Nuitka-winsvc 2.3.11__cp311-cp311-win_amd64.whl → 2.4.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 (210) hide show
  1. Nuitka_winsvc-2.3.11.data/scripts/nuitka-run.bat → Nuitka_winsvc-2.4.1.data/scripts/nuitka-run.cmd +1 -1
  2. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/METADATA +1 -1
  3. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/RECORD +210 -207
  4. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/WHEEL +1 -1
  5. nuitka/CacheCleanup.py +6 -1
  6. nuitka/HardImportRegistry.py +29 -2
  7. nuitka/MainControl.py +62 -35
  8. nuitka/ModuleRegistry.py +11 -3
  9. nuitka/OptionParsing.py +78 -39
  10. nuitka/Options.py +142 -35
  11. nuitka/OutputDirectories.py +5 -0
  12. nuitka/PostProcessing.py +23 -14
  13. nuitka/PythonFlavors.py +22 -4
  14. nuitka/PythonVersions.py +18 -0
  15. nuitka/TreeXML.py +6 -3
  16. nuitka/Version.py +1 -1
  17. nuitka/__main__.py +55 -10
  18. nuitka/build/Backend.scons +6 -1
  19. nuitka/build/CCompilerVersion.scons +1 -0
  20. nuitka/build/Onefile.scons +4 -0
  21. nuitka/build/SconsCaching.py +1 -0
  22. nuitka/build/SconsCompilerSettings.py +1 -0
  23. nuitka/build/SconsHacks.py +5 -1
  24. nuitka/build/SconsInterface.py +2 -0
  25. nuitka/build/SconsUtils.py +4 -1
  26. nuitka/build/include/nuitka/allocator.h +27 -5
  27. nuitka/build/include/nuitka/calling.h +1 -1
  28. nuitka/build/include/nuitka/compiled_frame.h +23 -23
  29. nuitka/build/include/nuitka/compiled_method.h +1 -1
  30. nuitka/build/include/nuitka/exception_groups.h +0 -2
  31. nuitka/build/include/nuitka/helper/attributes.h +7 -1
  32. nuitka/build/include/nuitka/helper/subscripts.h +1 -1
  33. nuitka/build/include/nuitka/helpers.h +7 -4
  34. nuitka/build/include/nuitka/prelude.h +6 -10
  35. nuitka/build/include/nuitka/printing.h +2 -0
  36. nuitka/build/include/nuitka/unfreezing.h +5 -5
  37. nuitka/build/inline_copy/tqdm/tqdm/_monitor.py +4 -1
  38. nuitka/build/static_src/CompiledAsyncgenType.c +2 -4
  39. nuitka/build/static_src/CompiledCellType.c +7 -7
  40. nuitka/build/static_src/CompiledCodeHelpers.c +49 -36
  41. nuitka/build/static_src/CompiledCoroutineType.c +2 -4
  42. nuitka/build/static_src/CompiledFrameType.c +109 -82
  43. nuitka/build/static_src/CompiledFunctionType.c +36 -9
  44. nuitka/build/static_src/CompiledGeneratorType.c +12 -10
  45. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +2 -2
  46. nuitka/build/static_src/CompiledMethodType.c +14 -13
  47. nuitka/build/static_src/HelpersAttributes.c +13 -15
  48. nuitka/build/static_src/HelpersBuiltin.c +16 -7
  49. nuitka/build/static_src/HelpersCalling.c +13 -13
  50. nuitka/build/static_src/HelpersCallingGenerated.c +22 -22
  51. nuitka/build/static_src/HelpersComparisonEq.c +110 -110
  52. nuitka/build/static_src/HelpersComparisonEqUtils.c +1 -1
  53. nuitka/build/static_src/HelpersComparisonGe.c +110 -110
  54. nuitka/build/static_src/HelpersComparisonGt.c +110 -110
  55. nuitka/build/static_src/HelpersComparisonLe.c +110 -110
  56. nuitka/build/static_src/HelpersComparisonLt.c +110 -110
  57. nuitka/build/static_src/HelpersComparisonNe.c +110 -110
  58. nuitka/build/static_src/HelpersConstantsBlob.c +480 -481
  59. nuitka/build/static_src/HelpersDictionaries.c +9 -0
  60. nuitka/build/static_src/HelpersFiles.c +2 -2
  61. nuitka/build/static_src/HelpersFilesystemPaths.c +28 -13
  62. nuitka/build/static_src/HelpersImport.c +1 -1
  63. nuitka/build/static_src/HelpersLists.c +5 -1
  64. nuitka/build/static_src/HelpersMatching.c +95 -35
  65. nuitka/build/static_src/HelpersOperationInplaceAdd.c +23 -23
  66. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -0
  67. nuitka/build/static_src/HelpersOperationInplaceBitand.c +11 -11
  68. nuitka/build/static_src/HelpersOperationInplaceBitor.c +11 -11
  69. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +11 -11
  70. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +17 -17
  71. nuitka/build/static_src/HelpersOperationInplaceLshift.c +9 -9
  72. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
  73. nuitka/build/static_src/HelpersOperationInplaceMod.c +47 -47
  74. nuitka/build/static_src/HelpersOperationInplaceMult.c +28 -28
  75. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +17 -17
  76. nuitka/build/static_src/HelpersOperationInplacePow.c +17 -17
  77. nuitka/build/static_src/HelpersOperationInplaceRshift.c +9 -9
  78. nuitka/build/static_src/HelpersOperationInplaceSub.c +17 -17
  79. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +17 -17
  80. nuitka/build/static_src/HelpersSequences.c +1 -1
  81. nuitka/build/static_src/HelpersTypes.c +8 -4
  82. nuitka/build/static_src/MainProgram.c +28 -9
  83. nuitka/build/static_src/MetaPathBasedLoader.c +124 -108
  84. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +13 -4
  85. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +1 -1
  86. nuitka/build/static_src/OnefileBootstrap.c +34 -6
  87. nuitka/code_generation/AttributeCodes.py +12 -10
  88. nuitka/code_generation/CodeGeneration.py +6 -7
  89. nuitka/code_generation/ConstantCodes.py +53 -10
  90. nuitka/code_generation/GlobalConstants.py +6 -6
  91. nuitka/code_generation/Indentation.py +3 -4
  92. nuitka/code_generation/LoaderCodes.py +3 -0
  93. nuitka/code_generation/LocalsDictCodes.py +36 -14
  94. nuitka/code_generation/MatchCodes.py +23 -4
  95. nuitka/code_generation/ModuleCodes.py +0 -7
  96. nuitka/code_generation/Namify.py +2 -0
  97. nuitka/code_generation/PackageResourceCodes.py +5 -1
  98. nuitka/code_generation/templates/CodeTemplatesConstants.py +6 -4
  99. nuitka/code_generation/templates/CodeTemplatesLoader.py +1 -1
  100. nuitka/code_generation/templates/CodeTemplatesModules.py +3 -3
  101. nuitka/code_generation/templates/CodeTemplatesVariables.py +16 -2
  102. nuitka/code_generation/templates_c/CodeTemplateCallsMethodPositional.c.j2 +2 -2
  103. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +1 -1
  104. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
  105. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +7 -7
  106. nuitka/freezer/DependsExe.py +3 -1
  107. nuitka/freezer/DllDependenciesMacOS.py +5 -12
  108. nuitka/freezer/IncludedDataFiles.py +12 -3
  109. nuitka/freezer/IncludedEntryPoints.py +8 -2
  110. nuitka/freezer/Onefile.py +6 -1
  111. nuitka/freezer/Standalone.py +9 -2
  112. nuitka/importing/Importing.py +14 -5
  113. nuitka/importing/Recursion.py +3 -0
  114. nuitka/nodes/AttributeNodesGenerated.py +21 -12
  115. nuitka/nodes/BuiltinOpenNodes.py +5 -0
  116. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +11 -11
  117. nuitka/nodes/BuiltinRefNodes.py +41 -1
  118. nuitka/nodes/ChildrenHavingMixins.py +143 -355
  119. nuitka/nodes/ClassNodes.py +30 -12
  120. nuitka/nodes/CodeObjectSpecs.py +9 -0
  121. nuitka/nodes/ExpressionBasesGenerated.py +11 -11
  122. nuitka/nodes/FunctionNodes.py +7 -11
  123. nuitka/nodes/FutureSpecs.py +16 -3
  124. nuitka/nodes/GeneratorNodes.py +2 -2
  125. nuitka/nodes/HardImportNodesGenerated.py +11 -134
  126. nuitka/nodes/LocalsScopes.py +19 -23
  127. nuitka/nodes/MatchNodes.py +18 -7
  128. nuitka/nodes/ModuleAttributeNodes.py +1 -20
  129. nuitka/nodes/ModuleNodes.py +23 -6
  130. nuitka/nodes/NodeBases.py +3 -2
  131. nuitka/nodes/NodeMetaClasses.py +26 -10
  132. nuitka/nodes/ReturnNodes.py +1 -1
  133. nuitka/nodes/StatementBasesGenerated.py +11 -11
  134. nuitka/nodes/SubscriptNodes.py +4 -4
  135. nuitka/nodes/VariableAssignNodes.py +1 -1
  136. nuitka/nodes/VariableRefNodes.py +28 -2
  137. nuitka/optimizations/FunctionInlining.py +3 -6
  138. nuitka/optimizations/Optimization.py +13 -12
  139. nuitka/optimizations/TraceCollections.py +19 -4
  140. nuitka/plugins/PluginBase.py +121 -133
  141. nuitka/plugins/Plugins.py +91 -3
  142. nuitka/plugins/YamlPluginBase.py +121 -0
  143. nuitka/plugins/standard/AntiBloatPlugin.py +87 -28
  144. nuitka/plugins/standard/DataFilesPlugin.py +15 -6
  145. nuitka/plugins/standard/DelvewheelPlugin.py +7 -3
  146. nuitka/plugins/standard/DllFilesPlugin.py +5 -3
  147. nuitka/plugins/standard/ImplicitImports.py +34 -20
  148. nuitka/plugins/standard/MatplotlibPlugin.py +3 -1
  149. nuitka/plugins/standard/MultiprocessingPlugin.py +2 -2
  150. nuitka/plugins/standard/OptionsNannyPlugin.py +1 -1
  151. nuitka/plugins/standard/PySidePyQtPlugin.py +11 -12
  152. nuitka/plugins/standard/SpacyPlugin.py +136 -0
  153. nuitka/plugins/standard/standard.nuitka-package.config.yml +462 -179
  154. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +6 -0
  155. nuitka/reports/Reports.py +53 -5
  156. nuitka/specs/BuiltinParameterSpecs.py +1 -1
  157. nuitka/specs/HardImportSpecs.py +0 -6
  158. nuitka/tools/data_composer/DataComposer.py +29 -27
  159. nuitka/tools/environments/CreateEnvironment.py +1 -0
  160. nuitka/tools/environments/Virtualenv.py +25 -11
  161. nuitka/tools/general/find_module/FindModuleCode.py +13 -3
  162. nuitka/tools/onefile_compressor/OnefileCompressor.py +21 -4
  163. nuitka/tools/scanning/DisplayPackageDLLs.py +17 -3
  164. nuitka/tools/specialize/CTypeDescriptions.py +13 -7
  165. nuitka/tools/specialize/SpecializePython.py +18 -1
  166. nuitka/tools/testing/Common.py +19 -6
  167. nuitka/tools/testing/check_reference_counts/__main__.py +1 -1
  168. nuitka/tools/testing/run_nuitka_tests/__main__.py +0 -20
  169. nuitka/tools/watch/AutoStage.py +144 -0
  170. nuitka/tools/watch/__main__.py +79 -32
  171. nuitka/tree/Building.py +105 -104
  172. nuitka/tree/ComplexCallHelperFunctions.py +16 -26
  173. nuitka/tree/InternalModule.py +8 -0
  174. nuitka/tree/ReformulationAssignmentStatements.py +29 -59
  175. nuitka/tree/ReformulationClasses.py +10 -17
  176. nuitka/tree/ReformulationClasses3.py +69 -43
  177. nuitka/tree/ReformulationComparisonExpressions.py +6 -16
  178. nuitka/tree/ReformulationContractionExpressions.py +14 -23
  179. nuitka/tree/ReformulationDictionaryCreation.py +6 -10
  180. nuitka/tree/ReformulationExecStatements.py +10 -10
  181. nuitka/tree/ReformulationForLoopStatements.py +6 -12
  182. nuitka/tree/ReformulationFunctionStatements.py +21 -28
  183. nuitka/tree/ReformulationImportStatements.py +8 -10
  184. nuitka/tree/ReformulationLambdaExpressions.py +3 -6
  185. nuitka/tree/ReformulationMatchStatements.py +166 -60
  186. nuitka/tree/ReformulationMultidist.py +3 -1
  187. nuitka/tree/ReformulationNamespacePackages.py +1 -1
  188. nuitka/tree/ReformulationPrintStatements.py +3 -6
  189. nuitka/tree/ReformulationSequenceCreation.py +13 -26
  190. nuitka/tree/ReformulationTryFinallyStatements.py +15 -0
  191. nuitka/tree/ReformulationWithStatements.py +12 -16
  192. nuitka/tree/SourceHandling.py +13 -8
  193. nuitka/tree/VariableClosure.py +5 -21
  194. nuitka/utils/Distributions.py +80 -11
  195. nuitka/utils/Download.py +38 -31
  196. nuitka/utils/Execution.py +13 -2
  197. nuitka/utils/FileOperations.py +55 -28
  198. nuitka/utils/Images.py +6 -1
  199. nuitka/utils/Importing.py +1 -1
  200. nuitka/utils/ModuleNames.py +11 -5
  201. nuitka/utils/ReExecute.py +17 -13
  202. nuitka/utils/SharedLibraries.py +32 -8
  203. nuitka/utils/Signing.py +3 -1
  204. nuitka/utils/StaticLibraries.py +51 -41
  205. nuitka/utils/Timing.py +1 -1
  206. nuitka/utils/Utils.py +29 -7
  207. /Nuitka_winsvc-2.3.11.data/scripts/nuitka.bat → /Nuitka_winsvc-2.4.1.data/scripts/nuitka.cmd +0 -0
  208. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/LICENSE.txt +0 -0
  209. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/entry_points.txt +0 -0
  210. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/top_level.txt +0 -0
