Nuitka-winsvc 2.1.5__cp311-cp311-win_amd64.whl → 2.2.1__cp311-cp311-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.

Potentially problematic release.


This version of Nuitka-winsvc might be problematic. Click here for more details.

Files changed (234) hide show
  1. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/RECORD +234 -225
  3. nuitka/Errors.py +4 -0
  4. nuitka/HardImportRegistry.py +18 -1
  5. nuitka/MainControl.py +27 -30
  6. nuitka/OptionParsing.py +32 -30
  7. nuitka/Options.py +26 -13
  8. nuitka/OutputDirectories.py +7 -4
  9. nuitka/PostProcessing.py +9 -7
  10. nuitka/Progress.py +3 -3
  11. nuitka/PythonVersions.py +2 -2
  12. nuitka/TreeXML.py +1 -1
  13. nuitka/Version.py +1 -1
  14. nuitka/build/Backend.scons +2 -1
  15. nuitka/build/DataComposerInterface.py +1 -0
  16. nuitka/build/Onefile.scons +2 -1
  17. nuitka/build/SconsCaching.py +64 -46
  18. nuitka/build/SconsCompilerSettings.py +19 -6
  19. nuitka/build/SconsHacks.py +0 -1
  20. nuitka/build/SconsInterface.py +84 -5
  21. nuitka/build/SconsProgress.py +0 -1
  22. nuitka/build/SconsUtils.py +9 -5
  23. nuitka/build/include/nuitka/allocator.h +8 -3
  24. nuitka/build/include/nuitka/compiled_cell.h +8 -0
  25. nuitka/build/include/nuitka/constants.h +2 -0
  26. nuitka/build/include/nuitka/exceptions.h +554 -179
  27. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  28. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  29. nuitka/build/include/nuitka/helper/ints.h +15 -2
  30. nuitka/build/include/nuitka/helper/lists.h +4 -1
  31. nuitka/build/include/nuitka/helper/raising.h +12 -0
  32. nuitka/build/include/nuitka/helper/tuples.h +5 -1
  33. nuitka/build/include/nuitka/helpers.h +5 -0
  34. nuitka/build/include/nuitka/importing.h +3 -4
  35. nuitka/build/include/nuitka/jit_sources.h +25 -0
  36. nuitka/build/include/nuitka/prelude.h +38 -11
  37. nuitka/build/include/nuitka/printing.h +3 -0
  38. nuitka/build/include/nuitka/threading.h +2 -6
  39. nuitka/build/include/nuitka/type_aliases.h +27 -0
  40. nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +0 -3
  41. nuitka/build/inline_copy/tqdm/tqdm/version.py +1 -4
  42. nuitka/build/static_src/CompiledAsyncgenType.c +99 -114
  43. nuitka/build/static_src/CompiledCodeHelpers.c +24 -14
  44. nuitka/build/static_src/CompiledCoroutineType.c +96 -114
  45. nuitka/build/static_src/CompiledFrameType.c +14 -11
  46. nuitka/build/static_src/CompiledFunctionType.c +34 -7
  47. nuitka/build/static_src/CompiledGeneratorType.c +248 -142
  48. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +60 -70
  49. nuitka/build/static_src/CompiledMethodType.c +8 -7
  50. nuitka/build/static_src/HelpersAttributes.c +2 -19
  51. nuitka/build/static_src/HelpersBuiltin.c +2 -1
  52. nuitka/build/static_src/HelpersComparisonEq.c +32 -18
  53. nuitka/build/static_src/HelpersComparisonGe.c +50 -36
  54. nuitka/build/static_src/HelpersComparisonGt.c +50 -36
  55. nuitka/build/static_src/HelpersComparisonLe.c +50 -36
  56. nuitka/build/static_src/HelpersComparisonLt.c +50 -36
  57. nuitka/build/static_src/HelpersComparisonNe.c +32 -18
  58. nuitka/build/static_src/HelpersDeepcopy.c +6 -8
  59. nuitka/build/static_src/HelpersDictionaries.c +8 -3
  60. nuitka/build/static_src/HelpersExceptions.c +36 -22
  61. nuitka/build/static_src/HelpersFiles.c +9 -0
  62. nuitka/build/static_src/HelpersFilesystemPaths.c +7 -7
  63. nuitka/build/static_src/HelpersImportHard.c +15 -0
  64. nuitka/build/static_src/HelpersJitSources.c +46 -0
  65. nuitka/build/static_src/HelpersLists.c +40 -0
  66. nuitka/build/static_src/HelpersOperationBinaryAdd.c +66 -66
  67. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +80 -33
  68. nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +16 -13
  69. nuitka/build/static_src/HelpersOperationBinarySub.c +39 -39
  70. nuitka/build/static_src/HelpersOperationInplaceAdd.c +54 -54
  71. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -1
  72. nuitka/build/static_src/HelpersOperationInplaceSub.c +50 -50
  73. nuitka/build/static_src/HelpersProfiling.c +3 -4
  74. nuitka/build/static_src/HelpersRaising.c +62 -1
  75. nuitka/build/static_src/HelpersStrings.c +203 -8
  76. nuitka/build/static_src/HelpersTypes.c +42 -0
  77. nuitka/build/static_src/MainProgram.c +1 -1
  78. nuitka/build/static_src/MetaPathBasedLoader.c +2 -1
  79. nuitka/build/static_src/OnefileBootstrap.c +3 -3
  80. nuitka/code_generation/BinaryOperationHelperDefinitions.py +5 -3
  81. nuitka/code_generation/BuiltinCodes.py +1 -0
  82. nuitka/code_generation/CodeGeneration.py +11 -0
  83. nuitka/code_generation/CodeHelpers.py +5 -3
  84. nuitka/code_generation/CodeObjectCodes.py +10 -6
  85. nuitka/code_generation/ComparisonCodes.py +19 -3
  86. nuitka/code_generation/ConstantCodes.py +5 -0
  87. nuitka/code_generation/Contexts.py +22 -6
  88. nuitka/code_generation/Emission.py +1 -0
  89. nuitka/code_generation/ErrorCodes.py +8 -16
  90. nuitka/code_generation/EvalCodes.py +5 -3
  91. nuitka/code_generation/ExceptionCodes.py +8 -1
  92. nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +1 -0
  93. nuitka/code_generation/FrameCodes.py +5 -3
  94. nuitka/code_generation/FunctionCodes.py +0 -1
  95. nuitka/code_generation/GeneratorCodes.py +3 -3
  96. nuitka/code_generation/GlobalConstants.py +1 -2
  97. nuitka/code_generation/ImportCodes.py +2 -0
  98. nuitka/code_generation/JitCodes.py +44 -0
  99. nuitka/code_generation/ListCodes.py +11 -17
  100. nuitka/code_generation/MatchCodes.py +0 -1
  101. nuitka/code_generation/ModuleCodes.py +2 -1
  102. nuitka/code_generation/Namify.py +0 -1
  103. nuitka/code_generation/NetworkxCodes.py +51 -0
  104. nuitka/code_generation/OperationCodes.py +8 -6
  105. nuitka/code_generation/PackageResourceCodes.py +7 -5
  106. nuitka/code_generation/TensorflowCodes.py +54 -0
  107. nuitka/code_generation/TypeAliasCodes.py +71 -0
  108. nuitka/code_generation/VariableCodes.py +7 -5
  109. nuitka/code_generation/VariableDeclarations.py +1 -0
  110. nuitka/code_generation/c_types/CTypeCLongs.py +0 -1
  111. nuitka/code_generation/c_types/CTypeNuitkaInts.py +0 -1
  112. nuitka/code_generation/c_types/CTypeVoids.py +1 -0
  113. nuitka/code_generation/templates/CodeTemplatesConstants.py +15 -0
  114. nuitka/code_generation/templates/CodeTemplatesExceptions.py +1 -1
  115. nuitka/code_generation/templates/CodeTemplatesIterators.py +0 -1
  116. nuitka/code_generation/templates/CodeTemplatesLoader.py +0 -1
  117. nuitka/code_generation/templates/CodeTemplatesModules.py +4 -1
  118. nuitka/code_generation/templates/CodeTemplatesVariables.py +8 -8
  119. nuitka/code_generation/templates/TemplateDebugWrapper.py +0 -1
  120. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -0
  121. nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +9 -7
  122. nuitka/containers/Namedtuples.py +0 -1
  123. nuitka/finalizations/Finalization.py +1 -0
  124. nuitka/finalizations/FinalizeMarkups.py +0 -1
  125. nuitka/freezer/DllDependenciesMacOS.py +60 -13
  126. nuitka/freezer/DllDependenciesPosix.py +0 -1
  127. nuitka/freezer/IncludedDataFiles.py +46 -15
  128. nuitka/freezer/IncludedEntryPoints.py +5 -3
  129. nuitka/freezer/Standalone.py +6 -1
  130. nuitka/importing/ImportCache.py +2 -2
  131. nuitka/importing/ImportResolving.py +80 -78
  132. nuitka/importing/Importing.py +34 -1
  133. nuitka/nodes/AttributeNodesGenerated.py +21 -6
  134. nuitka/nodes/BuiltinComplexNodes.py +1 -0
  135. nuitka/nodes/BuiltinFormatNodes.py +1 -0
  136. nuitka/nodes/BuiltinIteratorNodes.py +5 -3
  137. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +21 -6
  138. nuitka/nodes/BuiltinRefNodes.py +8 -1
  139. nuitka/nodes/BuiltinVarsNodes.py +0 -1
  140. nuitka/nodes/ChildrenHavingMixins.py +906 -186
  141. nuitka/nodes/CodeObjectSpecs.py +1 -1
  142. nuitka/nodes/ConstantRefNodes.py +38 -0
  143. nuitka/nodes/CtypesNodes.py +0 -1
  144. nuitka/nodes/DictionaryNodes.py +0 -1
  145. nuitka/nodes/ExceptionNodes.py +10 -0
  146. nuitka/nodes/ExpressionBases.py +15 -9
  147. nuitka/nodes/ExpressionBasesGenerated.py +32 -15
  148. nuitka/nodes/FunctionNodes.py +50 -5
  149. nuitka/nodes/HardImportNodesGenerated.py +245 -60
  150. nuitka/nodes/ImportHardNodes.py +27 -13
  151. nuitka/nodes/ImportNodes.py +90 -70
  152. nuitka/nodes/InjectCNodes.py +0 -1
  153. nuitka/nodes/ModuleNodes.py +10 -5
  154. nuitka/nodes/NetworkxNodes.py +45 -0
  155. nuitka/nodes/OperatorNodesUnary.py +1 -0
  156. nuitka/nodes/OsSysNodes.py +0 -1
  157. nuitka/nodes/PackageMetadataNodes.py +0 -1
  158. nuitka/nodes/PackageResourceNodes.py +10 -6
  159. nuitka/nodes/StatementBasesGenerated.py +107 -60
  160. nuitka/nodes/StringConcatenationNodes.py +1 -0
  161. nuitka/nodes/TensorflowNodes.py +38 -0
  162. nuitka/nodes/TypeNodes.py +21 -0
  163. nuitka/nodes/VariableRefNodes.py +1 -0
  164. nuitka/nodes/shapes/BuiltinTypeShapes.py +25 -15
  165. nuitka/optimizations/Optimization.py +7 -6
  166. nuitka/optimizations/OptimizeBuiltinCalls.py +11 -9
  167. nuitka/optimizations/Tags.py +0 -1
  168. nuitka/optimizations/TraceCollections.py +6 -55
  169. nuitka/optimizations/ValueTraces.py +49 -1
  170. nuitka/plugins/PluginBase.py +26 -4
  171. nuitka/plugins/Plugins.py +49 -12
  172. nuitka/plugins/standard/AntiBloatPlugin.py +12 -2
  173. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +0 -1
  174. nuitka/plugins/standard/DataFilesPlugin.py +2 -6
  175. nuitka/plugins/standard/DillPlugin.py +3 -3
  176. nuitka/plugins/standard/DllFilesPlugin.py +29 -23
  177. nuitka/plugins/standard/GiPlugin.py +1 -0
  178. nuitka/plugins/standard/ImplicitImports.py +9 -7
  179. nuitka/plugins/standard/MatplotlibPlugin.py +1 -0
  180. nuitka/plugins/standard/OptionsNannyPlugin.py +3 -7
  181. nuitka/plugins/standard/PkgResourcesPlugin.py +0 -1
  182. nuitka/plugins/standard/PmwPlugin.py +10 -9
  183. nuitka/plugins/standard/PySidePyQtPlugin.py +0 -28
  184. nuitka/plugins/standard/TensorflowPlugin.py +1 -0
  185. nuitka/plugins/standard/TorchPlugin.py +1 -0
  186. nuitka/plugins/standard/TrioPlugin.py +1 -0
  187. nuitka/plugins/standard/standard.nuitka-package.config.yml +242 -54
  188. nuitka/reports/CompilationReportReader.py +0 -1
  189. nuitka/reports/Reports.py +49 -5
  190. nuitka/specs/BuiltinParameterSpecs.py +10 -2
  191. nuitka/specs/BuiltinStrOperationSpecs.py +1 -1
  192. nuitka/specs/BuiltinTypeOperationSpecs.py +0 -1
  193. nuitka/specs/HardImportSpecs.py +34 -1
  194. nuitka/specs/ParameterSpecs.py +11 -9
  195. nuitka/tools/environments/Virtualenv.py +0 -1
  196. nuitka/tools/specialize/CTypeDescriptions.py +15 -11
  197. nuitka/tools/specialize/SpecializeC.py +11 -9
  198. nuitka/tools/specialize/SpecializePython.py +57 -30
  199. nuitka/tools/testing/Common.py +24 -7
  200. nuitka/tools/testing/OutputComparison.py +4 -0
  201. nuitka/tools/testing/Pythons.py +0 -1
  202. nuitka/tools/testing/compare_with_cpython/__main__.py +0 -4
  203. nuitka/tools/watch/GitHub.py +4 -1
  204. nuitka/tools/watch/__main__.py +22 -1
  205. nuitka/tree/Building.py +3 -0
  206. nuitka/tree/InternalModule.py +0 -1
  207. nuitka/tree/ReformulationAssertStatements.py +1 -0
  208. nuitka/tree/ReformulationAssignmentStatements.py +26 -3
  209. nuitka/tree/ReformulationClasses3.py +23 -26
  210. nuitka/tree/ReformulationContractionExpressions.py +5 -3
  211. nuitka/tree/ReformulationDictionaryCreation.py +6 -5
  212. nuitka/tree/ReformulationExecStatements.py +8 -6
  213. nuitka/tree/ReformulationFunctionStatements.py +10 -6
  214. nuitka/tree/SourceHandling.py +8 -0
  215. nuitka/tree/TreeHelpers.py +6 -3
  216. nuitka/utils/AppDirs.py +6 -2
  217. nuitka/utils/CStrings.py +1 -1
  218. nuitka/utils/CommandLineOptions.py +0 -1
  219. nuitka/utils/Distributions.py +3 -3
  220. nuitka/utils/Download.py +5 -1
  221. nuitka/utils/Execution.py +6 -3
  222. nuitka/utils/FileOperations.py +62 -35
  223. nuitka/utils/Importing.py +4 -4
  224. nuitka/utils/InstanceCounters.py +1 -0
  225. nuitka/utils/MacOSApp.py +1 -0
  226. nuitka/utils/Shebang.py +1 -0
  227. nuitka/utils/Utils.py +39 -1
  228. nuitka/utils/WindowsFileUsage.py +4 -3
  229. {Nuitka_winsvc-2.1.5.data → Nuitka_winsvc-2.2.1.data}/scripts/nuitka-run.bat +0 -0
  230. {Nuitka_winsvc-2.1.5.data → Nuitka_winsvc-2.2.1.data}/scripts/nuitka.bat +0 -0
  231. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/LICENSE.txt +0 -0
  232. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/WHEEL +0 -0
  233. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/entry_points.txt +0 -0
  234. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,11 @@
