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
@@ -26,7 +26,11 @@ import os
26
26
 
27
27
  from nuitka.containers.OrderedSets import OrderedSet
28
28
  from nuitka.Errors import NuitkaForbiddenDLLEncounter
29
- from nuitka.importing.Importing import getPythonUnpackedSearchPath
29
+ from nuitka.importing.Importing import (
30
+ getPythonUnpackedSearchPath,
31
+ locateModule,
32
+ )
33
+ from nuitka.importing.StandardLibrary import isStandardLibraryPath
30
34
  from nuitka.Options import (
31
35
  isShowProgress,
32
36
  shallNotStoreDependsExeCachedResults,
@@ -227,6 +231,22 @@ def copyDllsUsed(dist_dir, standalone_entry_points):
227
231
  )
228
232
 
229
233
 
234
+ def _reduceToPythonPath(used_dlls):
235
+ inside_paths = getPythonUnpackedSearchPath()
236
+
237
+ def decideInside(dll_filename):
238
+ return any(
239
+ isFilenameBelowPath(path=inside_path, filename=dll_filename)
240
+ for inside_path in inside_paths
241
+ )
242
+
243
+ used_dlls = set(
244
+ dll_filename for dll_filename in used_dlls if decideInside(dll_filename)
245
+ )
246
+
247
+ return used_dlls
248
+
249
+
230
250
  def _detectUsedDLLs(standalone_entry_point, source_dir):
231
251
  binary_filename = standalone_entry_point.source_path
232
252
  try:
@@ -244,26 +264,27 @@ def _detectUsedDLLs(standalone_entry_point, source_dir):
244
264
  else:
245
265
  # Plugins generally decide if they allow dependencies from the outside
246
266
  # based on the package name.
247
- allow_outside_dependencies = Plugins.decideAllowOutsideDependencies(
248
- standalone_entry_point.package_name
249
- )
250
267
 
251
- # TODO: Command line option maybe
252
- if allow_outside_dependencies is None:
253
- allow_outside_dependencies = True
254
-
255
- if not allow_outside_dependencies:
256
- inside_paths = getPythonUnpackedSearchPath()
268
+ if standalone_entry_point.module_name is not None and used_dlls:
269
+ module_name, module_filename, _kind, finding = locateModule(
270
+ standalone_entry_point.module_name, parent_package=None, level=0
271
+ )
257
272
 