nuitka/Options.py CHANGED
@@ -43,14 +43,17 @@ from nuitka.PythonFlavors import (
43
43
  isUninstalledPython,
44
44
  )
45
45
  from nuitka.PythonVersions import (
46
+ getLaunchingSystemPrefixPath,
46
47
  getNotYetSupportedPythonVersions,
47
48
  getSupportedPythonVersions,
48
49
  isDebugPython,
50
+ isPythonWithGil,
49
51
  python_version,
50
52
  python_version_str,
51
53
  )
52
54
  from nuitka.utils.Execution import getExecutablePath
53
55
  from nuitka.utils.FileOperations import (
56
+ isLegalPath,
54
57
  isPathExecutable,
55
58
  openTextFile,
56
59
  resolveShellPatternToFilenames,
@@ -60,6 +63,7 @@ from nuitka.utils.StaticLibraries import getSystemStaticLibPythonPath
60
63
  from nuitka.utils.Utils import (
61
64
  getArchitecture,
62
65
  getCPUCoreCount,
66
+ getLaunchingNuitkaProcessEnvironmentValue,
63
67
  getLinuxDistribution,
64
68
  getMacOSRelease,
65
69
  getOS,
@@ -116,6 +120,9 @@ def checkPathSpec(value, arg_name, allow_disable):
116
120
  % (arg_name, old, value)
117
121
  )
118
122
 
123
+ # This changes the '/' to '\' on Windows at least.
124
+ value = os.path.normpath(value)
125
+
119
126
  if "\n" in value or "\r" in value:
120
127
  Tracing.options_logger.sysexit(
121
128
  "Using a new line in value '%s=%r' value is not allowed."
@@ -221,6 +228,22 @@ start of '%s=%s', using that alone is not allowed."""
221
228
  % (candidate, arg_name, value)
222
229
  )
223
230
 
231
+ if value.startswith(candidate):
232
+ if value[len(candidate)] != os.path.sep:
233
+ Tracing.options_logger.sysexit(
234
+ """Cannot use general system folder %s, without a path \
235
+ separator '%s=%s', just appending to these is not allowed, needs to be \
236
+ below them."""
237
+ % (candidate, arg_name, value)
238
+ )
239
+
240
+ is_legal, reason = isLegalPath(value)
241
+ if not is_legal:
242
+ Tracing.options_logger.sysexit(
243
+ """Cannot use illegal paths '%s=%s', due to %s."""
244
+ % (arg_name, value, reason)
245
+ )
246
+
224
247
  return value
225
248
 
226
249
 
@@ -273,6 +296,8 @@ def _getVersionInformationValues():
273
296
  yield "Commercial: %s" % getCommercialVersion()
274
297
  yield "Python: %s" % sys.version.split("\n", 1)[0]
275
298
  yield "Flavor: %s" % getPythonFlavorName()
299
+ if python_version >= 0x3D0:
300
+ yield "GIL: %s" % ("yes" if isPythonWithGil() else "no")
276
301
  yield "Executable: %s" % sys.executable
277
302
  yield "OS: %s" % getOS()
278
303
  yield "Arch: %s" % getArchitecture()
@@ -414,11 +439,17 @@ Error, the Python from Windows app store is not supported.""",
414
439
  % " ".join(_quoteArg(arg) for arg in sys.argv[1:])
415
440
  )
416
441
 
417
- if os.getenv("NUITKA_REEXECUTION") and not isAllowedToReexecute():
442
+ if (
443
+ getLaunchingNuitkaProcessEnvironmentValue("NUITKA_RE_EXECUTION")
444
+ and not isAllowedToReexecute()
445
+ ):
418
446
  Tracing.general.sysexit(
419
447
  "Error, not allowed to re-execute, but that has happened."
420
448
  )
421
449
 
450
+ # Force to persist this one early.
451
+ getLaunchingSystemPrefixPath()
452
+
422
453
  if options.progress_bar:
423
454
  Progress.enableProgressBar()
424
455
 
@@ -934,6 +965,13 @@ release will add it. In the mean time use '%s' instead."""
934
965
  )
935
966
  )
936
967
 
968
+ if not isPythonWithGil():
969
+ Tracing.general.warning(
970
+ """\
971
+ The Python without GIL is only experimentally supported by \
972
+ and recommended only for use in Nuitka development and testing."""
973
+ )
974
+
937
975
  default_reference_mode = (
938
976
  "runtime" if shallMakeModule() or isStandaloneMode() else "original"
939
977
  )
@@ -1003,7 +1041,7 @@ release will add it. In the mean time use '%s' instead."""
1003
1041
  getJobLimit()
1004
1042
  except ValueError:
1005
1043
  Tracing.options_logger.sysexit(
1006
- "For --jobs value, use positive integer values only, not, but not '%s'."
1044
+ "For '--jobs' value, use integer values only, not, but not '%s'."
1007
1045
  % options.jobs
1008
1046
  )
1009
1047
 
@@ -1052,7 +1090,8 @@ to work. You need to instead selectively add them with \
1052
1090
  )