3
3
 
4
4
  """ Nodes representing more trusted imports. """
5
5
 
6
- from nuitka.importing.Importing import locateModule, makeModuleUsageAttempt
6
+ from nuitka.importing.Importing import (
7
+ locateModule,
8
+ makeModuleUsageAttempt,
9
+ makeParentModuleUsagesAttempts,
10
+ )
7
11
  from nuitka.utils.ModuleNames import ModuleName
8
12
 
9
13
  from .ExpressionBases import ExpressionBase
@@ -12,7 +16,13 @@ from .ExpressionBases import ExpressionBase
12
16
  class ExpressionImportHardBase(ExpressionBase):
13
17
  # Base classes can be abstract, pylint: disable=abstract-method
14
18
  #
15
- __slots__ = ("module_name", "finding", "module_kind", "module_filename")
19
+ __slots__ = (
20
+ "module_name",
21
+ "finding",
22
+ "module_kind",
23
+ "module_filename",
24
+ "module_usages",
25
+ )
16
26
 
17
27
  def __init__(self, module_name, source_ref):
18
28
  ExpressionBase.__init__(self, source_ref)
@@ -34,17 +44,21 @@ class ExpressionImportHardBase(ExpressionBase):
34
44
  assert self.finding != "not-found", self.module_name
35
45
  assert _module_name == self.module_name, (self.module_name, _module_name)