258
- def decideInside(dll_filename):
259
- return any(
260
- isFilenameBelowPath(path=inside_path, filename=dll_filename)
261
- for inside_path in inside_paths
273
+ # Make sure we are not surprised here.
274
+ assert (
275
+ module_name == standalone_entry_point.module_name
276
+ ), standalone_entry_point.module_name
277
+ assert finding == "absolute", standalone_entry_point.module_name
278
+
279
+ if isStandardLibraryPath(module_filename):
280
+ allow_outside_dependencies = True
281
+ else:
282
+ allow_outside_dependencies = Plugins.decideAllowOutsideDependencies(
283
+ standalone_entry_point.module_name
262
284
  )
263
285
 
264
- used_dlls = set(
265
- dll_filename for dll_filename in used_dlls if decideInside(dll_filename)
266
- )
286
+ if allow_outside_dependencies is False:
287
+ used_dlls = _reduceToPythonPath(used_dlls)
267
288
 
268
289
  # Allow plugins can prevent inclusion, this may discard things from used_dlls.
269
290
  removed_dlls = Plugins.removeDllDependencies(
@@ -293,6 +314,7 @@ def _detectUsedDLLs(standalone_entry_point, source_dir):
293
314
  logger=inclusion_logger,
294
315
  source_path=used_dll,
295
316
  dest_path=dest_path,
317
+ module_name=standalone_entry_point.module_name,
296
318
  package_name=standalone_entry_point.package_name,
297
319
  reason="Used by '%s'" % standalone_entry_point.dest_path,
298
320
  )
@@ -37,12 +37,11 @@ it's from the standard library, one can abuse the attribute ``__file__`` of the
37
37
 
38
38
 
39
39
  import collections
40
- import hashlib
41
40
  import os
42
41
  import sys
43
42
  import zipfile
44
43
 
45
- from nuitka import Options, SourceCodeReferences
44
+ from nuitka import SourceCodeReferences
46
45
  from nuitka.__past__ import iter_modules
47
46
  from nuitka.containers.Namedtuples import makeNamedtupleClass
48
47
  from nuitka.containers.OrderedSets import OrderedSet
@@ -54,7 +53,9 @@ from nuitka.Tracing import my_print, recursion_logger
54
53
  from nuitka.tree.ReformulationMultidist import locateMultidistModule
55
54
  from nuitka.utils.AppDirs import getCacheDir
56
55
  from nuitka.utils.FileOperations import listDir, removeDirectory
56
+ from nuitka.utils.Hashing import getFileContentsHash
57
57
  from nuitka.utils.Importing import (
58
+ builtin_module_names,
58
59
  getModuleFilenameSuffixes,
59
60
  getSharedLibrarySuffixes,
60
61
  isBuiltinModuleName,
@@ -68,7 +69,43 @@ from nuitka.utils.Utils import isMacOS, isWin32OrPosixWindows
68
69
  from .IgnoreListing import isIgnoreListedNotExistingModule
69
70
  from .PreloadedPackages import getPreloadedPackagePath, isPreloadedPackagePath
70
71
 
71
- _debug_module_finding = Options.shallExplainImports()
72
+ # Debug traces, enabled via --explain-imports
73
+ _debug_module_finding = None
74
+
75
+ # Preference as expressed via --prefer-source-code
76
+ _prefer_source_code_over_extension_modules = None
77
+
78
+
79
+ def setupImportingFromOptions():
80
+ """Set up the importing layer from giving options."""
81
+
82
+ # Should only be used inside of here.
83
+ from nuitka import Options
84
+
85
+ # singleton, pylint: disable=global-statement
86
+ global _debug_module_finding
87
+ _debug_module_finding = Options.shallExplainImports()
88
+
89
+ global _prefer_source_code_over_extension_modules
90
+ _prefer_source_code_over_extension_modules = (
91
+ Options.shallPreferSourceCodeOverExtensionModules()
92
+ )
93
+
94
+ # Lets try and have this complete, please report failures.
95
+ if Options.is_debug and not isNuitkaPython():
96
+ _checkRaisingBuiltinComplete()
97
+
98
+ main_filenames = Options.getMainEntryPointFilenames()
99
+ for filename in main_filenames:
100
+ # Inform the importing layer about the main script directory, so it can use
101
+ # it when attempting to follow imports.
102
+ addMainScriptDirectory(main_dir=os.path.dirname(os.path.abspath(filename)))
103
+
104
+
105
+ def _checkRaisingBuiltinComplete():
106
+ for module_name in builtin_module_names:
107
+ assert module_name in _stdlib_module_raises, module_name
108
+
72
109
 
73
110
  warned_about = set()
74
111
 
@@ -186,7 +223,7 @@ def isIgnoreListedImportMaker(source_ref):
186
223
  return StandardLibrary.isStandardLibraryPath(source_ref.getFilename())
187
224
 
188
225
 
189
- def warnAbout(importing, module_name, level, source_ref):
226
+ def warnAboutNotFoundImport(importing, module_name, level, source_ref):
190
227
  # This probably should not be dealt with here
191
228
  if module_name == "":
192
229
  return
@@ -279,6 +316,15 @@ def findModule(module_name, parent_package, level):
279
316
  else:
280
317
  return None, None, None, "not-found"
281
318
 
319
+ if level == 1 and not module_name:
320
+ # Not actually allowed, but we only catch that at run-time.
321
+ if parent_package is None:
322
+ return None, None, None, "not-found"
323
+
324
+ module_name = parent_package
325
+ parent_package = None
326
+ level = 0
327
+
282
328
  # Try relative imports first if we have a parent package.
283
329
  if level != 0 and parent_package is not None:
284
330
  if module_name:
@@ -313,37 +359,11 @@ def findModule(module_name, parent_package, level):
313
359
 
314
360
  return full_name.getPackageName(), module_filename, module_kind, "relative"
315
361
 
316
- if level < 1 and module_name != "":
362
+ if level < 1 and module_name:
317
363
  module_name = normalizePackageName(module_name)
318
364
 
319
365
  package_name = module_name.getPackageName()
320
366
 
321
- # Built-in module names must not be searched any further.
322
- if module_name in sys.builtin_module_names:
323
- if _debug_module_finding:
324
- my_print(
325
- "findModule: Absolute imported module '%s' in as built-in':"
326
- % (module_name,)
327
- )
328
- return package_name, None, None, "built-in"
329
-
330
- # Frozen module names are similar to built-in, but there is no list of
331
- # them, therefore check loader name. Not useful at this time
332
- # to make a difference with built-in.
333
- if python_version >= 0x300 and module_name in sys.modules:
334
- loader = getattr(sys.modules[module_name], "__loader__", None)
335
-
336
- if (
337
- loader is not None
338
- and getattr(loader, "__name__", "") == "FrozenImporter"
339
- ):
340
- if _debug_module_finding:
341
- my_print(
342
- "findModule: Absolute imported module '%s' in as frozen':"
343
- % (module_name,)
344
- )
345
- return package_name, None, None, "built-in"
346
-
347
367
  preloaded_path = getPreloadedPackagePath(module_name)
348
368
 
349
369
  if preloaded_path is not None:
@@ -393,10 +413,7 @@ def _reportCandidates(package_name, module_name, candidate, candidates):
393
413
  else module_name
394
414
  )
395
415
 
396
- if (
397
- candidate.priority == 1
398
- and Options.shallPreferSourceCodeOverExtensionModules() is None
399
- ):
416
+ if candidate.priority == 1 and _prefer_source_code_over_extension_modules is None:
400
417
  for c in candidates:
401
418
  # Don't compare to itself and don't consider unused bytecode a problem.
402
419
  if c is candidate or c.priority == 3:
@@ -454,7 +471,7 @@ def _findModuleInPath2(package_name, module_name, search_path):
454
471
  # Higher values are lower priority.
455
472
  priority_map = {
456
473
  "PY_COMPILED": 3,
457
- "PY_SOURCE": 0 if Options.shallPreferSourceCodeOverExtensionModules() else 2,
474
+ "PY_SOURCE": 0 if _prefer_source_code_over_extension_modules else 2,
458
475
  "C_EXTENSION": 1,
459
476
  }
460
477
 
@@ -582,26 +599,26 @@ def _unpackPathElement(path_entry):
582
599
  if not path_entry:
583
600
  return "." # empty means current directory
584
601
 
585
- if os.path.isfile(path_entry) and path_entry.lower().endswith(".egg"):
586
- if path_entry not in _egg_files:
587
- with open(path_entry, "rb") as f:
588
- checksum = hashlib.md5(f.read()).hexdigest()
602
+ if os.path.isfile(path_entry):
603
+ if path_entry.lower().endswith((".egg", ".zip")):
604
+ if path_entry not in _egg_files:
605
+ checksum = getFileContentsHash(path_entry)
589
606
 
590
- target_dir = os.path.join(getCacheDir(), "egg-content", checksum)
607
+ target_dir = os.path.join(getCacheDir(), "egg-content", checksum)
591
608
 
592
- if not os.path.exists(target_dir):
593
- try:
594
- # Not all Python versions allow using with here, pylint: disable=consider-using-with
595
- zip_ref = zipfile.ZipFile(path_entry, "r")
596
- zip_ref.extractall(target_dir)
597
- zip_ref.close()
598
- except BaseException:
599
- removeDirectory(target_dir, ignore_errors=True)
600
- raise
609
+ if not os.path.exists(target_dir):
610
+ try:
611
+ # Not all Python versions allow using with here, pylint: disable=consider-using-with
612
+ zip_ref = zipfile.ZipFile(path_entry, "r")
613
+ zip_ref.extractall(target_dir)
614
+ zip_ref.close()
615
+ except BaseException:
616
+ removeDirectory(target_dir, ignore_errors=True)
617
+ raise
601
618
 
602
- _egg_files[path_entry] = target_dir
619
+ _egg_files[path_entry] = target_dir
603
620
 
604
- return _egg_files[path_entry]
621
+ return _egg_files[path_entry]
605
622
 
606
623
  return path_entry
607
624
 
@@ -614,7 +631,8 @@ def getPythonUnpackedSearchPath():
614
631
 
615
632
 
616
633
  def getPackageSearchPath(package_name):
617
- assert _main_paths
634
+ if not _main_paths:
635
+ return None
618
636
 
619
637
  if package_name is None:
620
638
  result = (
@@ -632,8 +650,9 @@ def getPackageSearchPath(package_name):
632
650
 
633
651
  if isPackageDir(package_dir):
634
652
  result.append(package_dir)
635
- # Hack for "uniconverter". TODO: Move this to plug-in decision. This
653
+ # Hack for "uniconvertor". TODO: Move this to plug-in decision. This
636
654
  # fails the above test, but at run time should be a package.
655
+ # spell-checker: ignore uniconvertor
637
656
  elif package_name == "uniconvertor.app.modules":
638
657
  result.append(package_dir)
639
658
 
@@ -678,7 +697,7 @@ def _findModuleInPath(module_name):
678
697
 
679
698
  # Free pass for built-in modules, they need not exist.
680
699
  if package_name is None and isBuiltinModuleName(module_name):
681
- return None
700
+ return None, "built-in"
682
701
 
683
702
  search_path = getPackageSearchPath(package_name)
684
703
 
@@ -698,7 +717,7 @@ def _findModuleInPath(module_name):
698
717
  module_name if package_name is None else package_name + "." + module_name,
699
718
  )
700
719
 
701
- return None
720
+ return None, None
702
721
 
703
722
  if _debug_module_finding:
704
723
  my_print("_findModuleInPath: _findModuleInPath2 gave", module_filename)
@@ -737,6 +756,8 @@ def _findModule(module_name):
737
756
  module_search_cache[key] = ImportError
738
757
  raise
739
758
 
759
+ # assert len(module_search_cache[key]) == 2, (module_name, module_search_cache[key])
760
+
740
761
  return module_search_cache[key]
741
762
 
742
763
 
@@ -747,9 +768,10 @@ def locateModule(module_name, parent_package, level):
747
768
  as with "__import__" built-in.
748
769
 
749
770
  Returns:
750
- Returns a triple of module name the module has considering
771
+ Returns a tuple of module name the module has considering
751
772
  package containing it, and filename of it which can be a
752
- directory for packages, and the location method used.
773
+ directory for packages, the module kind, and the finding
774
+ kind.
753
775
  """
754
776
 
755
777
  if module_name.isMultidistModuleName():
@@ -762,10 +784,7 @@ def locateModule(module_name, parent_package, level):
762
784
  )
763
785
 
764
786
  # Allowing ourselves to be lazy.
765
- if module_filename is None:
766
- module_kind = None
767
- else:
768
- assert module_kind is not None, module_filename
787
+ assert module_kind is not None or module_filename is None, module_name
769
788
 
770
789
  assert module_package is None or (
771
790
  type(module_package) is ModuleName and module_package != ""
@@ -872,3 +891,117 @@ def decideModuleSourceRef(filename, module_name, is_main, is_fake, logger):
872
891
  source_ref,
873
892
  source_filename,
874
893
  )
894
+
895
+
896
+ # spell-checker: ignore _posixsubprocess,pyexpat,xxsubtype
897
+
898
+ _stdlib_module_raises = {
899
+ "__builtin__": False,
900
+ "_abc": False,
901
+ "_ast": False,
902
+ "_bisect": False,
903
+ "_blake2": False,
904
+ "_bytesio": False,
905
+ "_codecs": False,
906
+ "_codecs_cn": False,
907
+ "_codecs_hk": False,
908
+ "_codecs_iso2022": False,
909
+ "_codecs_jp": False,
910
+ "_codecs_kr": False,
911
+ "_codecs_tw": False,
912
+ "_collections": False,
913
+ "_contextvars": False,
914
+ "_csv": False,
915
+ "_datetime": False,
916
+ "_elementtree": False,
917
+ "_fileio": False,
918
+ "_functools": False,
919
+ "_heapq": False,
920
+ "_hotshot": False,
921
+ "_imp": False,
922
+ "_io": False,
923
+ "_json": False,
924
+ "_locale": False,
925
+ "_lsprof": False,
926
+ "_md5": False,
927
+ "_multibytecodec": False,
928
+ "_opcode": False,
929
+ "_operator": False,
930
+ "_peg_parser": False,
931
+ "_pickle": False,
932
+ "_posixsubprocess": False,
933
+ "_random": False,
934
+ "_subprocess": False,
935
+ "_sha": False, # TODO: Not entirely clear if that's true
936
+ "_sha1": False,
937
+ "_sha256": False,
938
+ "_sha3": False,
939
+ "_sha512": False,
940
+ "_signal": False,
941
+ "_socket": False,
942
+ "_sre": False,
943
+ "_stat": False,
944
+ "_statistics": False,
945
+ "_string": False,
946
+ "_struct": False,
947
+ "_symtable": False,
948
+ "_thread": False,
949
+ "_tracemalloc": False,
950
+ "_tokenize": False,
951
+ "_typing": False,
952
+ "_warnings": False,
953
+ "_weakref": False,
954
+ "_winapi": False,
955
+ "_winreg": False,
956
+ "_xxsubinterpreters": False,
957
+ "array": False,
958
+ "atexit": False,
959
+ "audioop": False,
960
+ "binascii": False,
961
+ "builtins": False,
962
+ "cmath": False,
963
+ "cStringIO": False,
964
+ "cPickle": False,
965
+ "datetime": False,
966
+ "errno": False,
967
+ "exceptions": False,
968
+ "faulthandler": False,
969
+ "fcntl": False,
970
+ "future_builtins": False,
971
+ "gc": False,
972
+ "grp": False,
973
+ "itertools": False,
974
+ "imageop": False,
975
+ "imp": False,
976
+ "operator": False,
977
+ "marshal": False,
978
+ "math": False,
979
+ "mmap": False,
980
+ "msvcrt": False,
981
+ "nt": False,
982
+ "parser": False,
983
+ "posix": False,
984
+ "pwd": False,
985
+ "pyexpat": False,
986
+ "select": False,
987
+ "signal": False,
988
+ "strop": False,
989
+ "spwd": False,
990
+ "sys": False,
991
+ "syslog": False,
992
+ "time": False,
993
+ "thread": False,
994
+ "unicodedata": False,
995
+ "winreg": False,
996
+ "xxsubtype": False,
997
+ "zipimport": False,
998
+ "zlib": False,
999
+ "_ssl": True,
1000
+ }
1001
+
1002
+
1003
+ def isNonRaisingBuiltinModule(module_name):
1004
+ assert isBuiltinModuleName(module_name), module_name
1005
+
1006
+ # Return None, if we don't know.
1007
+ return _stdlib_module_raises.get(module_name)
@@ -27,6 +27,7 @@ import sys
27
27
 
28
28
  from nuitka.Tracing import recursion_logger
29
29
  from nuitka.utils.FileOperations import getFileContentByLine, listDir
30
+ from nuitka.utils.ModuleNames import ModuleName
30
31
 
31
32
 
32
33
  def getLoadedPackages():
@@ -154,7 +155,7 @@ def setPthImportedPackages(value):
154
155
  # We need to set this from the outside, pylint: disable=global-statement
155
156
  global pth_imported_packages
156
157
 
157
- pth_imported_packages = value
158
+ pth_imported_packages = tuple(ModuleName(module_name) for module_name in value)
158
159
 
159
160
 
160
161
  def getPthImportedPackages():