1053
1091
 
1054
1092
  if (
1055
- not standalone_mode
1093
+ not shallCreatePythonPgoInput()
1094
+ and not standalone_mode
1056
1095
  and options.follow_all is None
1057
1096
  and not options.follow_modules
1058
1097
  and not options.follow_stdlib
@@ -1080,7 +1119,7 @@ make sure that is intended."""
1080
1119
  options.static_libpython = "no"
1081
1120
 
1082
1121
  if (
1083
- not isPgoMode()
1122
+ not isCPgoMode()
1084
1123
  and not isPythonPgoMode()
1085
1124
  and (getPgoArgs() or getPgoExecutable())
1086
1125
  ):
@@ -1088,15 +1127,19 @@ make sure that is intended."""
1088
1127
  "Providing PGO arguments without enabling PGO mode has no effect."
1089
1128
  )
1090
1129
 
1091
- if isPgoMode():
1130
+ if isCPgoMode():
1092
1131
  if isStandaloneMode():
1093
1132
  Tracing.optimization_logger.warning(
1094
- "Using PGO with standalone/onefile mode is not currently working. Expect errors."
1133
+ """\
1134
+ Using C level PGO with standalone/onefile mode is not \
1135
+ currently working. Expect errors."""
1095
1136
  )
1096
1137
 
