Nuitka-winsvc 1.8.6__cp312-cp312-win_amd64.whl → 1.9.3__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/RECORD +212 -203
  3. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/WHEEL +1 -1
  4. nuitka/BytecodeCaching.py +4 -1
  5. nuitka/HardImportRegistry.py +348 -0
  6. nuitka/MainControl.py +45 -25
  7. nuitka/OptionParsing.py +31 -20
  8. nuitka/Options.py +47 -16
  9. nuitka/Progress.py +32 -2
  10. nuitka/PythonFlavors.py +1 -1
  11. nuitka/PythonVersions.py +61 -0
  12. nuitka/Tracing.py +25 -12
  13. nuitka/TreeXML.py +5 -5
  14. nuitka/Variables.py +15 -24
  15. nuitka/Version.py +16 -6
  16. nuitka/__main__.py +15 -0
  17. nuitka/__past__.py +15 -17
  18. nuitka/build/Backend.scons +44 -35
  19. nuitka/build/CCompilerVersion.scons +10 -9
  20. nuitka/build/Onefile.scons +11 -26
  21. nuitka/build/SconsCaching.py +2 -0
  22. nuitka/build/SconsCompilerSettings.py +72 -22
  23. nuitka/build/SconsHacks.py +1 -0
  24. nuitka/build/SconsInterface.py +5 -0
  25. nuitka/build/SconsSpawn.py +16 -3
  26. nuitka/build/SconsUtils.py +11 -12
  27. nuitka/build/include/nuitka/checksum_tools.h +0 -4
  28. nuitka/build/include/nuitka/compiled_asyncgen.h +1 -1
  29. nuitka/build/include/nuitka/compiled_coroutine.h +1 -1
  30. nuitka/build/include/nuitka/compiled_frame.h +7 -4
  31. nuitka/build/include/nuitka/compiled_function.h +13 -3
  32. nuitka/build/include/nuitka/compiled_generator.h +1 -1
  33. nuitka/build/include/nuitka/constants.h +2 -0
  34. nuitka/build/include/nuitka/environment_variables.h +45 -0
  35. nuitka/build/include/nuitka/exceptions.h +32 -4
  36. nuitka/build/include/nuitka/filesystem_paths.h +6 -1
  37. nuitka/build/include/nuitka/freelists.h +11 -1
  38. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  39. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  40. nuitka/build/include/nuitka/helpers.h +2 -0
  41. nuitka/build/include/nuitka/importing.h +3 -0
  42. nuitka/build/include/nuitka/prelude.h +17 -6
  43. nuitka/build/include/nuitka/unfreezing.h +1 -1
  44. nuitka/build/inline_copy/bin/scons.py +14 -0
  45. nuitka/build/inline_copy/tqdm/tqdm/__init__.py +2 -2
  46. nuitka/build/inline_copy/tqdm/tqdm/utils.py +14 -8
  47. nuitka/build/inline_copy/zlib/LICENSE +22 -0
  48. nuitka/build/inline_copy/zlib/crc32.c +1049 -0
  49. nuitka/build/inline_copy/zlib/crc32.h +9446 -0
  50. nuitka/build/inline_copy/zlib/zconf.h +551 -0
  51. nuitka/build/inline_copy/zlib/zlib.h +1938 -0
  52. nuitka/build/inline_copy/zlib/zutil.h +275 -0
  53. nuitka/build/static_src/CompiledAsyncgenType.c +41 -41
  54. nuitka/build/static_src/CompiledCodeHelpers.c +14 -7
  55. nuitka/build/static_src/CompiledCoroutineType.c +60 -51
  56. nuitka/build/static_src/CompiledFrameType.c +12 -12
  57. nuitka/build/static_src/CompiledFunctionType.c +149 -28
  58. nuitka/build/static_src/CompiledGeneratorType.c +64 -65
  59. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +1 -1
  60. nuitka/build/static_src/CompiledMethodType.c +5 -3
  61. nuitka/build/static_src/HelperEnvironmentVariables.c +120 -0
  62. nuitka/build/static_src/HelpersAttributes.c +1 -1
  63. nuitka/build/static_src/HelpersBuiltin.c +1 -1
  64. nuitka/build/static_src/HelpersChecksumTools.c +19 -4
  65. nuitka/build/static_src/HelpersComparisonEq.c +4 -4
  66. nuitka/build/static_src/HelpersComparisonNe.c +4 -4
  67. nuitka/build/static_src/HelpersConstantsBlob.c +40 -23
  68. nuitka/build/static_src/HelpersDictionaries.c +3 -1
  69. nuitka/build/static_src/HelpersDictionariesGenerated.c +9 -9
  70. nuitka/build/static_src/HelpersFilesystemPaths.c +12 -2
  71. nuitka/build/static_src/HelpersImport.c +29 -1
  72. nuitka/build/static_src/HelpersImportHard.c +19 -0
  73. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +5 -4
  74. nuitka/build/static_src/HelpersPythonPgo.c +5 -5
  75. nuitka/build/static_src/HelpersSafeStrings.c +2 -1
  76. nuitka/build/static_src/HelpersStrings.c +12 -10
  77. nuitka/build/static_src/HelpersTypes.c +1 -1
  78. nuitka/build/static_src/InspectPatcher.c +3 -2
  79. nuitka/build/static_src/MainProgram.c +182 -214
  80. nuitka/build/static_src/MetaPathBasedLoader.c +36 -23
  81. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +4 -2
  82. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +38 -2
  83. nuitka/build/static_src/OnefileBootstrap.c +124 -93
  84. nuitka/code_generation/CodeGeneration.py +4 -2
  85. nuitka/code_generation/CodeObjectCodes.py +5 -1
  86. nuitka/code_generation/ConstantCodes.py +4 -0
  87. nuitka/code_generation/Contexts.py +111 -3
  88. nuitka/code_generation/DictCodes.py +5 -5
  89. nuitka/code_generation/FunctionCodes.py +4 -2
  90. nuitka/code_generation/GlobalConstants.py +10 -0
  91. nuitka/code_generation/ImportCodes.py +69 -33
  92. nuitka/code_generation/ModuleCodes.py +4 -1
  93. nuitka/code_generation/Namify.py +6 -5
  94. nuitka/code_generation/YieldCodes.py +3 -3
  95. nuitka/code_generation/templates/CodeTemplatesModules.py +61 -95
  96. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +3 -3
  97. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +2 -2
  98. nuitka/distutils/DistutilCommands.py +3 -0
  99. nuitka/finalizations/FinalizeMarkups.py +1 -1
  100. nuitka/freezer/DependsExe.py +2 -1
  101. nuitka/freezer/DllDependenciesPosix.py +11 -1
  102. nuitka/freezer/IncludedEntryPoints.py +54 -16
  103. nuitka/freezer/Onefile.py +7 -3
  104. nuitka/freezer/Standalone.py +39 -17
  105. nuitka/importing/Importing.py +195 -62
  106. nuitka/importing/PreloadedPackages.py +2 -1
  107. nuitka/importing/Recursion.py +98 -27
  108. nuitka/importing/StandardLibrary.py +7 -4
  109. nuitka/nodes/BuiltinOpenNodes.py +28 -1
  110. nuitka/nodes/BuiltinRangeNodes.py +2 -2
  111. nuitka/nodes/BuiltinSumNodes.py +1 -1
  112. nuitka/nodes/ChildrenHavingMixins.py +326 -2
  113. nuitka/nodes/HardImportNodesGenerated.py +141 -38
  114. nuitka/nodes/ImportHardNodes.py +0 -8
  115. nuitka/nodes/ImportNodes.py +267 -361
  116. nuitka/nodes/IterationHandles.py +36 -17
  117. nuitka/nodes/LocalsScopes.py +3 -1
  118. nuitka/nodes/NodeBases.py +8 -14
  119. nuitka/nodes/OperatorNodes.py +9 -9
  120. nuitka/nodes/OutlineNodes.py +3 -3
  121. nuitka/nodes/PackageMetadataNodes.py +19 -9
  122. nuitka/nodes/SliceNodes.py +1 -1
  123. nuitka/nodes/VariableAssignNodes.py +25 -15
  124. nuitka/nodes/VariableRefNodes.py +7 -7
  125. nuitka/nodes/YieldNodes.py +2 -2
  126. nuitka/nodes/shapes/BuiltinTypeShapes.py +81 -6
  127. nuitka/nodes/shapes/ShapeMixins.py +21 -0
  128. nuitka/nodes/shapes/StandardShapes.py +9 -3
  129. nuitka/optimizations/OptimizeBuiltinCalls.py +1 -1
  130. nuitka/optimizations/TraceCollections.py +75 -0
  131. nuitka/pgo/PGO.py +14 -6
  132. nuitka/plugins/PluginBase.py +83 -11
  133. nuitka/plugins/Plugins.py +78 -35
  134. nuitka/plugins/standard/AntiBloatPlugin.py +46 -1
  135. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +1 -1
  136. nuitka/plugins/standard/DelvewheelPlugin.py +2 -1
  137. nuitka/plugins/standard/DillPlugin.py +3 -99
  138. nuitka/plugins/standard/DllFilesPlugin.py +45 -0
  139. nuitka/plugins/standard/GiPlugin.py +23 -10
  140. nuitka/plugins/standard/GlfwPlugin.py +1 -0
  141. nuitka/plugins/standard/ImplicitImports.py +267 -15
  142. nuitka/plugins/standard/KivyPlugin.py +1 -0
  143. nuitka/plugins/standard/MatplotlibPlugin.py +43 -25
  144. nuitka/plugins/standard/OptionsNannyPlugin.py +5 -6
  145. nuitka/plugins/standard/PkgResourcesPlugin.py +1 -1
  146. nuitka/plugins/standard/PmwPlugin.py +1 -1
  147. nuitka/plugins/standard/PySidePyQtPlugin.py +37 -20
  148. nuitka/plugins/standard/TkinterPlugin.py +44 -30
  149. nuitka/plugins/standard/TransformersPlugin.py +3 -1
  150. nuitka/plugins/standard/standard.nuitka-package.config.yml +522 -86
  151. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +8 -1
  152. nuitka/reports/CompilationReportReader.py +53 -0
  153. nuitka/reports/LicenseReport.rst.j2 +4 -4
  154. nuitka/reports/Reports.py +129 -47
  155. nuitka/specs/HardImportSpecs.py +6 -0
  156. nuitka/tools/data_composer/DataComposer.py +29 -17
  157. nuitka/tools/onefile_compressor/OnefileCompressor.py +173 -110
  158. nuitka/tools/podman/__main__.py +17 -2
  159. nuitka/tools/scanning/DisplayPackageDLLs.py +11 -2
  160. nuitka/tools/scanning/DisplayPackageData.py +1 -1
  161. nuitka/tools/specialize/CTypeDescriptions.py +36 -27
  162. nuitka/tools/specialize/SpecializeC.py +1 -1
  163. nuitka/tools/specialize/SpecializePython.py +16 -0
  164. nuitka/tools/testing/Common.py +3 -4
  165. nuitka/tools/testing/OutputComparison.py +23 -0
  166. nuitka/tools/testing/SearchModes.py +2 -2
  167. nuitka/tools/testing/compare_with_cpython/__main__.py +13 -4
  168. nuitka/tools/testing/measure_construct_performance/__main__.py +2 -5
  169. nuitka/tools/watch/__main__.py +194 -56
  170. nuitka/tree/Building.py +8 -2
  171. nuitka/tree/ComplexCallHelperFunctions.py +45 -15
  172. nuitka/tree/ReformulationAssignmentStatements.py +18 -12
  173. nuitka/tree/ReformulationCallExpressions.py +1 -1
  174. nuitka/tree/ReformulationClasses.py +11 -5
  175. nuitka/tree/ReformulationClasses3.py +30 -12
  176. nuitka/tree/ReformulationComparisonExpressions.py +4 -2
  177. nuitka/tree/ReformulationContractionExpressions.py +19 -11
  178. nuitka/tree/ReformulationDictionaryCreation.py +9 -3
  179. nuitka/tree/ReformulationExecStatements.py +6 -6
  180. nuitka/tree/ReformulationForLoopStatements.py +5 -5
  181. nuitka/tree/ReformulationFunctionStatements.py +6 -2
  182. nuitka/tree/ReformulationImportStatements.py +7 -2
  183. nuitka/tree/ReformulationLambdaExpressions.py +1 -1
  184. nuitka/tree/ReformulationMatchStatements.py +3 -1
  185. nuitka/tree/ReformulationNamespacePackages.py +7 -3
  186. nuitka/tree/ReformulationPrintStatements.py +1 -1
  187. nuitka/tree/ReformulationSequenceCreation.py +18 -6
  188. nuitka/tree/ReformulationWithStatements.py +8 -8
  189. nuitka/tree/ReformulationYieldExpressions.py +2 -2
  190. nuitka/tree/SourceHandling.py +27 -5
  191. nuitka/tree/VariableClosure.py +11 -1
  192. nuitka/utils/AppDirs.py +2 -2
  193. nuitka/utils/CStrings.py +39 -3
  194. nuitka/utils/CommandLineOptions.py +42 -1
  195. nuitka/utils/Distributions.py +305 -38
  196. nuitka/utils/Download.py +27 -8
  197. nuitka/utils/FileOperations.py +103 -20
  198. nuitka/utils/Hashing.py +2 -3
  199. nuitka/utils/Importing.py +60 -3
  200. nuitka/utils/InstalledPythons.py +31 -36
  201. nuitka/utils/Jinja2.py +11 -5
  202. nuitka/utils/ModuleNames.py +11 -3
  203. nuitka/utils/ReExecute.py +7 -0
  204. nuitka/utils/SharedLibraries.py +38 -14
  205. nuitka/utils/SlotMetaClasses.py +55 -0
  206. nuitka/utils/Utils.py +10 -0
  207. nuitka/utils/Yaml.py +9 -1
  208. nuitka/build/inline_copy/tqdm/tqdm/_tqdm_gui.py +0 -9
  209. nuitka/build/inline_copy/tqdm/tqdm/gui.py +0 -191
  210. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka-run.bat +0 -0
  211. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka.bat +0 -0
  212. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/LICENSE.txt +0 -0
  213. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/entry_points.txt +0 -0
  214. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/top_level.txt +0 -0
