Nuitka-winsvc 2.1.6__cp311-cp311-win_amd64.whl → 2.2.1__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (232) hide show
  1. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.1.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.1.dist-info}/RECORD +232 -223
  3. nuitka/Errors.py +4 -0
  4. nuitka/HardImportRegistry.py +18 -1
  5. nuitka/MainControl.py +27 -30
  6. nuitka/OptionParsing.py +32 -30
  7. nuitka/Options.py +26 -13
  8. nuitka/OutputDirectories.py +7 -4
  9. nuitka/PostProcessing.py +9 -7
  10. nuitka/Progress.py +3 -3
  11. nuitka/PythonVersions.py +2 -2
  12. nuitka/TreeXML.py +1 -1
  13. nuitka/Version.py +1 -1
  14. nuitka/build/Backend.scons +2 -1
  15. nuitka/build/DataComposerInterface.py +1 -0
  16. nuitka/build/Onefile.scons +2 -1
  17. nuitka/build/SconsCaching.py +64 -46
  18. nuitka/build/SconsCompilerSettings.py +19 -6
  19. nuitka/build/SconsHacks.py +0 -1
  20. nuitka/build/SconsInterface.py +84 -5
  21. nuitka/build/SconsProgress.py +0 -1
  22. nuitka/build/SconsUtils.py +8 -4
  23. nuitka/build/include/nuitka/allocator.h +8 -3
  24. nuitka/build/include/nuitka/compiled_cell.h +8 -0
  25. nuitka/build/include/nuitka/exceptions.h +554 -179
  26. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  27. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  28. nuitka/build/include/nuitka/helper/ints.h +15 -2
  29. nuitka/build/include/nuitka/helper/lists.h +4 -1
  30. nuitka/build/include/nuitka/helper/raising.h +12 -0
  31. nuitka/build/include/nuitka/helper/tuples.h +5 -1
  32. nuitka/build/include/nuitka/helpers.h +4 -0
  33. nuitka/build/include/nuitka/importing.h +3 -4
  34. nuitka/build/include/nuitka/jit_sources.h +25 -0
  35. nuitka/build/include/nuitka/prelude.h +38 -11
  36. nuitka/build/include/nuitka/printing.h +3 -0
  37. nuitka/build/include/nuitka/threading.h +2 -6
  38. nuitka/build/include/nuitka/type_aliases.h +27 -0
  39. nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +0 -3
  40. nuitka/build/inline_copy/tqdm/tqdm/version.py +1 -4
  41. nuitka/build/static_src/CompiledAsyncgenType.c +99 -114
  42. nuitka/build/static_src/CompiledCodeHelpers.c +24 -14
  43. nuitka/build/static_src/CompiledCoroutineType.c +96 -114
  44. nuitka/build/static_src/CompiledFrameType.c +14 -11
  45. nuitka/build/static_src/CompiledFunctionType.c +34 -7
  46. nuitka/build/static_src/CompiledGeneratorType.c +248 -142
  47. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +60 -70
  48. nuitka/build/static_src/CompiledMethodType.c +8 -7
  49. nuitka/build/static_src/HelpersAttributes.c +2 -19
  50. nuitka/build/static_src/HelpersBuiltin.c +2 -1
  51. nuitka/build/static_src/HelpersComparisonEq.c +32 -18
  52. nuitka/build/static_src/HelpersComparisonGe.c +50 -36
  53. nuitka/build/static_src/HelpersComparisonGt.c +50 -36
  54. nuitka/build/static_src/HelpersComparisonLe.c +50 -36
  55. nuitka/build/static_src/HelpersComparisonLt.c +50 -36
  56. nuitka/build/static_src/HelpersComparisonNe.c +32 -18
  57. nuitka/build/static_src/HelpersDeepcopy.c +6 -8
  58. nuitka/build/static_src/HelpersDictionaries.c +8 -3
  59. nuitka/build/static_src/HelpersExceptions.c +36 -22
  60. nuitka/build/static_src/HelpersFilesystemPaths.c +7 -7
  61. nuitka/build/static_src/HelpersImportHard.c +15 -0
  62. nuitka/build/static_src/HelpersJitSources.c +46 -0
  63. nuitka/build/static_src/HelpersLists.c +40 -0
  64. nuitka/build/static_src/HelpersOperationBinaryAdd.c +66 -66
  65. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +80 -33
  66. nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +16 -13
  67. nuitka/build/static_src/HelpersOperationBinarySub.c +39 -39
  68. nuitka/build/static_src/HelpersOperationInplaceAdd.c +54 -54
  69. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -1
  70. nuitka/build/static_src/HelpersOperationInplaceSub.c +50 -50
  71. nuitka/build/static_src/HelpersProfiling.c +3 -4
  72. nuitka/build/static_src/HelpersRaising.c +62 -1
  73. nuitka/build/static_src/HelpersStrings.c +203 -8
  74. nuitka/build/static_src/HelpersTypes.c +42 -0
  75. nuitka/build/static_src/MainProgram.c +1 -1
  76. nuitka/build/static_src/MetaPathBasedLoader.c +2 -1
  77. nuitka/build/static_src/OnefileBootstrap.c +3 -3
  78. nuitka/code_generation/BinaryOperationHelperDefinitions.py +5 -3
  79. nuitka/code_generation/BuiltinCodes.py +1 -0
  80. nuitka/code_generation/CodeGeneration.py +11 -0
  81. nuitka/code_generation/CodeHelpers.py +5 -3
  82. nuitka/code_generation/CodeObjectCodes.py +10 -6
  83. nuitka/code_generation/ComparisonCodes.py +19 -3
  84. nuitka/code_generation/ConstantCodes.py +5 -0
  85. nuitka/code_generation/Contexts.py +22 -6
  86. nuitka/code_generation/Emission.py +1 -0
  87. nuitka/code_generation/ErrorCodes.py +8 -16
  88. nuitka/code_generation/EvalCodes.py +5 -3
  89. nuitka/code_generation/ExceptionCodes.py +8 -1
  90. nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +1 -0
  91. nuitka/code_generation/FrameCodes.py +5 -3
  92. nuitka/code_generation/FunctionCodes.py +0 -1
  93. nuitka/code_generation/GeneratorCodes.py +3 -3
  94. nuitka/code_generation/GlobalConstants.py +0 -2
  95. nuitka/code_generation/ImportCodes.py +2 -0
  96. nuitka/code_generation/JitCodes.py +44 -0
  97. nuitka/code_generation/ListCodes.py +11 -17
  98. nuitka/code_generation/MatchCodes.py +0 -1
  99. nuitka/code_generation/ModuleCodes.py +2 -1
  100. nuitka/code_generation/Namify.py +0 -1
  101. nuitka/code_generation/NetworkxCodes.py +51 -0
  102. nuitka/code_generation/OperationCodes.py +8 -6
  103. nuitka/code_generation/PackageResourceCodes.py +7 -5
  104. nuitka/code_generation/TensorflowCodes.py +54 -0
  105. nuitka/code_generation/TypeAliasCodes.py +71 -0
  106. nuitka/code_generation/VariableCodes.py +7 -5
  107. nuitka/code_generation/VariableDeclarations.py +1 -0
  108. nuitka/code_generation/c_types/CTypeCLongs.py +0 -1
  109. nuitka/code_generation/c_types/CTypeNuitkaInts.py +0 -1
  110. nuitka/code_generation/c_types/CTypeVoids.py +1 -0
  111. nuitka/code_generation/templates/CodeTemplatesConstants.py +14 -0
  112. nuitka/code_generation/templates/CodeTemplatesExceptions.py +1 -1
  113. nuitka/code_generation/templates/CodeTemplatesIterators.py +0 -1
  114. nuitka/code_generation/templates/CodeTemplatesLoader.py +0 -1
  115. nuitka/code_generation/templates/CodeTemplatesModules.py +4 -1
  116. nuitka/code_generation/templates/CodeTemplatesVariables.py +8 -8
  117. nuitka/code_generation/templates/TemplateDebugWrapper.py +0 -1
  118. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -0
  119. nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +9 -7
  120. nuitka/containers/Namedtuples.py +0 -1
  121. nuitka/finalizations/Finalization.py +1 -0
  122. nuitka/finalizations/FinalizeMarkups.py +0 -1
  123. nuitka/freezer/DllDependenciesMacOS.py +60 -13
  124. nuitka/freezer/DllDependenciesPosix.py +0 -1
  125. nuitka/freezer/IncludedDataFiles.py +46 -15
  126. nuitka/freezer/IncludedEntryPoints.py +5 -3
  127. nuitka/freezer/Standalone.py +6 -1
  128. nuitka/importing/ImportCache.py +2 -2
  129. nuitka/importing/ImportResolving.py +80 -78
  130. nuitka/importing/Importing.py +34 -1
  131. nuitka/nodes/AttributeNodesGenerated.py +21 -6
  132. nuitka/nodes/BuiltinComplexNodes.py +1 -0
  133. nuitka/nodes/BuiltinFormatNodes.py +1 -0
  134. nuitka/nodes/BuiltinIteratorNodes.py +5 -3
  135. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +21 -6
  136. nuitka/nodes/BuiltinRefNodes.py +8 -1
  137. nuitka/nodes/BuiltinVarsNodes.py +0 -1
  138. nuitka/nodes/ChildrenHavingMixins.py +906 -186
  139. nuitka/nodes/CodeObjectSpecs.py +1 -1
  140. nuitka/nodes/ConstantRefNodes.py +38 -0
  141. nuitka/nodes/CtypesNodes.py +0 -1
  142. nuitka/nodes/DictionaryNodes.py +0 -1
  143. nuitka/nodes/ExceptionNodes.py +10 -0
  144. nuitka/nodes/ExpressionBases.py +15 -9
  145. nuitka/nodes/ExpressionBasesGenerated.py +32 -15
  146. nuitka/nodes/FunctionNodes.py +50 -5
  147. nuitka/nodes/HardImportNodesGenerated.py +245 -60
  148. nuitka/nodes/ImportHardNodes.py +27 -13
  149. nuitka/nodes/ImportNodes.py +90 -70
  150. nuitka/nodes/InjectCNodes.py +0 -1
  151. nuitka/nodes/ModuleNodes.py +10 -5
  152. nuitka/nodes/NetworkxNodes.py +45 -0
  153. nuitka/nodes/OperatorNodesUnary.py +1 -0
  154. nuitka/nodes/OsSysNodes.py +0 -1
  155. nuitka/nodes/PackageMetadataNodes.py +0 -1
  156. nuitka/nodes/PackageResourceNodes.py +10 -6
  157. nuitka/nodes/StatementBasesGenerated.py +107 -60
  158. nuitka/nodes/StringConcatenationNodes.py +1 -0
  159. nuitka/nodes/TensorflowNodes.py +38 -0
  160. nuitka/nodes/TypeNodes.py +21 -0
  161. nuitka/nodes/VariableRefNodes.py +1 -0
  162. nuitka/nodes/shapes/BuiltinTypeShapes.py +25 -15
  163. nuitka/optimizations/Optimization.py +7 -6
  164. nuitka/optimizations/OptimizeBuiltinCalls.py +11 -9
  165. nuitka/optimizations/Tags.py +0 -1
  166. nuitka/optimizations/TraceCollections.py +6 -55
  167. nuitka/optimizations/ValueTraces.py +49 -1
  168. nuitka/plugins/PluginBase.py +26 -4
  169. nuitka/plugins/Plugins.py +49 -12
  170. nuitka/plugins/standard/AntiBloatPlugin.py +12 -2
  171. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +0 -1
  172. nuitka/plugins/standard/DataFilesPlugin.py +2 -6
  173. nuitka/plugins/standard/DillPlugin.py +3 -3
  174. nuitka/plugins/standard/DllFilesPlugin.py +29 -23
  175. nuitka/plugins/standard/GiPlugin.py +1 -0
  176. nuitka/plugins/standard/ImplicitImports.py +8 -7
  177. nuitka/plugins/standard/MatplotlibPlugin.py +1 -0
  178. nuitka/plugins/standard/OptionsNannyPlugin.py +3 -7
  179. nuitka/plugins/standard/PkgResourcesPlugin.py +0 -1
  180. nuitka/plugins/standard/PmwPlugin.py +10 -9
  181. nuitka/plugins/standard/PySidePyQtPlugin.py +0 -28
  182. nuitka/plugins/standard/TensorflowPlugin.py +1 -0
  183. nuitka/plugins/standard/TorchPlugin.py +1 -0
  184. nuitka/plugins/standard/TrioPlugin.py +1 -0
  185. nuitka/plugins/standard/standard.nuitka-package.config.yml +242 -34
  186. nuitka/reports/CompilationReportReader.py +0 -1
  187. nuitka/reports/Reports.py +49 -5
  188. nuitka/specs/BuiltinParameterSpecs.py +10 -2
  189. nuitka/specs/BuiltinStrOperationSpecs.py +1 -1
  190. nuitka/specs/BuiltinTypeOperationSpecs.py +0 -1
  191. nuitka/specs/HardImportSpecs.py +34 -1
  192. nuitka/specs/ParameterSpecs.py +11 -9
  193. nuitka/tools/environments/Virtualenv.py +0 -1
  194. nuitka/tools/specialize/CTypeDescriptions.py +15 -11
  195. nuitka/tools/specialize/SpecializeC.py +11 -9
  196. nuitka/tools/specialize/SpecializePython.py +57 -30
  197. nuitka/tools/testing/Common.py +24 -7
  198. nuitka/tools/testing/OutputComparison.py +4 -0
  199. nuitka/tools/testing/Pythons.py +0 -1
  200. nuitka/tools/testing/compare_with_cpython/__main__.py +0 -4
  201. nuitka/tools/watch/GitHub.py +4 -1
  202. nuitka/tools/watch/__main__.py +22 -1
  203. nuitka/tree/Building.py +3 -0
  204. nuitka/tree/InternalModule.py +0 -1
  205. nuitka/tree/ReformulationAssertStatements.py +1 -0
  206. nuitka/tree/ReformulationAssignmentStatements.py +26 -3
  207. nuitka/tree/ReformulationClasses3.py +23 -26
  208. nuitka/tree/ReformulationContractionExpressions.py +5 -3
  209. nuitka/tree/ReformulationDictionaryCreation.py +6 -5
  210. nuitka/tree/ReformulationExecStatements.py +8 -6
  211. nuitka/tree/ReformulationFunctionStatements.py +10 -6
  212. nuitka/tree/SourceHandling.py +8 -0
  213. nuitka/tree/TreeHelpers.py +6 -3
  214. nuitka/utils/AppDirs.py +6 -2
  215. nuitka/utils/CStrings.py +1 -1
  216. nuitka/utils/CommandLineOptions.py +0 -1
  217. nuitka/utils/Distributions.py +3 -3
  218. nuitka/utils/Download.py +5 -1
  219. nuitka/utils/Execution.py +6 -3
  220. nuitka/utils/FileOperations.py +61 -34
  221. nuitka/utils/Importing.py +4 -4
  222. nuitka/utils/InstanceCounters.py +1 -0
  223. nuitka/utils/MacOSApp.py +1 -0
  224. nuitka/utils/Shebang.py +1 -0
  225. nuitka/utils/Utils.py +39 -1
  226. nuitka/utils/WindowsFileUsage.py +4 -3
  227. {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.1.data}/scripts/nuitka-run.bat +0 -0
  228. {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.1.data}/scripts/nuitka.bat +0 -0
  229. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.1.dist-info}/LICENSE.txt +0 -0
  230. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.1.dist-info}/WHEEL +0 -0
  231. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.1.dist-info}/entry_points.txt +0 -0
  232. {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,51 @@
1
+ # Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+
4
+ """ Code generation for networkx module specific stuff. """
5
+
6
+ from .BuiltinCodes import getBuiltinCallViaSpecCode
7
+ from .ImportCodes import getImportModuleNameHardCode
8
+ from .JitCodes import addUncompiledFunctionSourceDict
9
+
10
+
11
+ def generateNetworkxUtilsDecoratorsArgmapCallCode(to_name, expression, emit, context):
12
+ """This is for networkx.utils.decorators.argmap calls."""
13
+
14
+ # TODO: Have global cached forms of hard attribute lookup results too.
15
+ argmap_class_name = context.allocateTempName("argmap_class", unique=True)
16
+
17
+ getImportModuleNameHardCode(
18
+ to_name=argmap_class_name,
19
+ module_name="networkx.utils.decorators",
20
+ import_name="argmap",
21
+ needs_check=False,
22
+ emit=emit,
23
+ context=context,
24
+ )
25
+
26
+ addUncompiledFunctionSourceDict(func_value=expression.subnode_func, context=context)
27
+
28
+ getBuiltinCallViaSpecCode(
29
+ spec=expression.spec,
30
+ called_name=argmap_class_name,
31
+ to_name=to_name,
32
+ expression=expression,
33
+ emit=emit,
34
+ context=context,
35
+ )
36
+
37
+
38
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
39
+ # integrates with CPython, but also works on its own.
40
+ #
41
+ # Licensed under the Apache License, Version 2.0 (the "License");
42
+ # you may not use this file except in compliance with the License.
43
+ # You may obtain a copy of the License at
44
+ #
45
+ # http://www.apache.org/licenses/LICENSE-2.0
46
+ #
47
+ # Unless required by applicable law or agreed to in writing, software
48
+ # distributed under the License is distributed on an "AS IS" BASIS,
49
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50
+ # See the License for the specific language governing permissions and
51
+ # limitations under the License.
@@ -104,12 +104,14 @@ def _getBinaryOperationCode(
104
104
  ) = decideExpressionCTypes(
105
105
  left=left,
106
106
  right=right,
107
- may_swap_arguments="never"
108
- if inplace
109
- else (
110
- "number"
111
- if operator in ("Add", "Mult", "BitOr", "BitAnd", "BitXor")
112
- else "never"
107
+ may_swap_arguments=(
108
+ "never"
109
+ if inplace
110
+ else (
111
+ "number"
112
+ if operator in ("Add", "Mult", "BitOr", "BitAnd", "BitXor")
113
+ else "never"
114
+ )
113
115
  ),
114
116
  )
115
117
 
@@ -520,11 +520,13 @@ def generatePkgResourcesIterEntryPointsCallCode(to_name, expression, emit, conte
520
520
  called_name=iter_entry_points_function_name,
521
521
  expression=expression,
522
522
  arg_names=(
523
- group_arg_name,
524
- name_arg_name,
525
- )
526
- if name_arg_name is not None
527
- else (group_arg_name,),
523
+ (
524
+ group_arg_name,
525
+ name_arg_name,
526
+ )
527
+ if name_arg_name is not None
528
+ else (group_arg_name,)
529
+ ),
528
530
  emit=emit,
529
531
  context=context,
530
532
  )
@@ -0,0 +1,54 @@
1
+ # Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+
4
+ """ Code generation for tensorflow module specific stuff. """
5
+
6
+ from .BuiltinCodes import getBuiltinCallViaSpecCode
7
+ from .ImportCodes import getImportModuleNameHardCode
8
+ from .JitCodes import addUncompiledFunctionSourceDict
9
+
10
+
11
+ def generateTensorflowFunctionCallCode(to_name, expression, emit, context):
12
+ """This is for tensorflow.function calls."""
13
+
14
+ # TODO: Have global cached forms of hard attribute lookup results too.
15
+ tensorflow_function_name = context.allocateTempName(
16
+ "tensorflow_function", unique=True
17
+ )
18
+
19
+ getImportModuleNameHardCode(
20
+ to_name=tensorflow_function_name,
21
+ module_name="tensorflow",
22
+ import_name="function",
23
+ needs_check=False,
24
+ emit=emit,
25
+ context=context,
26
+ )
27
+
28
+ # Include source code of "tensorflow.function" decorated functions.
29
+ addUncompiledFunctionSourceDict(func_value=expression.subnode_func, context=context)
30
+
31
+ getBuiltinCallViaSpecCode(
32
+ spec=expression.spec,
33
+ called_name=tensorflow_function_name,
34
+ to_name=to_name,
35
+ expression=expression,
36
+ emit=emit,
37
+ context=context,
38
+ )
39
+
40
+
41
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
42
+ # integrates with CPython, but also works on its own.
43
+ #
44
+ # Licensed under the Apache License, Version 2.0 (the "License");
45
+ # you may not use this file except in compliance with the License.
46
+ # You may obtain a copy of the License at
47
+ #
48
+ # http://www.apache.org/licenses/LICENSE-2.0
49
+ #
50
+ # Unless required by applicable law or agreed to in writing, software
51
+ # distributed under the License is distributed on an "AS IS" BASIS,
52
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ # See the License for the specific language governing permissions and
54
+ # limitations under the License.
@@ -0,0 +1,71 @@
1
+ # Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+
4
+ """ Code generation for type alias statement helpers.
5
+
6
+ """
7
+
8
+ from .CodeHelpers import (
9
+ generateChildExpressionCode,
10
+ withObjectCodeTemporaryAssignment,
11
+ )
12
+ from .ErrorCodes import getErrorExitCode
13
+ from .TupleCodes import getTupleCreationCode
14
+
15
+
16
+ def generateTypeAliasCode(to_name, expression, emit, context):
17
+ type_params_name = context.allocateTempName("type_params_value")
18
+ getTupleCreationCode(
19
+ to_name=type_params_name,
20
+ elements=expression.subnode_type_params,
21
+ emit=emit,
22
+ context=context,
23
+ )
24
+
25
+ compute_value_name = generateChildExpressionCode(
26
+ expression=expression.subnode_compute_value, emit=emit, context=context
27
+ )
28
+
29
+ assert (
30
+ expression.getParent().isStatementAssignmentVariable()
31
+ ), expression.getParent()
32
+ type_alias_name = expression.getParent().getVariableName()
33
+
34
+ with withObjectCodeTemporaryAssignment(
35
+ to_name, "type_alias_value", expression, emit, context
36
+ ) as value_name:
37
+ emit(
38
+ "%s = MAKE_TYPE_ALIAS(%s, %s, %s);"
39
+ % (
40
+ value_name,
41
+ context.getConstantCode(constant=type_alias_name),
42
+ type_params_name,
43
+ compute_value_name,
44
+ )
45
+ )
46
+
47
+ getErrorExitCode(
48
+ check_name=value_name,
49
+ release_names=(type_alias_name, compute_value_name),
50
+ emit=emit,
51
+ context=context,
52
+ needs_check=expression.mayRaiseExceptionOperation(),
53
+ )
54
+
55
+ context.addCleanupTempName(value_name)
56
+
57
+
58
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
59
+ # integrates with CPython, but also works on its own.
60
+ #
61
+ # Licensed under the Apache License, Version 2.0 (the "License");
62
+ # you may not use this file except in compliance with the License.
63
+ # You may obtain a copy of the License at
64
+ #
65
+ # http://www.apache.org/licenses/LICENSE-2.0
66
+ #
67
+ # Unless required by applicable law or agreed to in writing, software
68
+ # distributed under the License is distributed on an "AS IS" BASIS,
69
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70
+ # See the License for the specific language governing permissions and
71
+ # limitations under the License.
@@ -110,11 +110,13 @@ if (unlikely(%(value_name)s == NULL)) {
110
110
  }
111
111
  """
112
112
  % {
113
- "helper_code": "GET_MODULE_VARIABLE_VALUE_FALLBACK_IN_FUNCTION"
114
- if python_version < 0x340
115
- and not owner.isCompiledPythonModule()
116
- and not owner.isExpressionClassBodyBase()
117
- else "GET_MODULE_VARIABLE_VALUE_FALLBACK",
113
+ "helper_code": (
114
+ "GET_MODULE_VARIABLE_VALUE_FALLBACK_IN_FUNCTION"
115
+ if python_version < 0x340
116
+ and not owner.isCompiledPythonModule()
117
+ and not owner.isExpressionClassBodyBase()
118
+ else "GET_MODULE_VARIABLE_VALUE_FALLBACK"
119
+ ),
118
120
  "module_identifier": context.getModuleCodeName(),
119
121
  "value_name": value_name,
120
122
  "var_name": context.getConstantCode(constant=variable.getName()),
@@ -5,6 +5,7 @@
5
5
  Holds the information necessary to make C code declarations related to a variable.
6
6
 
7
7
  """
8
+
8
9
  from contextlib import contextmanager
9
10
 
10
11
  from .c_types.CTypeBooleans import CTypeBool
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  from .CTypeBases import CTypeBase
10
9
 
11
10
 
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  from nuitka.code_generation.templates.CodeTemplatesVariables import (
10
9
  template_release_object_clear,
11
10
  template_release_object_unclear,
@@ -4,6 +4,7 @@
4
4
  """ CType classes for C void, this cannot represent unassigned, nor indicate exception.
5
5
 
6
6
  """
7
+
7
8
  from nuitka.code_generation.ErrorCodes import getReleaseCode
8
9
 
9
10
  from .CTypeBases import CTypeBase, CTypeNotReferenceCountedMixin
@@ -127,6 +127,7 @@ static void _createGlobalConstants(PyThreadState *tstate) {
127
127
  {(char *)"no_docstrings", (char *)"boolean indicating --python-flag=no_docstrings usage"},
128
128
  {(char *)"no_annotations", (char *)"boolean indicating --python-flag=no_annotations usage"},
129
129
  {(char *)"module", (char *)"boolean indicating --module usage"},
130
+ {(char *)"main", (char *)"name of main module at runtime"},
130
131
  {0}
131
132
  };
132
133
 
@@ -211,6 +212,19 @@ static void _createGlobalConstants(PyThreadState *tstate) {
211
212
  #endif
212
213
  PyStructSequence_SET_ITEM(Nuitka_dunder_compiled_value, 11, is_module_mode);
213
214
 
215
+ #ifdef _NUITKA_MODULE
216
+ PyObject *main_name;
217
+
218
+ if (_Py_PackageContext != NULL) {
219
+ main_name = Nuitka_String_FromString(_Py_PackageContext);
220
+ } else {
221
+ main_name = Nuitka_String_FromString(%(module_name_cstr)s);
222
+ }
223
+ #else
224
+ PyObject *main_name = Nuitka_String_FromString("__main__");
225
+ #endif
226
+ PyStructSequence_SET_ITEM(Nuitka_dunder_compiled_value, 12, main_name);
227
+
214
228
  // Prevent users from creating the Nuitka version type object.
215
229
  Nuitka_VersionInfoType.tp_init = NULL;
216
230
  Nuitka_VersionInfoType.tp_new = NULL;
@@ -56,7 +56,7 @@ if (%(condition)s) {
56
56
  template_error_format_name_error_exception = """\
57
57
  if (unlikely(%(condition)s)) {
58
58
  %(release_temps)s
59
- %(set_exception)s
59
+ %(raise_name_error_helper)s(tstate, %(variable_name)s, &%(exception_type)s, &%(exception_value)s);
60
60
 
61
61
  %(line_number_code)s
62
62
  %(var_description_code)s
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  template_iterator_check = """\
10
9
  // Check if iterator has left-over elements.
11
10
  CHECK_OBJECT(%(iterator_name)s); assert(HAS_ITERNEXT(%(iterator_name)s));
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  template_metapath_loader_compiled_module_entry = """\
10
9
  {%(module_name)s, modulecode_%(module_identifier)s, 0, 0, %(flags)s
11
10
  #if defined(_NUITKA_FREEZER_HAS_FILE_PATH)
@@ -451,8 +451,11 @@ PyObject *modulecode_%(module_identifier)s(PyThreadState *tstate, PyObject *modu
451
451
  // Temp variables if any
452
452
  %(temps_decl)s
453
453
 
454
+ // Module init code if any
455
+ %(module_init_codes)s
456
+
454
457
  // Module code.
455
- %(module_code)s
458
+ %(module_codes)s
456
459
 
457
460
  // Report to PGO about leaving the module without error.
458
461
  PGO_onModuleExit("%(module_identifier)s", false);
@@ -45,7 +45,7 @@ template_write_local_inplace = """\
45
45
  """
46
46
 
47
47
  template_write_shared_inplace = """\
48
- PyCell_SET(%(identifier)s, %(tmp_name)s);
48
+ Nuitka_Cell_SET(%(identifier)s, %(tmp_name)s);
49
49
  """
50
50
 
51
51
 
@@ -62,7 +62,7 @@ template_write_local_clear_ref1 = """\
62
62
  template_write_shared_unclear_ref0 = """\
63
63
  {
64
64
  PyObject *old = Nuitka_Cell_GET(%(identifier)s);
65
- PyCell_SET(%(identifier)s, %(tmp_name)s);
65
+ Nuitka_Cell_SET(%(identifier)s, %(tmp_name)s);
66
66
  Py_XDECREF(old);
67
67
  }
68
68
  """
@@ -70,7 +70,7 @@ template_write_shared_unclear_ref0 = """\
70
70
  template_write_shared_unclear_ref1 = """\
71
71
  {
72
72
  PyObject *old = Nuitka_Cell_GET(%(identifier)s);
73
- PyCell_SET(%(identifier)s, %(tmp_name)s);
73
+ Nuitka_Cell_SET(%(identifier)s, %(tmp_name)s);
74
74
  Py_INCREF(%(tmp_name)s);
75
75
  Py_XDECREF(old);
76
76
  }
@@ -78,13 +78,13 @@ template_write_shared_unclear_ref1 = """\
78
78
 
79
79
  template_write_shared_clear_ref0 = """\
80
80
  assert(Nuitka_Cell_GET(%(identifier)s) == NULL);
81
- PyCell_SET(%(identifier)s, %(tmp_name)s);
81
+ Nuitka_Cell_SET(%(identifier)s, %(tmp_name)s);
82
82
  """
83
83
 
84
84
  template_write_shared_clear_ref1 = """\
85
85
  assert(Nuitka_Cell_GET(%(identifier)s) == NULL);
86
86
  Py_INCREF(%(tmp_name)s);
87
- PyCell_SET(%(identifier)s, %(tmp_name)s);
87
+ Nuitka_Cell_SET(%(identifier)s, %(tmp_name)s);
88
88
  """
89
89
 
90
90
 
@@ -96,7 +96,7 @@ Py_XDECREF(%(identifier)s);
96
96
  template_del_shared_tolerant = """\
97
97
  {
98
98
  PyObject *old = Nuitka_Cell_GET(%(identifier)s);
99
- PyCell_SET(%(identifier)s, NULL);
99
+ Nuitka_Cell_SET(%(identifier)s, NULL);
100
100
  Py_XDECREF(old);
101
101
  }
102
102
  """
@@ -112,7 +112,7 @@ if (likely(%(result)s)) {
112
112
  template_del_shared_intolerant = """\
113
113
  {
114
114
  PyObject *old = Nuitka_Cell_GET(%(identifier)s);
115
- PyCell_SET(%(identifier)s, NULL);
115
+ Nuitka_Cell_SET(%(identifier)s, NULL);
116
116
  Py_XDECREF(old);
117
117
 
118
118
  %(result)s = old != NULL;
@@ -128,7 +128,7 @@ Py_DECREF(%(identifier)s);
128
128
  template_del_shared_known = """\
129
129
  {
130
130
  PyObject *old = Nuitka_Cell_GET(%(identifier)s);
131
- PyCell_SET(%(identifier)s, NULL);
131
+ Nuitka_Cell_SET(%(identifier)s, NULL);
132
132
 
133
133
  CHECK_OBJECT(old);
134
134
  Py_DECREF(old);
@@ -6,7 +6,6 @@
6
6
  This wraps strings with a class derived from "str" that does more checks.
7
7
  """
8
8
 
9
-
10
9
  from nuitka import Options
11
10
  from nuitka.__past__ import iterItems
12
11
  from nuitka.Tracing import optimization_logger
@@ -30,20 +30,24 @@ static {{target.getTypeDecl()}} COMPARE_{{op_code}}_{{target.getHelperCodeName()
30
30
  r = false;
31
31
  } else {
32
32
  int kind1 = PyUnicode_KIND(a);
33
+ #if PYTHON_VERSION < 0x3c0
33
34
  if (unlikely(kind1 == 0)) {
34
35
  NUITKA_MAY_BE_UNUSED int res = _PyUnicode_Ready((PyObject *)a);
35
36
  assert(res != -1);
36
37
  kind1 = PyUnicode_KIND(a);
37
38
  assert(kind1 != 0);
38
39
  }
40
+ #endif
39
41
 
40
42
  int kind2 = PyUnicode_KIND(b);
43
+ #if PYTHON_VERSION < 0x3c0
41
44
  if (unlikely(kind2 == 0)) {
42
45
  NUITKA_MAY_BE_UNUSED int res = _PyUnicode_Ready((PyObject *)b);
43
46
  assert(res != -1);
44
47
  kind2 = PyUnicode_KIND(b);
45
48
  assert(kind2 != 0);
46
49
  }
50
+ #endif
47
51
 
48
52
  if (kind1 != kind2) {
49
53
  r = false;
@@ -19,11 +19,12 @@
19
19
  {{ declare_long_access(right, operand2) }}
20
20
 
21
21
  if ({{ left.getLongValueDigitCountExpression("operand1")}} <= 1 && {{ right.getLongValueDigitCountExpression("operand2")}} <= 1) {
22
- long r = {{ left.getLongValueMediumValueExpression("operand1") }} + {{ right.getLongValueMediumValueExpression("operand2") }};
22
+ {# TODO: Double digits are not handled efficiently for Python3.12 #}
23
+ long r = (long)({{ left.getLongValueMediumValueExpression("operand1") }} + {{ right.getLongValueMediumValueExpression("operand2") }});
23
24
 
24
25
  {% if target == None and left.hasReferenceCounting() %}
25
26
  if (Py_REFCNT({{operand1}}) == 1) {
26
- Nuitka_LongUpdateFromCLong(&{{operand1}}, r);
27
+ Nuitka_LongUpdateFromCLong(&{{operand1}}, (long)r);
27
28
  {{ goto_exit(props, "exit_result_ok") }}
28
29
  } else {
29
30
  PyObject *obj = Nuitka_LongFromCLong(r);
@@ -45,7 +46,7 @@
45
46
  if (a_negative) {
46
47
  if (b_negative) {
47
48
  {{ operand1 }} = _Nuitka_LongAddInplaceDigits({{ operand1 }}, b_digits, b_digit_count);
48
- Py_SET_SIZE({{ operand1 }}, -Py_ABS(Py_SIZE({{ operand1 }})));
49
+ Nuitka_LongSetSignNegative({{ operand1 }});
49
50
  } else {
50
51
  {# Reversed operands order means sign inversion. #}
51
52
  {{ operand1 }} = _Nuitka_LongSubInplaceDigits({{ operand1 }}, b_digits, b_digit_count, -1);
@@ -75,7 +76,7 @@
75
76
  if (a_negative) {
76
77
  if (b_negative) {
77
78
  z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
78
- Py_SET_SIZE(z, -(Py_SIZE(z)));
79
+ Nuitka_LongFlipSign(z);
79
80
  } else {
80
81
  {# Reversed operands order. #}
81
82
  z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
@@ -95,7 +96,8 @@
95
96
  {{ declare_long_access(right, operand2) }}
96
97
 
97
98
  if ({{ left.getLongValueDigitCountExpression("operand1")}} <= 1 && {{ right.getLongValueDigitCountExpression("operand2")}} <= 1) {
98
- long r = {{ left.getLongValueMediumValueExpression("operand1") }} - {{ right.getLongValueMediumValueExpression("operand2") }};
99
+ {# TODO: Double digits are not handled efficiently for Python3.12 #}
100
+ long r = (long)({{ left.getLongValueMediumValueExpression("operand1") }} - {{ right.getLongValueMediumValueExpression("operand2") }});
99
101
 
100
102
  {% if target == None and left.hasReferenceCounting() %}
101
103
  if (Py_REFCNT({{operand1}}) == 1) {
@@ -124,7 +126,7 @@
124
126
  {{ operand1 }} = _Nuitka_LongSubInplaceDigits({{ operand1 }}, b_digits, b_digit_count, -1);
125
127
  } else {
126
128
  {{ operand1 }} = _Nuitka_LongAddInplaceDigits({{ operand1 }}, b_digits, b_digit_count);
127
- Py_SET_SIZE({{ operand1 }}, -Py_ABS(Py_SIZE({{ operand1 }})));
129
+ Nuitka_LongSetSignNegative({{ operand1 }});
128
130
  }
129
131
  } else {
130
132
  if (b_negative) {
@@ -155,7 +157,7 @@
155
157
  z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
156
158
  }
157
159
 
158
- Py_SET_SIZE(z, -(Py_SIZE(z)));
160
+ Nuitka_LongFlipSign(z);
159
161
  } else {
160
162
  if (b_negative) {
161
163
  z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
@@ -7,7 +7,6 @@ It works around bugs present in some version of Python, and provides extra
7
7
  methods like "asDict".
8
8
  """
9
9
 
10
-
11
10
  from collections import namedtuple
12
11
 
13
12
 
@@ -8,6 +8,7 @@ can be computed here, so the code generation can be quick and doesn't have to
8
8
  check it many times.
9
9
 
10
10
  """
11
+
11
12
  from nuitka.tree import Operations
12
13
 
13
14
  from .FinalizeMarkups import FinalizeMarkups
@@ -17,7 +17,6 @@ are in another context.
17
17
 
18
18
  """
19
19
 
20
-
21
20
  from nuitka import Tracing
22
21
  from nuitka.__past__ import unicode
23
22
  from nuitka.containers.OrderedSets import OrderedSet
@@ -26,6 +26,7 @@ from nuitka.utils.SharedLibraries import (
26
26
  getOtoolDependencyOutput,
27
27
  getOtoolListing,
28
28
  )
29
+ from nuitka.utils.Utils import getArchitecture
29
30
 
30
31
  from .DllDependenciesCommon import getLdLibraryPath
31
32
 
@@ -50,7 +51,7 @@ def _detectPythonRpaths():
50
51
  if os.path.isdir(candidate):
51
52
  result.append(candidate)
52
53
 
53
- return tuple(result)
54
+ return tuple(set(result))
54
55
 
55
56
 
56
57
  def detectBinaryPathDLLsMacOS(
@@ -93,8 +94,8 @@ def detectBinaryPathDLLsMacOS(
93
94
  original_dir=os.path.dirname(sub_dll_filename),
94
95
  binary_filename=sub_dll_filename,
95
96
  package_name=package_name,
96
- recursive=True,
97
97
  keep_unresolved=True,
98
+ recursive=True,
98
99
  )
99
100
 
100
101
  merged_result.update(sub_result)
@@ -133,6 +134,24 @@ def _parseOtoolListingOutput(output):
133
134
  return paths
134
135
 
135
136
 
137
+ def _getNonVersionedDllFilenames(filename):
138
+ yield filename
139
+
140
+ if getArchitecture() == "arm64" and filename.endswith(".dylib"):
141
+ yield filename[:-6] + "_arm64.dylib"
142
+
143
+ match = re.match(r"^(.*?)(\.\d+)+\.dylib$", filename)
144
+
145
+ if match:
146
+ yield match.group(1) + ".dylib"
147
+
148
+ # TODO: The versioned filename, might do the same, and so could the
149
+ # "x86_64" specific DLL be a thing too, but we should have actual
150
+ # examples to be sure they are covered with tests.
151
+ if getArchitecture() == "arm64":
152
+ yield match.group(1) + "_arm64.dylib"
153
+
154
+
136
155
  def _resolveBinaryPathDLLsMacOS(
137
156
  original_dir, binary_filename, paths, package_specific_dirs, package_name
138
157
  ):
@@ -149,11 +168,17 @@ def _resolveBinaryPathDLLsMacOS(
149
168
  for path in paths:
150
169
  if path.startswith("@rpath/"):
151
170
  # Resolve rpath to just the ones given, first match.
171
+ library_name = path[7:]
172
+
152
173
  for rpath in rpaths:
153
- if os.path.exists(os.path.join(rpath, path[7:])):
174
+ if os.path.exists(os.path.join(rpath, library_name)):
154
175
  resolved_path = os.path.normpath(os.path.join(rpath, path[7:]))
155
176
  break
156
177
  else:
178
+ # These have become virtual in later macOS.
179
+ if library_name in ("libc++.1.dylib", "libz.1.dylib"):
180
+ continue
181
+
157
182
  # This is only a guess, might be missing package specific directories.
158
183
  resolved_path = os.path.normpath(os.path.join(original_dir, path[7:]))
159
184
  elif path.startswith("@loader_path/"):
@@ -189,22 +214,33 @@ def _resolveBinaryPathDLLsMacOS(
189
214
  )
190
215
 
191
216
  # Some extension modules seem to reference themselves by a different
192
- # extension module name, so use that if it exists.
193
- if not os.path.exists(resolved_path) and python_version >= 0x300:
217
+ # extension module name, so use that if it exists, and some versioned
218
+ # DLL dependencies do not matter.
219
+ if python_version >= 0x300:
194
220
  so_suffixes = getSharedLibrarySuffixes()[:-1]
195
221
 
196
222
  specific_suffix = so_suffixes[0]
197
223
  abi_suffix = so_suffixes[1]
198
224
 
199
- if resolved_path.endswith(specific_suffix):
200
- candidate = resolved_path[: -len(specific_suffix)] + abi_suffix
201
- elif resolved_path.endswith(abi_suffix):
202
- candidate = resolved_path[: -len(specific_suffix)] + abi_suffix
203
- else:
204
- candidate = None
225
+ for resolved_path_candidate in _getNonVersionedDllFilenames(resolved_path):
226
+ if os.path.exists(resolved_path_candidate):
227
+ resolved_path = resolved_path_candidate
228
+ break
205
229
 
206
- if candidate is not None and os.path.exists(candidate):
207
- resolved_path = candidate
230
+ if resolved_path_candidate.endswith(specific_suffix):
231
+ candidate = (
232
+ resolved_path_candidate[: -len(specific_suffix)] + abi_suffix
233
+ )
234
+ elif resolved_path_candidate.endswith(abi_suffix):
235
+ candidate = (
236
+ resolved_path_candidate[: -len(specific_suffix)] + abi_suffix
237
+ )
238
+ else:
239
+ candidate = None
240
+
241
+ if candidate is not None and os.path.exists(candidate):
242
+ resolved_path = candidate
243
+ break
208
244
 
209
245
  # Sometimes self-dependencies are on a numbered version, but deployed is
210
246
  # one version without it. The macOS just ignores that, and so we do.
@@ -241,6 +277,17 @@ def _resolveBinaryPathDLLsMacOS(
241
277
  # TODO: Missing DLLs that are accepted, are not really forbidden, we
242
278
  # should instead acknowledge them as missing, and treat that properly
243
279
  # in using code.
280
+ if acceptable is True:
281
+ raise NuitkaForbiddenDLLEncounter(binary_filename, plugin_name)
282
+
283
+ # We check both the user and the used DLL if they are listed. This
284
+ # might be a form of bug hiding, that the later is not sufficient,
285
+ # that we should address later.
286
+ acceptable, plugin_name = Plugins.isAcceptableMissingDLL(
287
+ package_name=package_name,
288
+ filename=resolved_path,
289
+ )
290
+
244
291
  if acceptable is True:
245
292
  raise NuitkaForbiddenDLLEncounter(binary_filename, plugin_name)
246
293