1097
1138
  if shallMakeModule():
1098
1139
  Tracing.optimization_logger.warning(
1099
- "Using PGO with module mode is not currently working. Expect errors."
1140
+ """\
1141
+ Using C level PGO with module mode is not currently \
1142
+ working. Expect errors."""
1100
1143
  )
1101
1144
 
1102
1145
  if (
@@ -1300,6 +1343,9 @@ def shallFollowNoImports():
1300
1343
 
1301
1344
  def shallFollowAllImports():
1302
1345
  """:returns: bool derived from ``--follow-imports``"""
1346
+ if shallCreatePythonPgoInput() and options.is_standalone:
1347
+ return True
1348
+
1303
1349
  return options.is_standalone or options.follow_all is True
1304
1350
 
1305
1351
 
@@ -1512,6 +1558,10 @@ def getMainEntryPointFilenames():
1512
1558
  return tuple(os.path.normpath(r).rstrip(os.path.sep) for r in result)
1513
1559
 
1514
1560
 
1561
+ def isMultidistMode():
1562
+ return options is not None and options.mains and len(options.mains) > 1
1563
+
1564
+
1515
1565
  def shallOptimizeStringExec():
1516
1566
  """Inactive yet"""
1517
1567
  return False
@@ -1554,7 +1604,7 @@ def _shallUseStaticLibPython():
1554
1604
 
1555
1605
  # For Anaconda default to trying static lib python library, which
1556
1606
  # normally is just not available or if it is even unusable.
1557
- if isAnacondaPython() and not isMacOS() and not isWin32Windows():
1607
+ if isAnacondaPython() and not isWin32Windows():
1558
1608
  return (
1559
1609
  True,
1560
1610
  "Nuitka on Anaconda needs package for static libpython installed. Execute 'conda install libpython-static'.",
@@ -1643,22 +1693,25 @@ def isShowScons():
1643
1693
 
1644
1694
  def getJobLimit():
1645
1695
  """*int*, value of ``--jobs`` / "-j" or number of CPU kernels"""
1646
- if options.jobs is None:
1647
- if isLowMemory():
1648
- return 1
1649
- else:
1650
- return getCPUCoreCount()
1696
+ jobs = options.jobs
1651
1697
 
1652
- result = int(options.jobs)
1698
+ # Low memory has a default of 1.
1699
+ if jobs is None and isLowMemory():
1700
+ return 1
1701
+
1702
+ if jobs is None:
1703
+ result = getCPUCoreCount()
1704
+ else:
1705
+ result = int(jobs)
1653
1706
 
1654
- if result <= 0:
1655
- raise ValueError(result)
1707
+ if result <= 0:
1708
+ result = max(1, getCPUCoreCount() + jobs)
1656
1709
 
1657
1710
  return result
1658
1711
 
1659
1712
 
1660
1713
  def getLtoMode():
1661
- """:returns: bool derived from ``--lto`` or ``--pgo``"""
1714
+ """:returns: bool derived from ``--lto``"""
1662
1715
  return options.lto
1663
1716
 
1664
1717
 
@@ -1797,6 +1850,23 @@ def getExperimentalIndications():
1797
1850
  return ()
1798
1851
 
1799
1852
 
1853
+ def getDebugModeIndications():
1854
+ result = []
1855
+
1856
+ for debug_option_value_name in ("debug_immortal",):
1857
+ if debug_option_value_name == "debug_immortal" and python_version < 0x3C0:
1858
+ continue
1859
+
1860
+ if _isDebug():
1861
+ if getattr(options, debug_option_value_name) is not False:
1862
+ result.append(debug_option_value_name)
1863
+ else:
1864
+ if getattr(options, debug_option_value_name) is True:
1865
+ result.append(debug_option_value_name)
1866
+
1867
+ return result
1868
+
1869
+
1800
1870
  def shallExplainImports():
1801
1871
  """:returns: bool derived from ``--explain-imports``"""
1802
1872
  return options is not None and options.explain_imports
@@ -1804,12 +1874,18 @@ def shallExplainImports():
1804
1874
 
1805
1875
  def isStandaloneMode():
1806
1876
  """:returns: bool derived from ``--standalone``"""
1807
- return options.is_standalone
1877
+ if shallCreatePythonPgoInput():
1878
+ return False
1879
+
1880
+ return bool(options.is_standalone or options.list_package_dlls)
1808
1881
 
1809
1882
 
1810
1883
  def isOnefileMode():
1811
1884
  """:returns: bool derived from ``--onefile``"""
1812
- return options.is_onefile
1885
+ if shallCreatePythonPgoInput():
1886
+ return False
1887
+
1888
+ return bool(options.is_onefile)
1813
1889
 
1814
1890
 
1815
1891
  def isAcceleratedMode():
@@ -1824,6 +1900,9 @@ def isOnefileTempDirMode():
1824
1900
  Using cached onefile execution when the spec doesn't contain
1825
1901
  volatile things.
1826
1902
  """
1903
+ if shallCreatePythonPgoInput():
1904
+ return False
1905
+
1827
1906
  spec = getOnefileTempDirSpec()
1828
1907
 
1829
1908
  for candidate in (
@@ -1838,8 +1917,11 @@ def isOnefileTempDirMode():
1838
1917
  return False
1839
1918
 
1840
1919
 
1841
- def isPgoMode():
1842
- """:returns: bool derived from ``--pgo``"""
1920
+ def isCPgoMode():
1921
+ """:returns: bool derived from ``--pgo-c``"""
1922
+ if shallCreatePythonPgoInput():
1923
+ return False
1924
+
1843
1925
  return options.is_c_pgo
1844
1926
 
1845
1927
 
@@ -1853,7 +1935,7 @@ def getPythonPgoInput():
1853
1935
  return options.python_pgo_input
1854
1936
 
1855
1937
 
1856
- def shallCreatePgoInput():
1938
+ def shallCreatePythonPgoInput():
1857
1939
  return isPythonPgoMode() and getPythonPgoInput() is None
1858
1940
 
1859
1941
 
@@ -1883,8 +1965,7 @@ def getOnefileTempDirSpec():
1883
1965
  options.onefile_tempdir_spec or "{TEMP}" + os.path.sep + "onefile_{PID}_{TIME}"
1884
1966
  )
1885
1967
 
1886
- # This changes the '/' to '\' on Windows at least.
1887
- return os.path.normpath(result)
1968
+ return result
1888
1969
 
1889
1970
 
1890
1971
  def getOnefileChildGraceTime():
@@ -2073,6 +2154,16 @@ def getFileVersionTuple():
2073
2154
  return _parseVersionNumber(options.file_version)
2074
2155
 
2075
2156
 
2157
+ def getProductFileVersion():
2158
+ if options.product_version:
2159
+ if options.file_version:
2160
+ return "%s-%s" % (options.product_version, options.file_version)
2161
+ else:
2162
+ return options.product_version
2163
+ else:
2164
+ return options.file_version
2165
+
2166
+
2076
2167
  def getWindowsSplashScreen():
2077
2168
  """:returns: bool derived from ``--onefile-windows-splash-screen-image``"""
2078
2169
  return options.splash_screen_image
@@ -2100,6 +2191,9 @@ def getMacOSTargetArch():
2100
2191
 
2101
2192
  def shallCreateAppBundle():
2102
2193
  """*bool* shall create an application bundle, derived from ``--macos-create-app-bundle`` value"""
2194
+ if shallCreatePythonPgoInput():
2195
+ return False
2196
+
2103
2197
  return options.macos_create_bundle and isMacOS()
2104
2198
 
2105
2199
 
@@ -2370,22 +2464,18 @@ def shallUseProgressBar():
2370
2464
 
2371
2465
  def getForcedStdoutPath():
2372
2466
  """*str* force program stdout output into that filename"""
2373
- result = options.force_stdout_spec
2374
-
2375
- if result is not None:
2376
- result = os.path.normpath(result)
2467
+ if shallCreatePythonPgoInput():
2468
+ return False
2377
2469
 
2378
- return result
2470
+ return options.force_stdout_spec
2379
2471
 
2380
2472
 
2381
2473
  def getForcedStderrPath():
2382
2474
  """*str* force program stderr output into that filename"""
2383
- result = options.force_stderr_spec
2384
-
2385
- if result is not None:
2386
- result = os.path.normpath(result)
2475
+ if shallCreatePythonPgoInput():
2476
+ return False
2387
2477
 
2388
- return result
2478
+ return options.force_stderr_spec
2389
2479
 
2390
2480
 
2391
2481
  def shallShowSourceModifications(module_name):
@@ -2479,6 +2569,17 @@ def shallShowExecutedCommands():
2479
2569
  return isExperimental("show-commands")
2480
2570
 
2481
2571
 
2572
+ def getTargetPythonDescription():
2573
+ """:returns: tuple(python_version,OS/arch) string derived from ``--target``"""
2574
+ if options.target_spec is not None:
2575
+ # TODO: Only one we are working on right now.
2576
+ assert options.target_spec == "wasi"
2577
+
2578
+ return python_version, "wasi"
2579
+
2580
+ return None
2581
+
2582
+
2482
2583
  def getFcfProtectionMode():
2483
2584
  """:returns: string derived from ``--fcf-protection``"""
2484
2585
  return options.cf_protection
@@ -2486,7 +2587,13 @@ def getFcfProtectionMode():
2486
2587
 
2487
2588
  def getModuleParameter(module_name, parameter_name):
2488
2589
  """:returns: string derived from ``--module-parameter``"""
2489
- option_name = module_name.asString() + "-" + parameter_name
2590
+
2591
+ module_name_prefix = module_name.getTopLevelPackageName().asString()
2592
+
2593
+ if parameter_name.startswith(module_name_prefix + "-"):
2594
+ option_name = parameter_name
2595
+ else:
2596
+ option_name = module_name_prefix + "-" + parameter_name
2490
2597
 
2491
2598
  for module_option in options.module_parameters:
2492
2599
  module_option_name, module_option_value = module_option.split("=", 1)
@@ -34,6 +34,11 @@ def setMainModule(main_module):
34
34
  _main_module = main_module
35
35
 
36
36
 
37
+ def hasMainModule():
38
+ """For reporting to check if there is anything to talk about."""
39
+ return _main_module is not None
40
+
41
+
37
42
  def getSourceDirectoryPath(onefile=False):
38
43
  """Return path inside the build directory."""
39
44
 
nuitka/PostProcessing.py CHANGED
@@ -12,12 +12,7 @@ import sys
12
12
  from nuitka import Options, OutputDirectories
13
13
  from nuitka.build.DataComposerInterface import getConstantBlobFilename
14
14
  from nuitka.ModuleRegistry import getImportedModuleNames
15
- from nuitka.PythonVersions import (
16
- getPythonABI,
17
- getTargetPythonDLLPath,
18
- python_version,
19
- python_version_str,
20
- )
15
+ from nuitka.PythonVersions import getTargetPythonDLLPath, python_version
21
16
  from nuitka.Tracing import postprocessing_logger
22
17
  from nuitka.utils.Execution import wrapCommandForDebuggerForExec
23
18
  from nuitka.utils.FileOperations import (
@@ -35,6 +30,8 @@ from nuitka.utils.MacOSApp import createPlistInfoFile
35
30
  from nuitka.utils.SharedLibraries import (
36
31
  callInstallNameTool,
37
32
  cleanupHeaderForAndroid,
33
+ getOtoolDependencyOutput,
34
+ parseOtoolListingOutput,
38
35
  )
39
36
  from nuitka.utils.Utils import isAndroidBasedLinux, isMacOS, isWin32Windows
40
37
  from nuitka.utils.WindowsResources import (
@@ -317,10 +314,26 @@ def executePostProcessing():
317
314
  and not Options.shallMakeModule()
318
315
  and not Options.shallUseStaticLibPython()
319
316
  ):
320
- python_abi_version = python_version_str + getPythonABI()
321
- python_dll_filename = "libpython" + python_abi_version + ".dylib"
322
- python_lib_path = os.path.join(sys.prefix, "lib")
323
- python_dll_path = os.path.join(python_lib_path, python_dll_filename)
317
+ for dependency in parseOtoolListingOutput(
318
+ getOtoolDependencyOutput(result_filename, [])
319
+ ):
320
+ if os.path.basename(dependency).lower().startswith(("python", "libpython")):
321
+ python_dll_filename = dependency
322
+ break
323
+ else:
324
+ postprocessing_logger.sysexit(
325
+ """
326
+ Error, expected 'libpython dependency not found. Please report the bug."""
327
+ )
328
+
329
+ python_lib_path = os.path.dirname(python_dll_filename)
330
+ python_dll_path = python_dll_filename
331
+
332
+ if not os.path.exists(python_lib_path):
333
+ python_lib_path = os.path.join(sys.prefix, "lib")
334
+ python_dll_path = os.path.join(
335
+ python_lib_path, os.path.basename(python_dll_filename)
336
+ )
324
337
 
325
338
  # Note: For CPython, and potentially others, the rpath for the Python
326
339
  # library needs to be set, so it will be detected as a dependency
@@ -332,10 +345,6 @@ def executePostProcessing():
332
345
  python_dll_filename,
333
346
  python_dll_path,
334
347
  ),