@@ -33,7 +33,6 @@ import os
33
33
  import sys
34
34
 
35
35
  from nuitka import Options
36
- from nuitka.__past__ import getMetaClassBase
37
36
  from nuitka.containers.Namedtuples import makeNamedtupleClass
38
37
  from nuitka.containers.OrderedSets import OrderedSet
39
38
  from nuitka.freezer.IncludedDataFiles import (
@@ -68,8 +67,16 @@ from nuitka.PythonVersions import (
68
67
  python_version,
69
68
  )
70
69
  from nuitka.Tracing import plugins_logger
71
- from nuitka.utils.Distributions import isDistributionCondaPackage
70
+ from nuitka.utils.Distributions import (
71
+ getDistributionFromModuleName,
72
+ getDistributionName,
73
+ isDistributionCondaPackage,
74
+ )
72
75
  from nuitka.utils.Execution import NuitkaCalledProcessError, check_output
76
+ from nuitka.utils.FileOperations import (
77
+ changeFilenameExtension,
78
+ getFileContents,
79
+ )
73
80
  from nuitka.utils.Importing import isBuiltinModuleName
74
81
  from nuitka.utils.ModuleNames import (
75
82
  ModuleName,
@@ -78,8 +85,10 @@ from nuitka.utils.ModuleNames import (
78
85
  pre_module_load_trigger_name,
79
86
  )
80
87
  from nuitka.utils.SharedLibraries import locateDLL, locateDLLsInDirectory
88
+ from nuitka.utils.SlotMetaClasses import getMetaClassBase
81
89
  from nuitka.utils.Utils import (
82
90
  getArchitecture,
91
+ isAndroidBasedLinux,
83
92
  isLinux,
84
93
  isMacOS,
85
94
  isWin32Windows,
@@ -112,6 +121,13 @@ def _getPackageNameFromDistributionName(distribution_name):
112
121
  return distribution_name
113
122
 
114
123
 
124
+ def _getDistributionNameFromPackageName(package_name):
125
+ distribution = getDistributionFromModuleName(package_name)
126
+
127
+ assert distribution is not None, package_name
128
+ return getDistributionName(distribution)
129
+
130
+
115
131
  def _getPackageVersion(distribution_name):
116
132
  if distribution_name not in _package_versions:
117
133
  try:
@@ -163,7 +179,7 @@ def _isPluginActive(plugin_name):
163
179
  return plugin_name in getUserActivatedPluginNames()
164
180
 
165
181
 
166
- class NuitkaPluginBase(getMetaClassBase("Plugin")):
182
+ class NuitkaPluginBase(getMetaClassBase("Plugin", require_slots=False)):
167
183
  """Nuitka base class for all plugins.
168
184
 
169
185
  Derive your plugin from "NuitkaPluginBase" please.
@@ -273,7 +289,7 @@ class NuitkaPluginBase(getMetaClassBase("Plugin")):
273
289
  # Virtual method, pylint: disable=no-self-use,unused-argument
274
290
  return ()
275
291
 
276
- def onModuleSourceCode(self, module_name, source_code):
292
+ def onModuleSourceCode(self, module_name, source_filename, source_code):
277
293
  """Inspect or modify source code.
278
294
 
279
295
  Args:
@@ -286,6 +302,7 @@ class NuitkaPluginBase(getMetaClassBase("Plugin")):
286
302
  going to allow simply checking the source code without the need to
287
303
  pass it back.
288
304
  """
305
+ # Virtual method, pylint: disable=unused-argument
289
306
  self.checkModuleSourceCode(module_name, source_code)
290
307
 
291
308
  return source_code
@@ -431,6 +448,25 @@ class NuitkaPluginBase(getMetaClassBase("Plugin")):
431
448
  # Virtual method, pylint: disable=no-self-use,unused-argument
432
449
  return None
433
450
 
451
+ def onModuleUsageLookAhead(
452
+ self, module_name, module_filename, module_kind, get_module_source
453
+ ):
454
+ """React to tentative recursion of a module coming up.
455
+
456
+ For definite usage, use onModuleRecursion where it's a fact and
457
+ happening next. This may be a usage that is later optimized away
458
+ and doesn't impact anything. The main usage is to setup e.g.
459
+ hard imports as a factory, e.g. with detectable lazy loaders.
460
+
461
+ Args:
462
+ module_name: full module name
463
+ module_filename: filename
464
+ module_kind: one of "py", "extension" (shared library)
465
+ get_module_source: callable to get module source code if any
466
+ Returns:
467
+ None
468
+ """
469
+
434
470
  def onModuleRecursion(
435
471
  self,
436
472
  module_name,
@@ -440,7 +476,7 @@ class NuitkaPluginBase(getMetaClassBase("Plugin")):
440
476
  source_ref,
441
477
  reason,
442
478
  ):
443
- """React to recursion to a module coming up.
479
+ """React to recursion of a module coming up.
444
480
 
445
481
  Args:
446
482
  module_name: full module name
@@ -555,22 +591,28 @@ Unwanted import of '%(unwanted)s' that %(problem)s '%(binding_name)s' encountere
555
591
  """
556
592
  return locateDLLsInDirectory(directory)
557
593
 
558
- def makeDllEntryPoint(self, source_path, dest_path, package_name, reason):
594
+ def makeDllEntryPoint(
595
+ self, source_path, dest_path, module_name, package_name, reason
596
+ ):
559
597
  """Create an entry point, as expected to be provided by getExtraDlls."""
560
598
  return makeDllEntryPoint(
561
599
  logger=self,
562
600
  source_path=source_path,
563
601
  dest_path=dest_path,
602
+ module_name=module_name,
564
603
  package_name=package_name,
565
604
  reason=reason,
566
605
  )
567
606
 
568
- def makeExeEntryPoint(self, source_path, dest_path, package_name, reason):
607
+ def makeExeEntryPoint(
608
+ self, source_path, dest_path, module_name, package_name, reason
609
+ ):
569
610
  """Create an entry point, as expected to be provided by getExtraDlls."""
570
611
  return makeExeEntryPoint(
571
612
  logger=self,
572
613
  source_path=source_path,
573
614
  dest_path=dest_path,
615
+ module_name=module_name,
574
616
  package_name=package_name,
575
617
  reason=reason,
576
618
  )
@@ -904,6 +946,21 @@ Unwanted import of '%(unwanted)s' that %(problem)s '%(binding_name)s' encountere
904
946
  # Virtual method, pylint: disable=no-self-use
905
947
  return None
906
948
 
949
+ @classmethod
950
+ def getPluginDataFilesDir(cls):
951
+ """Helper function that returns path, where data files for the plugin are stored."""
952
+ plugin_filename = sys.modules[cls.__module__].__file__
953
+ return changeFilenameExtension(plugin_filename, "")
954
+
955
+ def getPluginDataFileContents(self, filename):
956
+ """Helper function that returns contents of a plugin data file."""
957
+ return getFileContents(
958
+ os.path.join(
959
+ self.getPluginDataFilesDir(),
960
+ filename,
961
+ )
962
+ )
963
+
907
964
  def getExtraCodeFiles(self):
908
965
  """Add extra code files to the compilation.
909
966
 
@@ -1035,6 +1092,10 @@ except ImportError:
1035
1092
  except NuitkaCalledProcessError as e:
1036
1093
  if e.returncode == 38:
1037
1094
  return None
1095
+
1096
+ if Options.is_debug:
1097
+ self.info(cmd)
1098
+
1038
1099
  raise
1039
1100
 
1040
1101
  if str is not bytes: # We want to work with strings, that's hopefully OK.
@@ -1090,6 +1151,11 @@ except ImportError:
1090
1151
  # Virtual method, pylint: disable=unused-argument
1091
1152
  return self.plugin_name
1092
1153
 
1154
+ def getExtraConstantDefaultPopulation(self):
1155
+ """Provide extra global constant values to code generation."""
1156
+ # Virtual method, pylint: disable=no-self-use
1157
+ return ()
1158
+
1093
1159
  def decideAllowOutsideDependencies(self, module_name):
1094
1160
  """Decide if outside of Python dependencies are allowed.
1095
1161
 
@@ -1100,8 +1166,10 @@ except ImportError:
1100
1166
  return None
1101
1167
 
1102
1168
  @staticmethod
1103
- def getPackageVersion(distribution_name):
1169
+ def getPackageVersion(module_name):
1104
1170
  """Provide package version of a distribution."""
1171
+ distribution_name = _getDistributionNameFromPackageName(module_name)
1172
+
1105
1173
  return _getPackageVersion(distribution_name)
1106
1174
 
1107
1175
  def getEvaluationConditionControlTags(self):
@@ -1125,6 +1193,9 @@ except ImportError:
1125
1193
  "macos": isMacOS(),
1126
1194
  "win32": isWin32Windows(),
1127
1195
  "linux": isLinux(),
1196
+ "android": isAndroidBasedLinux(),
1197
+ "android32": isAndroidBasedLinux() and sys.maxsize < 2**32,
1198
+ "android64": isAndroidBasedLinux() and sys.maxsize >= 2**64 - 1,
1128
1199
  "anaconda": isAnacondaPython(),
1129
1200
  "is_conda_package": isDistributionCondaPackage,
1130
1201
  "debian_python": isDebianPackagePython(),
@@ -1133,6 +1204,7 @@ except ImportError:
1133
1204
  "deployment": isDeploymentMode(),
1134
1205
  # Querying package versions.
1135
1206
  "version": _getPackageVersion,
1207
+ "get_dist_name": _getDistributionNameFromPackageName,
1136
1208
  "plugin": _isPluginActive,
1137
1209
  "no_asserts": hasPythonFlagNoAsserts(),
1138
1210
  "no_docstrings": hasPythonFlagNoDocStrings(),
@@ -1142,7 +1214,7 @@ except ImportError:
1142
1214
  }
1143
1215
  )
1144
1216
 
1145
- if isWin32Windows():
1217
+ if isWin32Windows() or isMacOS():
1146
1218
  context.update(
1147
1219
  {
1148
1220
  "arch_x86": getArchitecture() == "x86",
@@ -1207,9 +1279,9 @@ except ImportError:
1207
1279
  plugins_logger.info(cls.plugin_name + ": " + message)
1208
1280
 
1209
1281
  @classmethod
1210
- def sysexit(cls, message, mnemonic=None):
1282
+ def sysexit(cls, message, mnemonic=None, reporting=True):
1211
1283
  plugins_logger.sysexit(
1212
- cls.plugin_name + ": " + message, mnemonic=mnemonic, reporting=True
1284
+ cls.plugin_name + ": " + message, mnemonic=mnemonic, reporting=reporting
1213
1285
  )
1214
1286
 
1215
1287
 
nuitka/plugins/Plugins.py CHANGED
@@ -119,10 +119,8 @@ def _addActivePlugin(plugin_class, args, force=False):
119
119
  else:
120
120
  plugin_args = {}
121
121
 
122
- try:
122
+ with withPluginProblemReporting(plugin_class, "Plugin initialization failed", ()):
123
123
  plugin_instance = plugin_class(**plugin_args)
124
- except TypeError as e:
125
- plugin_class.sysexit("Problem initializing plugin: %s" % e)
126
124
 
127
125
  assert isinstance(plugin_instance, NuitkaPluginBase), plugin_instance
128
126
 
@@ -465,8 +463,8 @@ class Plugins(object):
465
463
 
466
464
  @staticmethod
467
465
  def _reportImplicitImports(plugin, module, implicit_imports):
468
- from nuitka.importing import Recursion
469
466
  from nuitka.importing.Importing import getModuleNameAndKindFromFilename
467
+ from nuitka.importing.Recursion import decideRecursion, recurseTo
470
468
 
471
469
  for full_name, module_filename in implicit_imports:
472
470
  # TODO: The module_kind should be forwarded from previous in the class using locateModule code.
@@ -475,7 +473,7 @@ class Plugins(object):
475
473
  )
476
474
 
477
475
  # This will get back to all other plugins allowing them to inhibit it though.
478
- decision, decision_reason = Recursion.decideRecursion(
476
+ decision, decision_reason = decideRecursion(
479
477
  using_module_name=module.getFullName(),
480
478
  module_filename=module_filename,
481
479
  module_name=full_name,
@@ -483,7 +481,7 @@ class Plugins(object):
483
481
  )
484
482
 
485
483
  if decision:
486
- imported_module = Recursion.recurseTo(
484
+ imported_module = recurseTo(
487
485
  module_name=full_name,
488
486
  module_filename=module_filename,
489
487
  module_kind=module_kind,
@@ -972,7 +970,7 @@ class Plugins(object):
972
970
  fake_modules[full_name].append((fake_module, plugin, reason))
973
971
 
974
972
  @staticmethod
975
- def onModuleSourceCode(module_name, source_code):
973
+ def onModuleSourceCode(module_name, source_filename, source_code):
976
974
  assert type(module_name) is ModuleName
977
975
  assert type(source_code) is str
978
976
 
@@ -980,7 +978,11 @@ class Plugins(object):
980
978
 
981
979
  for plugin in getActivePlugins():
982
980
  with withPluginModuleNameProblemReporting(plugin, module_name):
983
- new_source_code = plugin.onModuleSourceCode(module_name, source_code)
981
+ new_source_code = plugin.onModuleSourceCode(
982
+ module_name=module_name,
983
+ source_filename=source_filename,
984
+ source_code=source_code,
985
+ )
984
986
  if new_source_code is not None and new_source_code != source_code:
985
987
  source_code = new_source_code
986
988
  contributing_plugins.add(plugin)
@@ -1039,6 +1041,43 @@ class Plugins(object):
1039
1041
 
1040
1042
  return result, deciding_plugins
1041
1043
 
1044
+ module_usage_looked_ahead_cache = set()
1045
+
1046
+ @classmethod
1047
+ def onModuleUsageLookAhead(cls, module_name, module_filename, module_kind):
1048
+ if module_name in cls.module_usage_looked_ahead_cache:
1049
+ return
1050
+
1051
+ cls.module_usage_looked_ahead_cache.add(module_name)
1052
+
1053
+ # Lazy load the source code if a plugin wants it, the pre_load caches
1054
+ # the result for later usage.
1055
+ def getModuleSourceCode():
1056
+ if module_kind != "py":
1057
+ return None
1058
+
1059
+ from nuitka.tree.SourceHandling import readSourceCodeFromFilename
1060
+
1061
+ if os.path.isdir(module_filename):
1062
+ source_filename = os.path.join(module_filename, "__init__.py")
1063
+ else:
1064
+ source_filename = module_filename
1065
+
1066
+ if not os.path.isfile(source_filename):
1067
+ return None
1068
+
1069
+ return readSourceCodeFromFilename(
1070
+ module_name=module_name, source_filename=source_filename, pre_load=True
1071
+ )
1072
+
1073
+ for plugin in getActivePlugins():
1074
+ plugin.onModuleUsageLookAhead(
1075
+ module_name=module_name,
1076
+ module_filename=module_filename,
1077
+ module_kind=module_kind,
1078
+ get_module_source=getModuleSourceCode,
1079
+ )
1080
+
1042
1081
  @staticmethod
1043
1082
  def onModuleRecursion(
1044
1083
  module_name, module_filename, module_kind, using_module_name, source_ref, reason
@@ -1303,9 +1342,9 @@ class Plugins(object):
1303
1342
 
1304
1343
  @classmethod
1305
1344
  def encodeDataComposerName(cls, name):
1345
+ # Encoding needs to match generated source code output.
1306
1346
  if str is not bytes:
1307
- # Encoding needs to match generated source code output.
1308
- name = name.encode("latin1")
1347
+ name = name.encode("utf8")
1309
1348
 
1310
1349
  for plugin in getActivePlugins():
1311
1350
  r = plugin.encodeDataComposerName(name)
@@ -1336,42 +1375,46 @@ class Plugins(object):
1336
1375
  yield value
1337
1376
 
1338
1377
  @classmethod
1339
- def decideAllowOutsideDependencies(cls, module_name):
1340
- if not Options.isExperimental("no-outside-dependencies"):
1341
- return None
1378
+ def getExtraConstantDefaultPopulation(cls):
1379
+ for plugin in getActivePlugins():
1380
+ for value in plugin.getExtraConstantDefaultPopulation():
1381
+ yield value
1342
1382
 
1383
+ @classmethod
1384
+ def decideAllowOutsideDependencies(cls, module_name):
1343
1385
  result = None
1344
1386
  plugin_name = None
1345
1387
 
1346
- if module_name is not None:
1347
- for plugin in getActivePlugins():
1348
- value = plugin.decideAllowOutsideDependencies(module_name)
1388
+ assert module_name is not None
1349
1389
 
1350
- if value is True:
1351
- if result is False:
1352
- plugin.sysexit(
1353
- "Error, conflicting allow/disallow outside dependencies of plug-in '%s'."
1354
- % plugin_name
1355
- )
1390
+ for plugin in getActivePlugins():
1391
+ value = plugin.decideAllowOutsideDependencies(module_name)
1356
1392
 
1357
- result = True
1358
- plugin_name = plugin.plugin_name
1393
+ if value is True:
1394
+ if result is False:
1395
+ plugin.sysexit(
1396
+ "Error, conflicting allow/disallow outside dependencies of plug-in '%s'."
1397
+ % plugin_name
1398
+ )
1359
1399
 
1360
- elif value is False:
1361
- if result is False:
1362
- plugin.sysexit(
1363
- "Error, conflicting allow/disallow outside dependencies of plug-in '%s'."
1364
- % plugin_name
1365
- )
1400
+ result = True
1401
+ plugin_name = plugin.plugin_name
1366
1402
 
1367
- result = False
1368
- plugin_name = plugin.plugin_name
1369
- elif value is not None:
1403
+ elif value is False:
1404
+ if result is False:
1370
1405
  plugin.sysexit(
1371
- "Error, can only return True, False, None from 'decideAllowOutsideDependencies' not %r"
1372
- % value
1406
+ "Error, conflicting allow/disallow outside dependencies of plug-in '%s'."
1407
+ % plugin_name
1373
1408
  )
1374
1409
 
1410
+ result = False
1411
+ plugin_name = plugin.plugin_name
1412
+ elif value is not None:
1413
+ plugin.sysexit(
1414
+ "Error, can only return True, False, None from 'decideAllowOutsideDependencies' not %r"
1415
+ % value
1416
+ )
1417
+
1375
1418
  return result
1376
1419
 
1377
1420
  @classmethod
@@ -92,6 +92,10 @@ class NuitkaPluginAntiBloat(NuitkaPluginBase):
92
92
  noinclude_setuptools_mode,
93
93
  "setuptools",
94
94
  )
95
+ self.handled_modules["triton"] = (
96
+ noinclude_setuptools_mode,
97
+ "setuptools",
98
+ )
95
99
  else:
96
100
  self.control_tags["use_setuptools"] = True
97
101
 
@@ -138,6 +142,10 @@ class NuitkaPluginAntiBloat(NuitkaPluginBase):
138
142
  noinclude_ipython_mode,
139
143
  "IPython",
140
144
  )
145
+ self.handled_modules["altair._magics"] = (
146
+ noinclude_ipython_mode,
147
+ "IPython",
148
+ )
141
149
  else:
142
150
  self.control_tags["use_ipython"] = True
143
151
 
@@ -446,7 +454,7 @@ Error, cannot evaluate module '%s' append code '%s' in '%s' due to: %s"""
446
454
 
447
455
  return source_code
448
456
 
449
- def onModuleSourceCode(self, module_name, source_code):
457
+ def onModuleSourceCode(self, module_name, source_filename, source_code):
450
458
  for anti_bloat_config in self.config.get(module_name, section="anti-bloat"):
451
459
  if self.evaluateCondition(
452
460
  full_name=module_name, condition=anti_bloat_config.get("when", "True")
@@ -533,6 +541,34 @@ Error, cannot eval module '%s' function '%s' replacement code '%s' in '%s' due t
533
541
 
534
542
  return result
535
543
 
544
+ def _getModuleBloatModeOverrides(self, using_module_name, intended_module_name):
545
+ while 1:
546
+ config = self.config.get(using_module_name, section="anti-bloat")
547
+
548
+ if config:
549
+ for anti_bloat_config in config:
550
+ bloat_mode_overrides = anti_bloat_config.get(
551
+ "bloat-mode-overrides", ()
552
+ )
553
+
554
+ if not bloat_mode_overrides:
555
+ continue
556
+
557
+ if self.evaluateCondition(
558
+ full_name=intended_module_name,
559
+ condition=anti_bloat_config.get("when", "True"),
560
+ ):
561
+ for module_name, mode in bloat_mode_overrides.items():
562
+ if module_name == intended_module_name:
563
+ return mode
564
+
565
+ using_module_name = using_module_name.getPackageName()
566
+
567
+ if not using_module_name:
568
+ break
569
+
570
+ return None
571
+
536
572
  def onModuleRecursion(
537
573
  self,
538
574
  module_name,
@@ -567,6 +603,15 @@ Error, cannot eval module '%s' function '%s' replacement code '%s' in '%s' due t
567
603
  return
568
604
 
569
605
  if module_name.hasNamespace(handled_module_name):
606
+ if using_module_name is not None:
607
+ override_mode = self._getModuleBloatModeOverrides(
608
+ using_module_name=using_module_name,
609
+ intended_module_name=intended_module_name,
610
+ )
611
+
612
+ if override_mode is not None:
613
+ mode = override_mode
614
+
570
615
  # Make sure the compilation aborts or warns if asked to
571
616
  if mode == "error":
572
617
  raise NuitkaForbiddenImportEncounter(
@@ -83,7 +83,7 @@ if False:
83
83
  class NuitkaPluginDetectorPylintEclipseAnnotations(NuitkaPluginBase):
84
84
  detector_for = NuitkaPluginPylintEclipseAnnotations
85
85
 
86
- def onModuleSourceCode(self, module_name, source_code):
86
+ def onModuleSourceCode(self, module_name, source_filename, source_code):
87
87
  if re.search(r"#\s*pylint:\s*disable=\s*(\w+)", source_code):
88
88
  self.warnUnusedPlugin(
89
89
  "Understand PyLint/PyDev annotations for warnings."
@@ -63,7 +63,7 @@ class NuitkaPluginDelvewheel(NuitkaPluginBase):
63
63
  def _add_dll_directory(self, arg):
64
64
  self.dll_directory = arg
65
65
 
66
- def onModuleSourceCode(self, module_name, source_code):
66
+ def onModuleSourceCode(self, module_name, source_filename, source_code):
67
67
  # Avoid regular expression match if possible.
68
68
  if "_delvewheel_" not in source_code:
69
69
  return None
@@ -136,6 +136,7 @@ class NuitkaPluginDelvewheel(NuitkaPluginBase):
136
136
  dest_path=os.path.join(
137
137
  os.path.basename(dll_directory), dll_basename
138
138
  ),
139
+ module_name=full_name,
139
140
  package_name=full_name,
140
141
  reason="needed by '%s'" % full_name.asString(),
141
142
  )
@@ -33,110 +33,14 @@ class NuitkaPluginDillWorkarounds(NuitkaPluginBase):
33
33
  def isAlwaysEnabled():
34
34
  return False
35
35
 
36
- @staticmethod
37
- def createPostModuleLoadCode(module):
36
+ def createPostModuleLoadCode(self, module):
38
37
  full_name = module.getFullName()
39
38
 
40
39
  if full_name == "dill":
41
- code = r"""\
42
- import dill._dill
43
-
44
- # Compiled methods need to be created.
45
- @dill.register(compiled_method)
46
- def save_compiled_method(pickler, obj):
47
- if str is not bytes:
48
- pickler.save_reduce(compiled_method, (obj.__func__, obj.__self__), obj=obj)
49
- else:
50
- pickler.save_reduce(compiled_method, (obj.im_func, obj.im_self, obj.im_class), obj=obj)
51
-
52
- def _create_compiled_function2(module_name, func_values, func_dict, func_defaults):
53
- if module_name not in compiled_function_tables:
54
- __import__(module_name)
55
-
56
- func = compiled_function_tables[module_name][1](*func_values)
57
- if func_dict:
58
- for key, value in func_dict.items():
59
- func[key] = value
60
-
61
- func.__defaults__ = func_defaults
62
-
63
- return func
64
-
65
- def _create_compiled_function3(module_name, func_values, func_dict, func_defaults, func_kwdefaults):
66
- if module_name not in compiled_function_tables:
67
- __import__(module_name)
68
-
69
- func = compiled_function_tables[module_name][1](*func_values)
70
- if func_dict:
71
- for key, value in func_dict.items():
72
- func[key] = value
73
-
74
- func.__defaults__ = func_defaults
75
- func.__kwdefaults__ = func_kwdefaults
76
-
77
- return func
78
-
79
-
80
- # Compiled methods might have to be created or not.
81
- @dill.register(compiled_function)
82
- def save_compiled_function(pickler, obj):
83
- if not dill._dill._locate_function(obj):
84
- stack = dill._dill.stack
85
-
86
- if getattr(pickler, '_recurse', False):
87
- from dill.detect import globalvars
88
- globs = globalvars(obj, recurse=True, builtin=True)
89
- if id(obj) in stack:
90
- globs = obj.__globals__ if str is not bytes else obj.func_globals
91
- else:
92
- globs = obj.__globals__ if str is not bytes else obj.func_globals
93
-
94
- _byref = getattr(pickler, '_byref', None)
95
- _recurse = getattr(pickler, '_recurse', None)
96
- _memo = (id(obj) in stack) and (_recurse is not None)
97
- stack[id(obj)] = len(stack), obj
98
-
99
- if str is not bytes:
100
- # Python3
101
- _super = ('super' in getattr(obj.__code__,'co_names',())) and (_byref is not None)
102
- if _super: pickler._byref = True
103
- if _memo: pickler._recurse = False
104
-
105
- pickler.save_reduce(
106
- _create_compiled_function3,
107
- (
108
- obj.__module__,
109
- compiled_function_tables[obj.__module__][0](obj),
110
- obj.__dict__,
111
- obj.__defaults__,
112
- obj.__kwdefaults__
113
- )
114
- )
115
- else:
116
- # Python2
117
- _super = ('super' in getattr(obj.__code__,'co_names',())) and (_byref is not None) and getattr(pickler, '_recurse', False)
118
- if _super: pickler._byref = True
119
- if _memo: pickler._recurse = False
120
-
121
- pickler.save_reduce(
122
- _create_compiled_function2,
123
- (
124
- obj.__module__,
125
- compiled_function_tables[obj.__module__][0](obj),
126
- obj.__dict__,
127
- obj.__defaults__
128
- )
129
- )
130
-
131
- if _super: pickler._byref = _byref
132
- if _memo: pickler._recurse = _recurse
133
- else:
134
- dill._dill.StockPickler.save_global(pickler, obj)
135
- """
136
40
  return (
137
- code,
41
+ self.getPluginDataFileContents("dill-postLoad.py"),
138
42
  """\
139
- Extending "dill" for compiled types to be pickable as well.""",
43
+ Extending "dill" for compiled types to be pickle-able as well.""",
140
44
  )
141
45
 
142
46
  @staticmethod