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
nuitka/Options.py CHANGED
@@ -35,7 +35,8 @@ import sys
35
35
  from nuitka import Progress, Tracing
36
36
  from nuitka.containers.OrderedDicts import OrderedDict
37
37
  from nuitka.containers.OrderedSets import OrderedSet
38
- from nuitka.OptionParsing import parseOptions
38
+ from nuitka.importing.StandardLibrary import isStandardLibraryPath
39
+ from nuitka.OptionParsing import parseOptions, runSpecialCommandsFromOptions
39
40
  from nuitka.PythonFlavors import (
40
41
  getPythonFlavorName,
41
42
  isAnacondaPython,
@@ -271,7 +272,7 @@ def parseArgs():
271
272
  Tracing.general.sysexit(
272
273
  """\
273
274
  Error, the Python from Windows app store is not supported.""",
274
- mnemonic="unsupported-python",
275
+ mnemonic="unsupported-windows-app-store-python",
275
276
  )
276
277
 
277
278
  is_nuitka_run, options, positional_args, extra_args = parseOptions(
@@ -310,6 +311,9 @@ Error, the Python from Windows app store is not supported.""",
310
311
  else:
311
312
  return arg
312
313
 
314
+ # This will not return if a non-compiling command is given.
315
+ runSpecialCommandsFromOptions(options)
316
+
313
317
  if not options.version:
314
318
  Tracing.options_logger.info(
315
319
  "Used command line options: %s"
@@ -690,6 +694,22 @@ it before using it: '%s' (from --output-filename='%s')."""
690
694
  % pattern
691
695
  )
692
696
 
697
+ for directory_name in getShallFollowExtra():
698
+ if not os.path.isdir(directory_name):
699
+ Tracing.options_logger.sysexit(
700
+ "Error, value '%s' given to '--include-plugin-directory' must be a directory name."
701
+ % directory_name
702
+ )
703
+
704
+ if isStandardLibraryPath(directory_name):
705
+ Tracing.options_logger.sysexit(
706
+ """\
707
+ Error, directory '%s' given to '--include-plugin-directory' must not be a \
708
+ standard library path. Use '--include-module' or '--include-package' \
709
+ options instead."""
710
+ % pattern
711
+ )
712
+
693
713
  if options.static_libpython == "yes" and getSystemStaticLibPythonPath() is None:
694
714
  Tracing.options_logger.sysexit(
695
715
  "Error, static libpython is not found or not supported for this Python installation."
@@ -752,6 +772,20 @@ def commentArgs():
752
772
  """
753
773
  # A ton of cases to consider, pylint: disable=too-many-branches,too-many-statements
754
774
 
775
+ # Check files to exist or be suitable first before giving other warnings.
776
+ for filename in getMainEntryPointFilenames():
777
+ if not os.path.exists(filename):
778
+ Tracing.general.sysexit("Error, file '%s' is not found." % filename)
779
+
780
+ if (
781
+ shallMakeModule()
782
+ and os.path.normcase(os.path.basename(filename)) == "__init__.py"
783
+ ):
784
+ Tracing.general.sysexit(
785
+ """\
786
+ Error, to compile a package, specify its directory but, not the '__init__.py'."""
787
+ )
788
+
755
789
  # Inform the user about potential issues with the running version. e.g. unsupported
756
790
  # version.
757
791
  if python_version_str not in getSupportedPythonVersions():
@@ -1007,19 +1041,6 @@ notarization capable signature, the default identify 'ad-hoc' is not going \
1007
1041
  to work."""
1008
1042
  )
1009
1043
 
1010
- for filename in getMainEntryPointFilenames():
1011
- if not os.path.exists(filename):
1012
- Tracing.general.sysexit("Error, file '%s' is not found." % filename)
1013
-
1014
- if (
1015
- shallMakeModule()
1016
- and os.path.normcase(os.path.basename(filename)) == "__init__.py"
1017
- ):
1018
- Tracing.general.sysexit(
1019
- """\
1020
- Error, to compile a package, specify its directory but, not the '__init__.py'."""
1021
- )
1022
-
1023
1044
  if (
1024
1045
  isWin32Windows()
1025
1046
  and 0x340 <= python_version < 0x380
@@ -1133,7 +1154,7 @@ def getShallFollowInNoCase():
1133
1154
 
1134
1155
 
1135
1156
  def getShallFollowModules():
1136
- """*list*, items of ``--follow-import-to=``"""
1157
+ """*list*, items of ``--follow-import-to=`` amended with what ``--include-module`` and ``--include-package`` got"""
1137
1158
  return sum(
1138
1159
  [
1139
1160
  _splitShellPattern(x)
@@ -1507,6 +1528,11 @@ def shallDisableBytecodeCacheUsage():
1507
1528
  return shallDisableCacheUsage("bytecode")
1508
1529
 
1509
1530
 
1531
+ def shallDisableCompressionCacheUsage():
1532
+ """:returns: bool derived from ``--disable-cache=compression``"""
1533
+ return shallDisableCacheUsage("compression")
1534
+
1535
+
1510
1536
  def shallDisableConsoleWindow():
1511
1537
  """:returns: None (not given), False, or True derived from ``--disable-console or ``--enable-console``"""
1512
1538
  return options.disable_console
@@ -1695,6 +1721,11 @@ def shallNotCompressOnefile():
1695
1721
  return options.onefile_no_compression
1696
1722
 
1697
1723
 
1724
+ def shallOnefileAsArchive():
1725
+ """*bool* = ``--onefile-as-archive``"""
1726
+ return options.onefile_as_archive
1727
+
1728
+
1698
1729
  def getIconPaths():
1699
1730
  """*list of str*, values of ``--windows-icon-from-ico`` and ``--linux-onefile-icon``"""
1700
1731
 
nuitka/Progress.py CHANGED
@@ -35,6 +35,7 @@ from nuitka.utils.Utils import isWin32Windows
35
35
  # Late import and optional to be there.
36
36
  use_progress_bar = False
37
37
  tqdm = None
38
+ colorama = None
38
39
 
39
40
 
40
41
  class NuitkaProgressBar(object):
@@ -108,7 +109,7 @@ def _getTqdmModule():
108
109
  elif tqdm is False:
109
110
  return None
110
111
  else:
111
- tqdm = importFromInlineCopy("tqdm", must_exist=False)
112
+ tqdm = importFromInlineCopy("tqdm", must_exist=False, delete_module=True)
112
113
 
113
114
  if tqdm is None:
114
115
  try:
@@ -135,12 +136,17 @@ def _getTqdmModule():
135
136
 
136
137
  def enableProgressBar():
137
138
  global use_progress_bar # singleton, pylint: disable=global-statement
139
+ global colorama # singleton, pylint: disable=global-statement
138
140
 
139
141
  if _getTqdmModule() is not None:
140
142
  use_progress_bar = True
141
143
 
142
144
  if isWin32Windows():
143
- colorama = importFromInlineCopy("colorama", must_exist=True)
145
+ if colorama is None:
146
+ colorama = importFromInlineCopy(
147
+ "colorama", must_exist=True, delete_module=True
148
+ )
149
+
144
150
  colorama.init()
145
151
 
146
152
 
@@ -202,3 +208,27 @@ def wrapWithProgressBar(iterable, stage, unit):
202
208
  Tracing.progress = result
203
209
 
204
210
  return result
211
+
212
+
213
+ @contextmanager
214
+ def withNuitkaDownloadProgressBar(*args, **kwargs):
215
+ if not use_progress_bar or _getTqdmModule() is None:
216
+ yield
217
+ else:
218
+
219
+ class NuitkaDownloadProgressBar(tqdm):
220
+ # spell-checker: ignore bsize, tsize
221
+ def onProgress(self, b=1, bsize=1, tsize=None):
222
+ if tsize is not None:
223
+ self.total = tsize
224
+ self.update(b * bsize - self.n)
225
+
226
+ kwargs.update(
227
+ disable=None,
228
+ leave=False,
229
+ dynamic_ncols=True,
230
+ bar_format="{desc} {percentage:3.1f}%|{bar:25}| {n_fmt}/{total_fmt}{postfix}",
231
+ )
232
+
233
+ with NuitkaDownloadProgressBar(*args, **kwargs) as progress_bar:
234
+ yield progress_bar.onProgress
nuitka/PythonFlavors.py CHANGED
@@ -32,7 +32,6 @@ from nuitka.utils.FileOperations import (
32
32
  isFilenameBelowPath,
33
33
  isFilenameSameAsOrBelowPath,
34
34
  )
35
- from nuitka.utils.InstalledPythons import getInstalledPythonRegistryPaths
36
35
  from nuitka.utils.Utils import (
37
36
  isAndroidBasedLinux,
38
37
  isFedoraBasedLinux,
@@ -44,6 +43,7 @@ from nuitka.utils.Utils import (
44
43
  )
45
44
 
46
45
  from .PythonVersions import (
46
+ getInstalledPythonRegistryPaths,
47
47
  getRunningPythonDLLPath,
48
48
  getSystemPrefixPath,
49
49
  isStaticallyLinkedPython,
nuitka/PythonVersions.py CHANGED
@@ -417,3 +417,64 @@ def isPythonValidCLongValue(value):
417
417
 
418
418
  def isPythonValidCLongLongValue(value):
419
419
  return _min_signed_longlong <= value <= _max_signed_longlong
420
+
421
+
422
+ def getInstalledPythonRegistryPaths(version):
423
+ """Yield all Pythons as found in the Windows registry."""
424
+ # Windows only code,
425
+ # pylint: disable=I0021,import-error,redefined-builtin
426
+ from nuitka.__past__ import WindowsError
427
+
428
+ if str is bytes:
429
+ import _winreg as winreg # pylint: disable=I0021,import-error,no-name-in-module
430
+ else:
431
+ import winreg # pylint: disable=I0021,import-error,no-name-in-module
432
+
433
+ for hkey_branch in (winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER):
434
+ for arch_key in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
435
+ for suffix in "", "-32", "-arm64":
436
+ try:
437
+ key = winreg.OpenKey(
438
+ hkey_branch,
439
+ r"SOFTWARE\Python\PythonCore\%s%s\InstallPath"
440
+ % (version, suffix),
441
+ 0,
442
+ winreg.KEY_READ | arch_key,
443
+ )
444
+
445
+ install_dir = os.path.normpath(winreg.QueryValue(key, ""))
446
+ except WindowsError:
447
+ pass
448
+ else:
449
+ candidate = os.path.normpath(
450
+ os.path.join(install_dir, "python.exe")
451
+ )
452
+
453
+ if os.path.exists(candidate):
454
+ yield candidate
455
+
456
+
457
+ def getTkInterVersion():
458
+ """Get the tk-inter version or None if not installed."""
459
+ try:
460
+ if str is bytes:
461
+ return str(__import__("TkInter").TkVersion)
462
+ else:
463
+ return str(__import__("tkinter").TkVersion)
464
+ except ImportError:
465
+ # This should lead to no action taken ideally.
466
+ return None
467
+
468
+
469
+ def getModuleLinkerLibs():
470
+ """Get static link libraries needed."""
471
+ try:
472
+ import sysconfig
473
+ except ImportError:
474
+ return []
475
+ else:
476
+ # static link libraries might be there, spell-checker: ignore modlibs
477
+ result = sysconfig.get_config_var("MODLIBS") or ""
478
+ result = [entry[2:] for entry in result.split() if entry.startswith("-l:")]
479
+
480
+ return result
nuitka/Tracing.py CHANGED
@@ -271,6 +271,21 @@ class OurLogger(object):
271
271
  # For overload, pylint: disable=no-self-use
272
272
  my_print(message, **kwargs)
273
273
 
274
+ @staticmethod
275
+ def _warnMnemonic(mnemonic, style, output_function):
276
+ if mnemonic.startswith("http"):
277
+ url = mnemonic
278
+ extra_prefix = ""
279
+ else:
280
+ url = "https://nuitka.net/info/%s.html" % mnemonic
281
+ extra_prefix = "Complex topic! "
282
+
283
+ output_function(
284
+ """ %sMore information can be found at %s%s"""
285
+ % (extra_prefix, _getEnableStyleCode("link"), url),
286
+ style=style,
287
+ )
288
+
274
289
  def warning(self, message, style="red", mnemonic=None):
275
290
  if mnemonic is not None:
276
291
  from .Options import shallDisplayWarningMnemonic
@@ -303,11 +318,7 @@ class OurLogger(object):
303
318
  self.my_print(formatted_message, style=style, file=sys.stderr)
304
319
 
305
320
  if mnemonic is not None:
306
- self.warning(
307
- """ Complex topic! More information can be found at %shttps://nuitka.net/info/%s.html"""
308
- % (_getEnableStyleCode("link"), mnemonic),
309
- style=style,
310
- )
321
+ self._warnMnemonic(mnemonic, style=style, output_function=self.warning)
311
322
 
312
323
  def sysexit(
313
324
  self, message="", style=None, mnemonic=None, exit_code=1, reporting=False
@@ -334,11 +345,7 @@ class OurLogger(object):
334
345
  )
335
346
 
336
347
  if mnemonic is not None:
337
- self.warning(
338
- """ Complex topic! More information can be found at %shttps://nuitka.net/info/%s.html"""
339
- % (_getEnableStyleCode("link"), mnemonic),
340
- style=style,
341
- )
348
+ self._warnMnemonic(mnemonic, style=style, output_function=self.warning)
342
349
 
343
350
  if reporting:
344
351
  raise ReportingSystemExit(exit_code=exit_code, exit_message=message)
@@ -354,7 +361,7 @@ class OurLogger(object):
354
361
  def isQuiet(self):
355
362
  return is_quiet or self.is_quiet
356
363
 
357
- def info(self, message, style=None):
364
+ def info(self, message, style=None, mnemonic=None):
358
365
  if not self.isQuiet():
359
366
  if self.name:
360
367
  message = "%s:INFO: %s" % (self.name, message)
@@ -362,6 +369,9 @@ class OurLogger(object):
362
369
  style = style or self.base_style
363
370
  self.my_print(message, style=style)
364
371
 
372
+ if mnemonic is not None:
373
+ self._warnMnemonic(mnemonic, style=style, output_function=self.info)
374
+
365
375
 
366
376
  class FileLogger(OurLogger):
367
377
  def __init__(self, name, quiet=False, base_style=None, file_handle=None):
@@ -382,13 +392,16 @@ class FileLogger(OurLogger):
382
392
  def isFileOutput(self):
383
393
  return self.file_handle is not None
384
394
 
385
- def info(self, message, style=None):
395
+ def info(self, message, style=None, mnemonic=None):
386
396
  if not self.isQuiet() or self.file_handle:
387
397
  message = "%s:INFO: %s" % (self.name, message)
388
398
 
389
399
  style = style or self.base_style
390
400
  self.my_print(message, style=style)
391
401
 
402
+ if mnemonic is not None:
403
+ self._warnMnemonic(mnemonic, style=style, output_function=self.my_print)
404
+
392
405
  def debug(self, message, style=None):
393
406
  if self.file_handle:
394
407
  message = "%s:DEBUG: %s" % (self.name, message)
nuitka/TreeXML.py CHANGED
@@ -71,13 +71,13 @@ try:
71
71
 
72
72
  Element = xml.etree.ElementTree.Element
73
73
 
74
- def xml_tostring(tree, indent=True):
74
+ def xml_tostring(tree, indent=True, encoding=None):
75
75
  if indent:
76
76
  _indent(tree)
77
77
  elif not indent:
78
78
  _dedent(tree)
79
79
 
80
- return xml_module.tostring(tree)
80
+ return xml_module.tostring(tree, encoding=encoding)
81
81
 
82
82
  except ImportError:
83
83
  xml_module = None
@@ -94,12 +94,12 @@ except ImportError:
94
94
  # xml_writer = None
95
95
 
96
96
 
97
- def toBytes(tree, indent=True):
98
- return xml_tostring(tree, indent=indent)
97
+ def toBytes(tree, indent=True, encoding=None):
98
+ return xml_tostring(tree, indent=indent, encoding=encoding)
99
99
 
100
100
 
101
101
  def toString(tree):
102
- result = toBytes(tree)
102
+ result = toBytes(tree, encoding="utf8")
103
103
 
104
104
  if str is not bytes:
105
105
  result = result.decode("utf8")
nuitka/Variables.py CHANGED
@@ -25,7 +25,7 @@ module variable references.
25
25
 
26
26
  from abc import abstractmethod
27
27
 
28
- from nuitka.__past__ import getMetaClassBase, iterItems
28
+ from nuitka.__past__ import iterItems
29
29
  from nuitka.nodes.shapes.BuiltinTypeShapes import tshape_dict
30
30
  from nuitka.nodes.shapes.StandardShapes import tshape_unknown
31
31
  from nuitka.utils import Utils
@@ -34,11 +34,12 @@ from nuitka.utils.InstanceCounters import (
34
34
  counted_init,
35
35
  isCountingInstances,
36
36
  )
37
+ from nuitka.utils.SlotMetaClasses import getMetaClassBase
37
38
 
38
39
  complete = False
39
40
 
40
41
 
41
- class Variable(getMetaClassBase("Variable")):
42
+ class Variable(getMetaClassBase("Variable", require_slots=True)):
42
43
  # We will need all of these attributes, since we track the global
43
44
  # state and cache some decisions as attributes. TODO: But in some
44
45
  # cases, part of the these might be moved to the outside.
@@ -390,21 +391,26 @@ class ModuleVariable(Variable):
390
391
 
391
392
 
392
393
  class TempVariable(Variable):
393
- __slots__ = ()
394
+ __slots__ = ("variable_type",)
394
395
 
395
- def __init__(self, owner, variable_name):
396
+ def __init__(self, owner, variable_name, variable_type):
396
397
  Variable.__init__(self, owner=owner, variable_name=variable_name)
397
398
 
398
- def getDescription(self):
399
- return "temp variable '%s'" % self.variable_name
399
+ # TODO: Push this later down to Variable itself.
400
+ self.variable_type = variable_type
400
401
 
401
402
  @staticmethod
402
403
  def isTempVariable():
403
404
  return True
404
405
 
405
- @staticmethod
406
- def getVariableType():
407
- return "object"
406
+ def getVariableType(self):
407
+ return self.variable_type
408
+
409
+ def isTempVariableBool(self):
410
+ return self.variable_type == "bool"
411
+
412
+ def getDescription(self):
413
+ return "temp variable '%s'" % self.variable_name
408
414
 
409
415
  def initVariable(self, trace_collection):
410
416
  """Initialize variable in trace collection state."""
@@ -417,21 +423,6 @@ class TempVariable(Variable):
417
423
  # lost to outside star imports or exec/eval uses.
418
424
 
419
425
 
420
- class TempVariableBool(TempVariable):
421
- __slots__ = ()
422
-
423
- def getDescription(self):
424
- return "temp bool variable '%s'" % self.variable_name
425
-
426
- @staticmethod
427
- def isTempVariableBool():
428
- return True
429
-
430
- @staticmethod
431
- def getVariableType():
432
- return "bool"
433
-
434
-
435
426
  class LocalsDictVariable(Variable):
436
427
  __slots__ = ()
437
428
 
nuitka/Version.py CHANGED
@@ -20,7 +20,7 @@
20
20
  """
21
21
 
22
22
  version_string = """\
23
- Nuitka V1.8.6
23
+ Nuitka V1.9.3
24
24
  Copyright (C) 2023 Kay Hayen."""
25
25
 
26
26
 
@@ -32,14 +32,13 @@ def getNuitkaVersion():
32
32
  return version_string.split()[1][1:]
33
33
 
34
34
 
35
- def getNuitkaVersionTuple():
36
- """Return Nuitka version as a string.
35
+ def parseNuitkaVersionToTuple(version):
36
+ """Return Nuitka version as a tuple.
37
37
 
38
- This can also not be used for precise comparisons, last one might contain "rc"
38
+ This can also not be used for precise comparisons, even with rc versions,
39
+ but it's not actually a version.
39
40
  """
40
41
 
41
- version = getNuitkaVersion()
42
-
43
42
  if "rc" in version:
44
43
  rc_number = int(version[version.find("rc") + 2 :] or "0")
45
44
  version = version[: version.find("rc")]
@@ -58,6 +57,17 @@ def getNuitkaVersionTuple():
58
57
  return tuple(result)
59
58
 
60
59
 
60
+ def getNuitkaVersionTuple():
61
+ """Return Nuitka version as a tuple.
62
+
63
+ This can also not be used for precise comparisons, even with rc versions,
64
+ but it's not actually a version. The format is used what is used for
65
+ "__compiled__" values.
66
+ """
67
+
68
+ return parseNuitkaVersionToTuple(version=getNuitkaVersion())
69
+
70
+
61
71
  def getNuitkaVersionYear():
62
72
  """The year of Nuitka copyright for use in generations."""
63
73
 
nuitka/__main__.py CHANGED
@@ -86,6 +86,14 @@ def main():
86
86
  if os.environ.get("PYTHONHASHSEED", "-1") != "0":
87
87
  needs_re_execution = True
88
88
 
89
+ # The frozen stdlib modules of Python 3.11 are less compatible than the ones
90
+ # of Nuitka, so prefer those.
91
+ if sys.version_info >= (3, 11):
92
+ from _imp import _frozen_module_names
93
+
94
+ if "os" in _frozen_module_names():
95
+ needs_re_execution = True
96
+
89
97
  # Avoid doing it when running in Visual Code.
90
98
  if needs_re_execution and "debugpy" in sys.modules:
91
99
  needs_re_execution = False
@@ -135,6 +143,13 @@ def main():
135
143
  setPthImportedPackages(ast.literal_eval(os.environ["NUITKA_PTH_IMPORTED"]))
136
144
  del os.environ["NUITKA_PTH_IMPORTED"]
137
145
 
146
+ if "NUITKA_USER_SITE" in os.environ:
147
+ from nuitka.utils.Distributions import setUserSiteDirectory
148
+
149
+ setUserSiteDirectory(ast.literal_eval(os.environ["NUITKA_USER_SITE"]))
150
+
151
+ del os.environ["NUITKA_USER_SITE"]
152
+
138
153
  # Now the real main program of Nuitka can take over.
139
154
  from nuitka import MainControl # isort:skip
140
155
 
nuitka/__past__.py CHANGED
@@ -27,7 +27,7 @@ be a "in (str, unicode)" rather than making useless version checks.
27
27
 
28
28
  import pkgutil
29
29
  import sys
30
- from abc import ABCMeta
30
+ from hashlib import md5 as _md5
31
31
 
32
32
  # pylint: disable=invalid-name,self-assigning-variable
33
33
 
@@ -118,7 +118,7 @@ if str is bytes:
118
118
  else:
119
119
 
120
120
  def to_byte(value):
121
- assert type(value) is int and 0 <= value < 256
121
+ assert type(value) is int and 0 <= value < 256, value
122
122
  return bytes((value,))
123
123
 
124
124
  def from_byte(value):
@@ -137,19 +137,6 @@ except ImportError:
137
137
  UnionType = None
138
138
 
139
139
 
140
- def getMetaClassBase(meta_class_prefix):
141
- """For Python2/3 compatible source, we create a base class that has the metaclass
142
- used and doesn't require making a choice.
143
- """
144
-
145
- class MetaClass(ABCMeta):
146
- pass
147
-
148
- MetaClassBase = MetaClass("%sMetaClassBase" % meta_class_prefix, (object,), {})
149
-
150
- return MetaClassBase
151
-
152
-
153
140
  if str is bytes:
154
141
  try:
155
142
  import subprocess32 as subprocess
@@ -181,15 +168,26 @@ else:
181
168
 
182
169
 
183
170
  try:
184
- ExceptionGroup = ExceptionGroup
171
+ ExceptionGroup = ExceptionGroup # pylint: disable=I0021,redefined-builtin
185
172
  except NameError:
186
173
  ExceptionGroup = None
187
174
 
188
175
  try:
189
- BaseExceptionGroup = BaseExceptionGroup
176
+ BaseExceptionGroup = BaseExceptionGroup # pylint: disable=I0021,redefined-builtin
190
177
  except NameError:
191
178
  BaseExceptionGroup = None
192
179
 
180
+ try:
181
+ _md5()
182
+ except ValueError:
183
+ # On FIPS compliant systems, checks might be enabled that require
184
+ # this parameter to be set.
185
+ def md5(value=b""):
186
+ return _md5(value, usedforsecurity=False)
187
+
188
+ else:
189
+ md5 = _md5
190
+
193
191
  # For PyLint to be happy.
194
192
  assert long
195
193
  assert unicode