335
- (
336
- "@rpath/Python3.framework/Versions/%s/Python3" % python_version_str,
337
- python_dll_path,
338
- ),
339
348
  ),
340
349
  id_path=None,
341
350
  rpath=python_lib_path,
nuitka/PythonFlavors.py CHANGED
@@ -113,6 +113,20 @@ def isHomebrewPython():
113
113
  return False
114
114
 
115
115
 
116
+ def getHomebrewInstallPath():
117
+ assert isHomebrewPython()
118
+
119
+ candidate = getSystemPrefixPath()
120
+
121
+ while candidate != "/":
122
+ if os.path.isdir(os.path.join(candidate, "Cellar")):
123
+ return candidate
124
+
125
+ candidate = os.path.dirname(candidate)
126
+
127
+ sys.exit("Error, failed to locate homebrew installation path.")
128
+
129
+
116
130
  def isRyePython():
117
131
  if isMacOS():
118
132
  import sysconfig
@@ -271,10 +285,14 @@ def isCPythonOfficialPackage():
271
285
  sys_prefix = getSystemPrefixPath()
272
286
 
273
287
  # For macOS however, it's very knowable.
274
- if isMacOS() and isFilenameBelowPath(
275
- path="/Library/Frameworks/Python.framework/Versions/", filename=sys_prefix
276
- ):
277
- return True
288
+ if isMacOS():
289
+ for candidate in (
290
+ "/Library/Frameworks/Python.framework/Versions/",
291
+ "/Library/Frameworks/PythonT.framework/Versions/",
292
+ ):
293
+
294
+ if isFilenameBelowPath(path=candidate, filename=sys_prefix):
295
+ return True
278
296
 