36
46
 
37
- def getModuleUsageAttempt(self):
38
- return makeModuleUsageAttempt(
39
- module_name=self.module_name,
40
- filename=self.module_filename,
41
- module_kind=self.module_kind,
42
- finding=self.finding,
43
- level=0,
44
- source_ref=self.source_ref,
45
- reason="import",
47
+ self.module_usages = makeParentModuleUsagesAttempts(
48
+ makeModuleUsageAttempt(
49
+ module_name=self.module_name,
50
+ filename=self.module_filename,
51
+ module_kind=self.module_kind,
52
+ finding=self.finding,
53
+ level=0,
54
+ source_ref=self.source_ref,
55
+ reason="import",
56
+ )
46
57
  )
47
58
 
59
+ def getModuleUsageAttempts(self):
60
+ return self.module_usages
61
+
48
62
 
49
63
  class ExpressionImportModuleNameHardBase(ExpressionImportHardBase):
50
64
  """Hard import names base class."""
@@ -96,7 +110,7 @@ class ExpressionImportModuleNameHardMaybeExists(ExpressionImportModuleNameHardBa
96
110
  trace_collection.onExceptionRaiseExit(AttributeError)
97
111
 
98
112
  # Trace the module usage attempt.
99
- trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
113
+ trace_collection.onModuleUsageAttempts(self.getModuleUsageAttempts())
100
114
 
101
115
  return self, None, None
102
116
 
@@ -122,7 +136,7 @@ class ExpressionImportModuleNameHardExists(ExpressionImportModuleNameHardBase):
122
136
  trace_collection.onExceptionRaiseExit(ImportError)
123
137
 
124
138
  # Trace the module usage attempt.
125
- trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
139
+ trace_collection.onModuleUsageAttempts(self.getModuleUsageAttempts())
126
140
 
127
141
  # As good as it gets.
128
142
  return self, None, None
@@ -37,6 +37,7 @@ from nuitka.importing.Importing import (
37
37
  isPackageDir,
38
38
  locateModule,
39
39
  makeModuleUsageAttempt,
40
+ makeParentModuleUsagesAttempts,
40
41
  )
41
42
  from nuitka.importing.ImportResolving import resolveModuleName
42
43
  from nuitka.importing.Recursion import decideRecursion
@@ -47,6 +48,7 @@ from nuitka.Options import (
47
48
  shallMakeModule,
48
49
  shallWarnUnusualCode,
49
50
  )
51
+ from nuitka.plugins.Plugins import Plugins
50
52
  from nuitka.PythonVersions import python_version
51
53
  from nuitka.specs.BuiltinParameterSpecs import (
52
54
  BuiltinParameterSpec,
@@ -139,6 +141,7 @@ class ExpressionImportModuleFixed(ExpressionBase):
139
141
  "found_module_filename",
140
142
  "module_kind",
141
143
  "finding",
144
+ "module_usages",
142
145
  )
143
146
 
144
147
  def __init__(self, module_name, value_name, source_ref):
@@ -157,6 +160,18 @@ class ExpressionImportModuleFixed(ExpressionBase):
157
160
  self.finding,
158
161
  ) = self._attemptFollow()
159
162
 
163
+ self.module_usages = makeParentModuleUsagesAttempts(
164
+ makeModuleUsageAttempt(
165
+ module_name=self.found_module_name,
166
+ filename=self.found_module_filename,
167
+ finding=self.finding,
168
+ module_kind=self.module_kind,
169
+ level=0,
170
+ source_ref=self.source_ref,
171
+ reason="import",
172
+ )
173
+ )
174
+
160
175
  # TODO: This is called in constructor only, is it, then inline it.
161
176
  def _attemptFollow(self):
162
177
  found_module_name, found_module_filename, module_kind, finding = locateModule(
@@ -218,23 +233,15 @@ class ExpressionImportModuleFixed(ExpressionBase):
218
233
  else:
219
234
  return tshape_module
220
235
 
221
- def getModuleUsageAttempt(self):
222
- return makeModuleUsageAttempt(
223
- module_name=self.found_module_name,
224
- filename=self.found_module_filename,
225
- finding=self.finding,
226
- module_kind=self.module_kind,
227
- level=0,
228
- source_ref=self.source_ref,
229
- reason="import",
230
- )
236
+ def getModuleUsageAttempts(self):
237
+ return self.module_usages
231
238
 
232
239
  def computeExpressionRaw(self, trace_collection):
233
240
  if self.mayRaiseException(BaseException):
234
241
  trace_collection.onExceptionRaiseExit(BaseException)
235
242
 
236
243
  # Trace the module usage attempt.
237
- trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
244
+ trace_collection.onModuleUsageAttempts(self.getModuleUsageAttempts())
238
245
 
239
246
  # Nothing to do about it.
240
247
  return self, None, None
@@ -263,6 +270,7 @@ class ExpressionImportModuleBuiltin(ExpressionBase):
263
270
  "value_name",
264
271
  "module_kind",
265
272
  "builtin_module",
273
+ "module_usages",
266
274
  )
267
275
 
268
276
  def __init__(self, module_name, value_name, source_ref):
@@ -284,6 +292,18 @@ class ExpressionImportModuleBuiltin(ExpressionBase):
284
292
  assert _finding == "built-in", _finding
285
293
  assert _module_kind is None, _module_kind
286
294
 
295
+ self.module_usages = makeParentModuleUsagesAttempts(
296
+ makeModuleUsageAttempt(
297
+ module_name=self.module_name,
298
+ filename=None,
299
+ finding="built-in",
300
+ module_kind=None,
301
+ level=0,
302
+ source_ref=self.source_ref,
303
+ reason="import",
304
+ )
305
+ )
306
+
287
307
  @staticmethod
288
308
  def getTypeShape():
289
309
  return tshape_module_builtin
@@ -310,23 +330,15 @@ class ExpressionImportModuleBuiltin(ExpressionBase):
310
330
  def mayRaiseException(self, exception_type):
311
331
  return isNonRaisingBuiltinModule(self.module_name) is not False
312
332
 
313
- def getModuleUsageAttempt(self):
314
- return makeModuleUsageAttempt(
315
- module_name=self.module_name,
316
- filename=None,
317
- finding="built-in",
318
- module_kind=None,
319
- level=0,
320
- source_ref=self.source_ref,
321
- reason="import",
322
- )
333
+ def getModuleUsageAttempts(self):
334
+ return self.module_usages
323
335
 
324
336
  def computeExpressionRaw(self, trace_collection):
325
337
  if self.mayRaiseException(BaseException):
326
338
  trace_collection.onExceptionRaiseExit(BaseException)
327
339
 
328
340
  # Trace the module usage attempt.
329
- trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
341
+ trace_collection.onModuleUsageAttempts(self.getModuleUsageAttempts())
330
342
 
331
343
  # Nothing to do about it.
332
344
  return self, None, None
@@ -428,7 +440,7 @@ class ExpressionImportModuleHard(
428
440
  trace_collection.onExceptionRaiseExit(BaseException)
429
441
 
430
442
  # Trace the module usage attempt.
431
- trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
443
+ trace_collection.onModuleUsageAttempts(self.getModuleUsageAttempts())
432
444
 
433
445
  return self, None, None
434
446
 
@@ -479,11 +491,11 @@ class ExpressionImportModuleHard(
479
491
  def _computeExpressionAttribute(
480
492
  self, lookup_node, attribute_name, trace_collection, is_import
481
493
  ):
482
- # Return driven handling of many cases, pylint: disable=too-many-return-statements
494
+ # Return driven handling of many cases
495
+ # pylint: disable=too-many-branches,too-many-return-statements
483
496
 
484
- if self.module is not None and self.allowed:
497
+ if self.allowed:
485
498
  full_name = self.value_name.getChildNamed(attribute_name)
486
-
487
499
  full_name = ModuleName(hard_modules_aliases.get(full_name, full_name))
488
500
 
489
501
  if isHardModule(full_name):
@@ -501,9 +513,12 @@ class ExpressionImportModuleHard(
501
513
  % (self.value_name, attribute_name),
502
514
  )
503
515
 
504
- trust = hard_modules_trust[self.value_name].get(
505
- attribute_name, trust_undefined
506
- )
516
+ if self.value_name in hard_modules_trust:
517
+ trust = hard_modules_trust[self.value_name].get(
518
+ attribute_name, trust_undefined
519
+ )
520
+ else:
521
+ trust = trust_undefined
507
522
 
508
523
  if trust is trust_importable:
509
524
  # TODO: Change this is a hard module import itself, currently these are not all trusted
@@ -512,8 +527,10 @@ class ExpressionImportModuleHard(
512
527
  trace_collection.onExceptionRaiseExit(BaseException)
513
528
  elif trust is trust_may_exist:
514
529
  trace_collection.onExceptionRaiseExit(BaseException)
515
- elif trust is not trust_undefined and not hasattr(
516
- self.module, attribute_name
530
+ elif (
531
+ trust is not trust_undefined
532
+ and self.module is not None
533
+ and not hasattr(self.module, attribute_name)
517
534
  ):
518
535
  # TODO: Unify with below branches.
519
536
  trace_collection.onExceptionRaiseExit(ImportError)
@@ -573,7 +590,7 @@ class ExpressionImportModuleHard(
573
590
  self.value_name,
574
591
  attribute_name,
575
592
  )
576
- elif trust is trust_constant:
593
+ elif trust is trust_constant and self.module is not None:
577
594
  # Make sure it's actually there, and not becoming the getattr default by accident.
578
595
  assert hasattr(self.module, attribute_name), self
579
596
 
@@ -795,6 +812,30 @@ addModuleSingleAttributeNodeFactory(
795
812
  )
796
813
 
797
814
 
815
+ def _makeParentImportModuleUsages(module_name, source_ref):
816
+ for parent_package_name in module_name.getParentPackageNames():
817
+ (
818
+ _parent_package_name,
819
+ parent_module_filename,
820
+ parent_module_kind,
821
+ parent_module_finding,
822
+ ) = locateModule(
823
+ module_name=parent_package_name,
824
+ parent_package=None,
825
+ level=0,
826
+ )
827
+
828
+ yield makeModuleUsageAttempt(
829
+ module_name=parent_package_name,
830
+ filename=parent_module_filename,
831
+ finding=parent_module_finding,
832
+ module_kind=parent_module_kind,
833
+ level=0,
834
+ source_ref=source_ref,
835
+ reason="import path parent",
836
+ )
837
+
838
+
798
839
  class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBase):
799
840
  __slots__ = (
800
841
  "follow_attempted",
@@ -850,7 +891,7 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
850
891
  return level_value
851
892
 
852
893
  def _attemptFollow(self, module_name):
853
- # Complex stuff, pylint: disable=too-many-branches,too-many-locals
894
+ # Complex stuff, pylint: disable=too-many-branches
854
895
 
855
896
  # Without the level value, we don't know what it is.
856
897
  level_value = self._getLevelValue()
@@ -885,7 +926,15 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
885
926
  level=level_value,
886
927
  )
887
928
 
888
- self.used_modules = [
929
+ # Allow for the import look ahead, to change what modules are
930
+ # considered hard imports.
931
+ Plugins.onModuleUsageLookAhead(
932
+ module_name=module_name_found,
933
+ module_filename=module_filename,
934
+ module_kind=module_kind,
935
+ )
936
+
937
+ self.used_modules = makeParentModuleUsagesAttempts(
889
938
  makeModuleUsageAttempt(
890
939
  module_name=module_name_found,
891
940
  filename=module_filename,
@@ -895,7 +944,7 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
895
944
  source_ref=self.source_ref,
896
945
  reason="import",
897
946
  )
898
- ]
947
+ )
899
948
 
900
949
  if self.finding != "not-found":
901
950
  module_name = module_name_found
@@ -929,6 +978,8 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
929
978
  level=1, # Relative import
930
979
  )
931
980
 
981
+ self.used_modules = list(self.used_modules)
982
+
932
983
  self.used_modules.append(
933
984
  makeModuleUsageAttempt(
934
985
  module_name=name_import_module_name,
@@ -937,44 +988,14 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
937
988
  finding=name_import_finding,
938
989
  level=1,
939
990
  source_ref=self.source_ref,
940
- reason="import",
991
+ reason="import fromlist",
941
992
  )
942
993
  )
943
994
 
995
+ self.used_modules = tuple(self.used_modules)
996
+
944
997
  return module_filename
945
998
  else:
946
- while True:
947
- module_name = module_name.getPackageName()
948
-
949
- if not module_name:
950
- break
951
-
952
- (
953
- found_module_name,
954
- module_filename,
955
- module_kind,
956
- finding,
957
- ) = locateModule(
958
- module_name=module_name,
959
- parent_package=parent_package,
960
- level=level_value,
961
- )
962
-
963
- self.used_modules.append(
964
- makeModuleUsageAttempt(
965
- module_name=found_module_name,
966
- filename=module_filename,
967
- module_kind=module_kind,
968
- finding=finding,
969
- level=level_value,
970
- source_ref=self.source_ref,
971
- reason="import",
972
- )
973
- )
974
-
975
- if finding != "not-found":
976
- break
977
-
978
999
  return None
979
1000
 
980
1001
  def _getImportedValueName(self, imported_module_name):
@@ -999,8 +1020,7 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
999
1020
  trace_collection.onExceptionRaiseExit(RuntimeError)
1000
1021
 
1001
1022
  # Trace the module usage attempts.
1002
- for module_usage_attempt in self.used_modules:
1003
- trace_collection.onModuleUsageAttempt(module_usage_attempt)
1023
+ trace_collection.onModuleUsageAttempts(self.used_modules)
1004
1024
 
1005
1025
  # We stay here.
1006
1026
  return self, None, None
@@ -3,7 +3,6 @@
3
3
 
4
4
  """ Nodes to inject C code into generated code. """
5
5
 
6
-
7
6
  from .NodeBases import StatementBase
8
7
 
9
8
 
@@ -131,7 +131,7 @@ class PythonModuleBase(NodeBase):
131
131
  )
132
132
 
133
133
  def getCodeName(self):
134
- # Abstract method, pylint: disable=no-self-use
134
+ # Virtual method, pylint: disable=no-self-use
135
135
  return None
136
136
 
137
137
  def getCompileTimeFilename(self):
@@ -450,7 +450,10 @@ class CompiledPythonModule(
450
450
  # For code name of modules, we need to translate to C identifiers,
451
451
  # removing characters illegal for that.
452
452
 
453
- return encodePythonIdentifierToC(self.getFullName())
453
+ if self.code_name is None:
454
+ self.code_name = encodePythonIdentifierToC(self.module_name)
455
+
456
+ return self.code_name
454
457
 
455
458
  @staticmethod
456
459
  def getChildQualname(function_name):
@@ -540,9 +543,11 @@ class CompiledPythonModule(
540
543
 
541
544
  self.trace_collection = TraceCollectionModule(
542
545
  self,
543
- very_trusted_module_variables=old_collection.getVeryTrustedModuleVariables()
544
- if old_collection is not None
545
- else {},
546
+ very_trusted_module_variables=(
547
+ old_collection.getVeryTrustedModuleVariables()
548
+ if old_collection is not None
549
+ else {}
550
+ ),
546
551
  )
547
552
 
548
553
  module_body = self.subnode_body
@@ -0,0 +1,45 @@
1
+ # Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+
4
+ """ Nodes that represent networkx functions
5
+
6
+ """
7
+
8
+ from nuitka.HardImportRegistry import addModuleDynamicHard
9
+
10
+ # TODO: Disabled for now, keyword only arguments and star list argument are
11
+ # having ordering issues for call matching and code generation.
12
+
13
+ if False: # pylint: disable=using-constant-test
14
+ from .HardImportNodesGenerated import ( # pylint: disable=no-name-in-module
15
+ ExpressionNetworkxUtilsDecoratorsArgmapCallBase,
16
+ )
17
+
18
+ addModuleDynamicHard(module_name="networkx.utils.decorators")
19
+
20
+ class ExpressionNetworkxUtilsDecoratorsArgmapCall(
21
+ ExpressionNetworkxUtilsDecoratorsArgmapCallBase
22
+ ):
23
+ kind = "EXPRESSION_NETWORKX_UTILS_DECORATORS_ARGMAP_CALL"
24
+
25
+ def replaceWithCompileTimeValue(self, trace_collection):
26
+ # TODO: The node generation should allow for this to not be necessary
27
+ trace_collection.onExceptionRaiseExit(BaseException)
28
+
29
+ return self, None, None
30
+
31
+
32
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
33
+ # integrates with CPython, but also works on its own.
34
+ #
35
+ # Licensed under the Apache License, Version 2.0 (the "License");
36
+ # you may not use this file except in compliance with the License.
37
+ # You may obtain a copy of the License at
38
+ #
39
+ # http://www.apache.org/licenses/LICENSE-2.0
40
+ #
41
+ # Unless required by applicable law or agreed to in writing, software
42
+ # distributed under the License is distributed on an "AS IS" BASIS,
43
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ # See the License for the specific language governing permissions and
45
+ # limitations under the License.
@@ -5,6 +5,7 @@
5
5
 
6
6
  Some of these come from built-ins, e.g. abs, some from syntax, and repr from both.
7
7
  """
8
+
8
9
  from nuitka import PythonOperators
9
10
 
10
11
  from .ChildrenHavingMixins import ChildHavingOperandMixin
@@ -3,7 +3,6 @@
3
3
 
4
4
  """ Nodes the represent ways to access os and sys functions. """
5
5
 
6
-
7
6
  import os
8
7
 
9
8
  from .BuiltinRefNodes import ExpressionBuiltinExceptionRef
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  from nuitka.Constants import isCompileTimeConstantValue
10
9
  from nuitka.Options import isStandaloneMode, shallMakeModule
11
10
  from nuitka.Tracing import inclusion_logger
@@ -28,9 +28,11 @@ from .NodeBases import SideEffectsFromChildrenMixin
28
28
 
29
29
 
30
30
  class ExpressionPkgutilGetDataCall(
31
- ExpressionBytesShapeExactMixin
32
- if str is not bytes
33
- else ExpressionStrShapeExactMixin,
31
+ (
32
+ ExpressionBytesShapeExactMixin
33
+ if str is not bytes
34
+ else ExpressionStrShapeExactMixin
35
+ ),
34
36
  SideEffectsFromChildrenMixin,
35
37
  ExpressionPkgutilGetDataCallBase,
36
38
  ):
@@ -45,9 +47,11 @@ class ExpressionPkgutilGetDataCall(
45
47
 
46
48
 
47
49
  class ExpressionPkgResourcesResourceStringCall(
48
- ExpressionBytesShapeExactMixin
49
- if str is not bytes
50
- else ExpressionStrShapeExactMixin,
50
+ (
51
+ ExpressionBytesShapeExactMixin
52
+ if str is not bytes
53
+ else ExpressionStrShapeExactMixin
54
+ ),
51
55
  SideEffectsFromChildrenMixin,
52
56
  ExpressionPkgResourcesResourceStringCallBase,
53
57
  ):