279
297
  # For Windows, we check registry.
280
298
  if isWin32Windows():
nuitka/PythonVersions.py CHANGED
@@ -104,6 +104,7 @@ python_version_full_str = ".".join(str(s) for s in sys.version_info[0:3])
104
104
  python_version_str = ".".join(str(s) for s in sys.version_info[0:2])
105
105
 
106
106
 
107
+ # TODO: Move error construction helpers to separate node making helpers module.
107
108
  def getErrorMessageExecWithNestedFunction():
108
109
  """Error message of the concrete Python in case an exec occurs in a
109
110
  function that takes a closure variable.
@@ -161,6 +162,13 @@ def getUnboundLocalErrorErrorTemplate():
161
162
  return getUnboundLocalErrorErrorTemplate.result
162
163
 
163
164
 
165
+ def getDictFromkeysNoArgErrorMessage():
166
+ try:
167
+ dict.fromkeys()
168
+ except TypeError as e:
169
+ return e.args[0]
170
+
171
+
164
172
  _needs_set_literal_reverse_insertion = None
165
173
 
166
174
 
@@ -253,6 +261,12 @@ def getPythonABI():
253
261
  return abiflags
254
262
 
255
263
 
264
+ def getLaunchingSystemPrefixPath():
265
+ from nuitka.utils.Utils import getLaunchingNuitkaProcessEnvironmentValue
266
+
267
+ return getLaunchingNuitkaProcessEnvironmentValue("NUITKA_SYS_PREFIX")
268
+
269
+
256
270
  _the_sys_prefix = None
257
271
 
258
272
 
@@ -472,6 +486,10 @@ def getModuleLinkerLibs():
472
486
  return result
473
487
 
474
488
 
489
+ def isPythonWithGil():
490
+ return python_version < 0x3D0 or sys.flags.gil
491
+
492
+
475
493
  # Part of "Nuitka", an optimizing Python compiler that is compatible and
476
494
  # integrates with CPython, but also works on its own.
477
495
  #
nuitka/TreeXML.py CHANGED
@@ -7,7 +7,7 @@ Means to create XML elements from Nuitka tree nodes and to convert the
7
7
  XML tree to ASCII or output it.
8
8
  """
9
9
 
10
- from nuitka.__past__ import StringIO
10
+ from nuitka.__past__ import BytesIO, StringIO
11
11
 
12
12
 
13
13
  def _indent(elem, level=0, more_sibs=False):
@@ -93,8 +93,11 @@ def toString(tree):
93
93
  return result
94
94
 
95
95
 
96
- def fromString(text):
97
- return fromFile(StringIO(text))
96
+ def fromString(text, use_lxml=False):
97
+ if type(text) is str:
98
+ return fromFile(StringIO(text), use_lxml=use_lxml)
99
+ else:
100
+ return fromFile(BytesIO(text), use_lxml=use_lxml)
98
101
 
99
102
 
100
103
  def fromFile(file_handle, use_lxml=False):
nuitka/Version.py CHANGED
@@ -20,7 +20,7 @@
20
20
  """
21
21
 
22
22
  version_string = """\
23
- Nuitka V2.3.11
23
+ Nuitka V2.4.1
24
24
  Copyright (C) 2024 Kay Hayen."""
25
25
 
26
26
 
nuitka/__main__.py CHANGED
@@ -14,6 +14,36 @@ or package, that can contain all used modules too.
14
14
  import os
15
15
  import sys
16
16
 
17
+ _cached_process_environments = {}
18
+
19
+
20
+ def getLaunchingNuitkaProcessEnvironmentValue(environment_variable_name):
21
+ if environment_variable_name not in _cached_process_environments:
22
+ _cached_process_environments[environment_variable_name] = os.getenv(
23
+ environment_variable_name
24
+ )
25
+ if _cached_process_environments[environment_variable_name] is not None:
26
+ del os.environ[environment_variable_name]
27
+
28
+ value = _cached_process_environments[environment_variable_name]
29
+
30
+ if value is not None and ":" not in value:
31
+ value = None
32
+
33
+ if value is not None:
34
+ pid, value = value.split(":", 1)
35
+
36
+ try:
37
+ pid = int(pid)
38
+ except ValueError:
39
+ value = None
40
+ else:
41
+ if os.name != "nt":
42
+ if pid != os.getpid():
43
+ value = None
44
+
45
+ return value
46
+
17
47
 
18
48
  def main():
19
49
  # PyLint for Python3 thinks we import from ourselves if we really
@@ -35,21 +65,25 @@ def main():
35
65
  )
36
66
  sys.exit(1)
37
67
 
38
- if "NUITKA_BINARY_NAME" in os.environ:
39
- sys.argv[0] = os.environ["NUITKA_BINARY_NAME"]
68
+ nuitka_binary_name = getLaunchingNuitkaProcessEnvironmentValue("NUITKA_BINARY_NAME")
69
+ if nuitka_binary_name is not None:
70
+ sys.argv[0] = nuitka_binary_name
71
+
72
+ nuitka_pythonpath_ast = getLaunchingNuitkaProcessEnvironmentValue(
73
+ "NUITKA_PYTHONPATH_AST"
74
+ )
40
75
 
41
- if "NUITKA_PYTHONPATH_AST" in os.environ:
76
+ if nuitka_pythonpath_ast is not None:
42
77
  # Restore the PYTHONPATH gained from the site module, that we chose not
43
78
  # to have imported during compilation. For loading "ast" module, we need
44
79
  # one element, that is not necessarily in our current path, but we use
45
80
  # that to evaluate the current path.
46
- sys.path = [os.environ["NUITKA_PYTHONPATH_AST"]]
81
+ sys.path = [nuitka_pythonpath_ast]
47
82
  import ast
48
83
 
49
- del os.environ["NUITKA_PYTHONPATH_AST"]
50
-
51
- sys.path = ast.literal_eval(os.environ["NUITKA_PYTHONPATH"])
52
- del os.environ["NUITKA_PYTHONPATH"]
84
+ sys.path = ast.literal_eval(
85
+ getLaunchingNuitkaProcessEnvironmentValue("NUITKA_PYTHONPATH")
86
+ )
53
87
  else:
54
88
  # Remove path element added for being called via "__main__.py", this can
55
89
  # only lead to trouble, having e.g. a "distutils" in sys.path that comes
@@ -103,6 +137,13 @@ def main():
103
137
 
104
138
  warnings.simplefilter("ignore", DeprecationWarning)
105
139
 
140
+ # Hack, we need this to bootstrap and it's actually living in __main__
141
+ # module of nuitka package and renamed to where we can get at easily for
142
+ # other uses.
143
+ __import__("nuitka").getLaunchingNuitkaProcessEnvironmentValue = (
144
+ getLaunchingNuitkaProcessEnvironmentValue
145
+ )
146
+
106
147
  from nuitka import Options # isort:skip
107
148
 
108
149
  Options.parseArgs()
@@ -151,11 +192,15 @@ def main():
151
192
 
152
193
 
153
194
  if __name__ == "__main__":
154
- if "NUITKA_PACKAGE_HOME" in os.environ:
155
- sys.path.insert(0, os.environ["NUITKA_PACKAGE_HOME"])
195
+ _nuitka_package_home = getLaunchingNuitkaProcessEnvironmentValue(
196
+ "NUITKA_PACKAGE_HOME"
197
+ )
198
+ if _nuitka_package_home is not None:
199
+ sys.path.insert(0, _nuitka_package_home)
156
200
 
157
201
  import nuitka # just to have it loaded from there, pylint: disable=unused-import
158
202
 
203
+ assert sys.path[0] is _nuitka_package_home
159
204
  del sys.path[0]
160
205
 
161
206
  main()