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
@@ -171,6 +171,48 @@ void Nuitka_PyType_Ready(PyTypeObject *type, PyTypeObject *base, bool generic_ge
171
171
  NUITKA_MAY_BE_UNUSED int res = PyType_Ready(type);
172
172
  assert(res >= 0);
173
173
  }
174
+
175
+ #if PYTHON_VERSION >= 0x3c0
176
+
177
+ typedef struct {
178
+ PyObject_HEAD PyObject *name;
179
+ PyObject *type_params;
180
+ PyObject *compute_value;
181
+ PyObject *value;
182
+ PyObject *module;
183
+ } typealiasobject;
184
+
185
+ static PyTypeObject *getTypeAliasType(void) {
186
+ static PyTypeObject *type_alias_type = NULL;
187
+
188
+ if (type_alias_type == NULL) {
189
+
190
+ PyObject *typing_module = PyImport_ImportModule("_typing");
191
+ CHECK_OBJECT(typing_module);
192
+
193
+ type_alias_type = (PyTypeObject *)PyObject_GetAttrString(typing_module, "TypeAliasType");
194
+ CHECK_OBJECT(type_alias_type);
195
+ }
196
+
197
+ return type_alias_type;
198
+ }
199
+
200
+ PyObject *MAKE_TYPE_ALIAS(PyObject *name, PyObject *type_params, PyObject *compute_value) {
201
+ typealiasobject *ta = Nuitka_GC_New(getTypeAliasType());
202
+
203
+ // TODO: Lets follow Python new inline function in the future, this is 3.12
204
+ // only code, so we can use it here.
205
+ ta->name = Py_NewRef(name);
206
+ ta->type_params = Py_IsNone(type_params) ? NULL : Py_XNewRef(type_params);
207
+ ta->compute_value = Py_XNewRef(compute_value);
208
+ ta->value = NULL;
209
+ ta->module = NULL;
210
+
211
+ Nuitka_GC_Track(ta);
212
+
213
+ return (PyObject *)ta;
214
+ }
215
+ #endif
174
216
  // Part of "Nuitka", an optimizing Python compiler that is compatible and
175
217
  // integrates with CPython, but also works on its own.
176
218
  //
@@ -191,7 +191,7 @@ extern void _initCompiledFrameType();
191
191
  static wchar_t **convertCommandLineParameters(int argc, char **argv) {
192
192
  // Originally taken from CPython3: There seems to be no sane way to use
193
193
  static wchar_t **argv_copy;
194
- argv_copy = (wchar_t **)PyMem_MALLOC(sizeof(wchar_t *) * argc);
194
+ argv_copy = (wchar_t **)malloc(sizeof(wchar_t *) * argc);
195
195
 
196
196
  // Temporarily disable locale for conversions to not use it.
197
197
  char *old_locale = strdup(setlocale(LC_ALL, NULL));
@@ -200,8 +200,9 @@ static PyObject *loadModuleFromCodeObject(PyObject *module, PyCodeObject *code_o
200
200
  if (is_package) {
201
201
  /* Set __path__ properly, unlike frozen module importer does. */
202
202
  PyObject *path_list = MAKE_LIST_EMPTY(1);
203
- if (unlikely(path_list == NULL))
203
+ if (unlikely(path_list == NULL)) {
204
204
  return NULL;
205
+ }
205
206
 
206
207
  int res = PyList_SetItem(path_list, 0, module_path_entry);
207
208
  if (unlikely(res != 0)) {
@@ -65,8 +65,8 @@
65
65
  #define _NUITKA_ONEFILE_CHILD_GRACE_TIME_INT 5000
66
66
  #define _NUITKA_ONEFILE_TEMP_SPEC "{TEMP}/onefile_{PID}_{TIME}"
67
67
 
68
- #define _NUITKA_EXPERIMENTAL_DEBUG_AUTO_UPDATE
69
68
  #define _NUITKA_AUTO_UPDATE_BOOL 1
69
+ #define _NUITKA_AUTO_UPDATE_DEBUG_BOOL 1
70
70
  #define _NUITKA_AUTO_UPDATE_URL_SPEC "https://..."
71
71
 
72
72
  #endif
@@ -1019,7 +1019,7 @@ int main(int argc, char **argv) {
1019
1019
  signal(SIGTERM, ourConsoleCtrlHandler);
1020
1020
  #endif
1021
1021
 
1022
- #ifdef _NUITKA_AUTO_UPDATE_BOOL
1022
+ #if _NUITKA_AUTO_UPDATE_BOOL
1023
1023
  checkAutoUpdates();
1024
1024
  #endif
1025
1025
 
@@ -1213,7 +1213,7 @@ int main(int argc, char **argv) {
1213
1213
 
1214
1214
  closePayloadData();
1215
1215
 
1216
- #ifdef _NUITKA_AUTO_UPDATE_BOOL
1216
+ #if _NUITKA_AUTO_UPDATE_BOOL
1217
1217
  exe_file_updatable = true;
1218
1218
  #endif
1219
1219
 
@@ -200,9 +200,11 @@ def _makeNumberOps(op_code, include_nbool, in_place):
200
200
  _makeFriendOps(op_code, include_nbool, in_place, "INT", "LONG", "FLOAT"),
201
201
  # Special operations, currently used with constant values mostly.
202
202
  _makeFriendOps(op_code, include_nbool, in_place, "INT", "CLONG"),
203
- _makeFriendOps(op_code, include_nbool, in_place, "LONG", "DIGIT")
204
- if op_code in ("ADD", "SUB") # TODO: Add more
205
- else (),
203
+ (
204
+ _makeFriendOps(op_code, include_nbool, in_place, "LONG", "DIGIT")
205
+ if op_code in ("ADD", "SUB") # TODO: Add more
206
+ else ()
207
+ ),
206
208
  _makeFriendOps(op_code, include_nbool, in_place, "FLOAT", "CFLOAT"),
207
209
  )
208
210
 
@@ -6,6 +6,7 @@
6
6
  This is code generation for built-in references, and some built-ins like range,
7
7
  bin, etc.
8
8
  """
9
+
9
10
  from nuitka import Builtins
10
11
  from nuitka.PythonVersions import python_version
11
12
 
@@ -253,6 +253,7 @@ from .ModuleCodes import (
253
253
  generateNuitkaLoaderCreationCode,
254
254
  getModuleCode,
255
255
  )
256
+ from .NetworkxCodes import generateNetworkxUtilsDecoratorsArgmapCallCode
256
257
  from .OperationCodes import (
257
258
  generateOperationBinaryCode,
258
259
  generateOperationNotCode,
@@ -341,8 +342,10 @@ from .SubscriptCodes import (
341
342
  generateSubscriptCheckCode,
342
343
  generateSubscriptLookupCode,
343
344
  )
345
+ from .TensorflowCodes import generateTensorflowFunctionCallCode
344
346
  from .TryCodes import generateTryCode
345
347
  from .TupleCodes import generateBuiltinTupleCode, generateTupleCreationCode
348
+ from .TypeAliasCodes import generateTypeAliasCode
346
349
  from .VariableCodes import (
347
350
  generateAssignmentVariableCode,
348
351
  generateDelVariableCode,
@@ -667,6 +670,7 @@ addExpressionDispatchDict(
667
670
  "EXPRESSION_BUILTIN_XRANGE3": generateBuiltinXrange3Code,
668
671
  "EXPRESSION_BUILTIN_MAKE_EXCEPTION": generateBuiltinMakeExceptionCode,
669
672
  "EXPRESSION_BUILTIN_MAKE_EXCEPTION_IMPORT_ERROR": generateBuiltinMakeExceptionCode,
673
+ "EXPRESSION_BUILTIN_MAKE_EXCEPTION_MODULE_NOT_FOUND_ERROR": generateBuiltinMakeExceptionCode,
670
674
  "EXPRESSION_BUILTIN_REF": generateBuiltinRefCode,
671
675
  "EXPRESSION_BUILTIN_WITH_CONTEXT_REF": generateBuiltinRefCode,
672
676
  "EXPRESSION_BUILTIN_EXCEPTION_REF": generateExceptionRefCode,
@@ -939,10 +943,17 @@ addExpressionDispatchDict(
939
943
  "EXPRESSION_OS_PATH_ISABS_CALL": generateOsPathIsabsCallCode,
940
944
  "EXPRESSION_OS_LISTDIR_CALL": generateOsListdirCallCode,
941
945
  "EXPRESSION_MATCH_ARGS": generateMatchArgsCode,
946
+ "EXPRESSION_TYPE_ALIAS": generateTypeAliasCode,
942
947
  "EXPRESSION_STR_OPERATION_FORMAT": generateStrFormatMethodCode,
943
948
  # TODO: Should have all of these generically or not. This one is required for now.
944
949
  "EXPRESSION_DICT_OPERATION_FROMKEYS_REF": generateDictOperationFromkeysRefCode,
945
950
  "EXPRESSION_TYPE_OPERATION_PREPARE": generateTypeOperationPrepareCode,
951
+ # PyPI module "tensorflow" specific stuff
952
+ "EXPRESSION_TENSORFLOW_FUNCTION_REF": generateImportModuleNameHardCode,
953
+ "EXPRESSION_TENSORFLOW_FUNCTION_CALL": generateTensorflowFunctionCallCode,
954
+ # PyPI module "networkx" specific stuff
955
+ "EXPRESSION_NETWORKX_UTILS_DECORATORS_ARGMAP_REF": generateImportModuleNameHardCode,
956
+ "EXPRESSION_NETWORKX_UTILS_DECORATORS_ARGMAP_CALL": generateNetworkxUtilsDecoratorsArgmapCallCode,
946
957
  }
947
958
  )
948
959
 
@@ -48,9 +48,11 @@ def generateExpressionCode(to_name, expression, emit, context, allow_none=False)
48
48
  "Problem with %r at %s"
49
49
  % (
50
50
  expression,
51
- ""
52
- if expression is None
53
- else expression.getSourceReference().getAsString(),
51
+ (
52
+ ""
53
+ if expression is None
54
+ else expression.getSourceReference().getAsString()
55
+ ),
54
56
  )
55
57
  )
56
58
  raise
@@ -70,12 +70,16 @@ def _getMakeCodeObjectArgs(code_object_handle, context):
70
70
  " | ".join(co_flags) or "0",
71
71
  context.getConstantCode(constant=code_object_handle.co_name),
72
72
  context.getConstantCode(constant=code_object_handle.co_qualname),
73
- context.getConstantCode(constant=code_object_handle.co_varnames)
74
- if code_object_handle.co_varnames
75
- else "NULL",
76
- context.getConstantCode(constant=code_object_handle.co_freevars)
77
- if code_object_handle.co_freevars
78
- else "NULL",
73
+ (
74
+ context.getConstantCode(constant=code_object_handle.co_varnames)
75
+ if code_object_handle.co_varnames
76
+ else "NULL"
77
+ ),
78
+ (
79
+ context.getConstantCode(constant=code_object_handle.co_freevars)
80
+ if code_object_handle.co_freevars
81
+ else "NULL"
82
+ ),
79
83
  code_object_handle.co_argcount,
80
84
  code_object_handle.co_kwonlyargcount,
81
85
  code_object_handle.co_posonlyargcount,
@@ -7,7 +7,11 @@ Rich comparisons, "in", and "not in", also "is", and "is not", and the
7
7
  "isinstance" check as used in conditions, as well as exception matching.
8
8
  """
9
9
 
10
- from nuitka.nodes.shapes.BuiltinTypeShapes import tshape_bool
10
+ from nuitka.nodes.shapes.BuiltinTypeShapes import (
11
+ tshape_bool,
12
+ tshape_frozenset,
13
+ tshape_set,
14
+ )
11
15
  from nuitka.nodes.shapes.StandardShapes import tshape_unknown
12
16
  from nuitka.PythonOperators import (
13
17
  comparison_inversions,
@@ -279,9 +283,21 @@ def generateComparisonExpressionCode(to_name, expression, emit, context):
279
283
 
280
284
  res_name = context.getIntResName()
281
285
 
286
+ right_shape = right.getTypeShape()
287
+
288
+ if right_shape in (tshape_set, tshape_frozenset):
289
+ c_api = "PySet_Contains"
290
+ else:
291
+ c_api = "PySequence_Contains"
292
+
282
293
  emit(
283
- "%s = PySequence_Contains(%s, %s);"
284
- % (res_name, right_name, left_name) # sequence goes first in the API.
294
+ "%s = %s(%s, %s);"
295
+ % (
296
+ res_name,
297
+ c_api,
298
+ right_name,
299
+ left_name,
300
+ ) # sequence goes first in the API.
285
301
  )
286
302
 
287
303
  getErrorExitBoolCode(
@@ -17,8 +17,10 @@ import os
17
17
  import sys
18
18
 
19
19
  from nuitka import Options
20
+ from nuitka.ModuleRegistry import getRootTopModule
20
21
  from nuitka.PythonVersions import python_version
21
22
  from nuitka.Serialization import ConstantAccessor
23
+ from nuitka.utils.CStrings import encodePythonStringToC
22
24
  from nuitka.utils.Distributions import getDistributionTopLevelPackageNames
23
25
  from nuitka.Version import getNuitkaVersionTuple
24
26
 
@@ -143,6 +145,9 @@ def getConstantsDefinitionCode():
143
145
  major, minor, micro, is_final, _rc_number = getNuitkaVersionTuple()
144
146
 
145
147
  body = template_constants_reading % {
148
+ "module_name_cstr": encodePythonStringToC(
149
+ getRootTopModule().getFullName().asString().encode("utf8")
150
+ ),
146
151
  "global_constants_count": constant_accessor.getConstantsCount(),
147
152
  "sys_executable": sys_executable,
148
153
  "sys_prefix": sys_prefix,
@@ -215,12 +215,12 @@ class TempMixin(object):
215
215
  else:
216
216
  preserver_obj_init = None
217
217
 
218
- self.preserver_variable_declaration[
219
- preserver_id
220
- ] = self.variable_storage.addVariableDeclarationTop(
221
- "struct Nuitka_ExceptionStackItem",
222
- "exception_preserved_%d" % preserver_id,
223
- preserver_obj_init,
218
+ self.preserver_variable_declaration[preserver_id] = (
219
+ self.variable_storage.addVariableDeclarationTop(
220
+ "struct Nuitka_ExceptionStackItem",
221
+ "exception_preserved_%d" % preserver_id,
222
+ preserver_obj_init,
223
+ )
224
224
  )
225
225
 
226
226
  return self.preserver_variable_declaration[preserver_id]
@@ -365,6 +365,10 @@ class PythonContextBase(getMetaClassBase("Context", require_slots=True)):
365
365
  def getConstantCode(self, constant, deep_check=False):
366
366
  pass
367
367
 
368
+ @abstractmethod
369
+ def addModuleInitCode(self, code):
370
+ pass
371
+
368
372
  @abstractmethod
369
373
  def getModuleCodeName(self):
370
374
  pass
@@ -527,6 +531,9 @@ class PythonChildContextBase(PythonContextBase):
527
531
  def getConstantCode(self, constant, deep_check=False):
528
532
  return self.parent.getConstantCode(constant, deep_check=deep_check)
529
533
 
534
+ def addModuleInitCode(self, code):
535
+ self.parent.addModuleInitCode(code)
536
+
530
537
  def getModuleCodeName(self):
531
538
  return self.parent.getModuleCodeName()
532
539
 
@@ -764,6 +771,7 @@ class PythonModuleContext(
764
771
  "variable_storage",
765
772
  "function_table_entries",
766
773
  "constant_accessor",
774
+ "module_init_codes",
767
775
  # FrameDeclarationsMixin
768
776
  "frame_variables_stack",
769
777
  "frame_type_descriptions",
@@ -820,6 +828,8 @@ class PythonModuleContext(
820
828
  top_level_name="mod_consts", data_filename=data_filename
821
829
  )
822
830
 
831
+ self.module_init_codes = []
832
+
823
833
  def __repr__(self):
824
834
  return "<PythonModuleContext instance for module %s>" % self.name
825
835
 
@@ -879,6 +889,12 @@ class PythonModuleContext(
879
889
  def getConstantsCount(self):
880
890
  return self.constant_accessor.getConstantsCount()
881
891
 
892
+ def getModuleInitCodes(self):
893
+ return self.module_init_codes
894
+
895
+ def addModuleInitCode(self, code):
896
+ self.module_init_codes.append(code)
897
+
882
898
  def addFunctionCreationInfo(self, creation_info):
883
899
  self.function_table_entries.append(creation_info)
884
900
 
@@ -8,6 +8,7 @@ this is to collect them, providing the emit implementation. Sometimes nested
8
8
  use of these will occur.
9
9
 
10
10
  """
11
+
11
12
  import contextlib
12
13
 
13
14
  from .Indentation import indented
@@ -247,44 +247,36 @@ def getLocalVariableReferenceErrorCode(variable, condition, emit, context):
247
247
 
248
248
  # TODO: Get rid of this function entirely.
249
249
  def getNameReferenceErrorCode(variable_name, condition, emit, context):
250
- helper_code = "FORMAT_NAME_ERROR"
250
+ helper_code = "RAISE_CURRENT_EXCEPTION_NAME_ERROR"
251
251
 
252
252
  if python_version < 0x340:
253
253
  owner = context.getOwner()
254
254
 
255
255
  if not owner.isCompiledPythonModule() and not owner.isExpressionClassBodyBase():
256
- helper_code = "FORMAT_GLOBAL_NAME_ERROR"
256
+ helper_code = "RAISE_CURRENT_EXCEPTION_GLOBAL_NAME_ERROR"
257
257
 
258
258
  (
259
259
  exception_type,
260
260
  exception_value,
261
- _exception_tb,
261
+ exception_tb,
262
262
  _exception_lineno,
263
263
  ) = context.variable_storage.getExceptionVariableDescriptions()
264
264
 
265
- set_exception = "%s(&%s, &%s, %s);" % (
266
- helper_code,
267
- exception_type,
268
- exception_value,
269
- context.getConstantCode(variable_name),
270
- )
271
-
272
- # TODO: Make this part of the helper code as well.
273
- if python_version >= 0x300:
274
- set_exception = [set_exception]
275
- set_exception.extend(_getExceptionChainingCode(context))
276
-
277
265
  emit(
278
266
  template_error_format_name_error_exception
279
267
  % {
280
268
  "condition": condition,
281
269
  "exception_exit": context.getExceptionEscape(),
282
- "set_exception": indented(set_exception),
270
+ "raise_name_error_helper": helper_code,
271
+ "variable_name": context.getConstantCode(variable_name),
283
272
  "release_temps": indented(getErrorExitReleaseCode(context)),
284
273
  "var_description_code": indented(
285
274
  getFrameVariableTypeDescriptionCode(context)
286
275
  ),
287
276
  "line_number_code": indented(getErrorLineNumberUpdateCode(context)),
277
+ "exception_type": exception_type,
278
+ "exception_value": exception_value,
279
+ "exception_tb": exception_tb,
288
280
  }
289
281
  )
290
282
 
@@ -254,9 +254,11 @@ def generateExecCode(statement, emit, context):
254
254
  # Default filename with origin in improved mode.
255
255
  filename_name.getCType().emitAssignmentCodeFromConstant(
256
256
  to_name=filename_name,
257
- constant="<string>"
258
- if Options.is_full_compat
259
- else "<string at %s>" % source_ref.getAsString(),
257
+ constant=(
258
+ "<string>"
259
+ if Options.is_full_compat
260
+ else "<string at %s>" % source_ref.getAsString()
261
+ ),
260
262
  may_escape=False,
261
263
  emit=emit,
262
264
  context=context,
@@ -193,7 +193,14 @@ def generateBuiltinMakeExceptionCode(to_name, expression, emit, context):
193
193
  context=context,
194
194
  )
195
195
 
196
- if expression.getExceptionName() == "ImportError" and python_version >= 0x300:
196
+ if exception_type == "ImportError" and python_version >= 0x300:
197
+ is_new_import_error = True
198
+ elif exception_type == "ModuleNotFoundError" and python_version >= 0x360:
199
+ is_new_import_error = True
200
+ else:
201
+ is_new_import_error = False
202
+
203
+ if is_new_import_error:
197
204
  from .PythonAPICodes import getReferenceExportCode
198
205
 
199
206
  import_error_name_expression = expression.subnode_name
@@ -7,6 +7,7 @@ This is first used for comparisons and binary operations, but should see
7
7
  general use too and expand beyond constant values, e.g. covering constant
8
8
  values that are of behind conditions or variables.
9
9
  """
10
+
10
11
  from nuitka.nodes.shapes.BuiltinTypeShapes import (
11
12
  tshape_bytearray,
12
13
  tshape_bytes,
@@ -244,9 +244,11 @@ def getFrameGuardHeavyCode(
244
244
  "locals_size": getFrameLocalsStorageSize(
245
245
  context.getFrameVariableTypeDescriptions()
246
246
  ),
247
- "locals_dict_name": frame_node.getLocalsScope().getCodeName()
248
- if use_locals_dict
249
- else "NULL",
247
+ "locals_dict_name": (
248
+ frame_node.getLocalsScope().getCodeName()
249
+ if use_locals_dict
250
+ else "NULL"
251
+ ),
250
252
  }
251
253
  )
252
254
 
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  from nuitka.PythonVersions import python_version
10
9
  from nuitka.Tracing import general
11
10
 
@@ -101,9 +101,9 @@ def getGeneratorObjectCode(
101
101
 
102
102
  if needs_generator_return:
103
103
  generator_exit += template_generator_return_exit % {
104
- "return_value": context.getReturnValueName()
105
- if python_version >= 0x300
106
- else None,
104
+ "return_value": (
105
+ context.getReturnValueName() if python_version >= 0x300 else None
106
+ ),
107
107
  "function_cleanup": indented(function_cleanup),
108
108
  }
109
109
 
@@ -91,8 +91,6 @@ def getConstantDefaultPopulation():
91
91
  # Meta path based loader.
92
92
  "read",
93
93
  "rb",
94
- # List methods
95
- "remove",
96
94
  # File handling
97
95
  "/",
98
96
  "\\",
@@ -230,6 +230,8 @@ def getImportHardModuleGetterCode(module_name, context):
230
230
  def getImportModuleNameHardCode(
231
231
  to_name, module_name, import_name, needs_check, emit, context
232
232
  ):
233
+ module_name = ModuleName(module_name)
234
+
233
235
  if module_name == "sys":
234
236
  emit("""%s = Nuitka_SysGetObject("%s");""" % (to_name, import_name))
235
237
  needs_release = False
@@ -0,0 +1,44 @@
1
+ # Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+
4
+ """ Code generation for JIT specific stuff, preserving source code for runtime. """
5
+
6
+ from nuitka.Options import isStandaloneMode
7
+
8
+
9
+ def addUncompiledFunctionSourceDict(func_value, context):
10
+ if (
11
+ isStandaloneMode()
12
+ and func_value is not None
13
+ and func_value.isExpressionFunctionCreation()
14
+ ):
15
+ function_ref = func_value.subnode_function_ref
16
+
17
+ function_super_qualified_name = function_ref.getFunctionSuperQualifiedName()
18
+ function_source_code = function_ref.getFunctionSourceCode()
19
+
20
+ context.addModuleInitCode(
21
+ """\
22
+ SET_UNCOMPILED_FUNCTION_SOURCE_DICT(%s, %s);
23
+ """
24
+ % (
25
+ context.getConstantCode(function_super_qualified_name),
26
+ context.getConstantCode(function_source_code),
27
+ )
28
+ )
29
+
30
+
31
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
32
+ # integrates with CPython, but also works on its own.
33
+ #
34
+ # Licensed under the Apache License, Version 2.0 (the "License");
35
+ # you may not use this file except in compliance with the License.
36
+ # You may obtain a copy of the License at
37
+ #
38
+ # http://www.apache.org/licenses/LICENSE-2.0
39
+ #
40
+ # Unless required by applicable law or agreed to in writing, software
41
+ # distributed under the License is distributed on an "AS IS" BASIS,
42
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43
+ # See the License for the specific language governing permissions and
44
+ # limitations under the License.
@@ -414,25 +414,19 @@ def generateListOperationRemoveCode(to_name, expression, emit, context):
414
414
  expression=expression, emit=emit, context=context
415
415
  )
416
416
 
417
- with withObjectCodeTemporaryAssignment(
418
- to_name, "list_remove_result", expression, emit, context
419
- ) as result_name:
420
- # TODO: Have a dedicated list helper instead, this could be more efficient,
421
- # this call is also very bad.
422
- emit("assert(PyList_CheckExact(%s));" % list_arg_name)
423
- emit(
424
- "%s = PyObject_CallMethodObjArgs(%s, const_str_plain_remove, %s, NULL);"
425
- % (result_name, list_arg_name, value_arg_name)
426
- )
417
+ res_name = context.getBoolResName()
427
418
 
428
- getErrorExitCode(
429
- check_name=result_name,
430
- release_names=(list_arg_name, value_arg_name),
431
- emit=emit,
432
- context=context,
433
- )
419
+ emit("%s = LIST_REMOVE(%s, %s);" % (res_name, list_arg_name, value_arg_name))
434
420
 
435
- context.addCleanupTempName(result_name)
421
+ getErrorExitBoolCode(
422
+ condition="%s == false" % res_name,
423
+ release_names=(list_arg_name, value_arg_name),
424
+ needs_check=expression.mayRaiseExceptionOperation(),
425
+ emit=emit,
426
+ context=context,
427
+ )
428
+
429
+ assignConstantNoneResult(to_name, emit, context)
436
430
 
437
431
 
438
432
  def generateListOperationSort1Code(to_name, expression, emit, context):
@@ -5,7 +5,6 @@
5
5
 
6
6
  """
7
7
 
8
-
9
8
  from .CodeHelpers import (
10
9
  generateChildExpressionsCode,
11
10
  withObjectCodeTemporaryAssignment,
@@ -131,7 +131,8 @@ def getModuleCode(
131
131
  "module_functions_code": function_body_codes,
132
132
  "module_function_table_entries": indented(function_table_entries_decl),
133
133
  "temps_decl": indented(local_var_inits),
134
- "module_code": indented(module_codes.codes),
134
+ "module_init_codes": indented(context.getModuleInitCodes()),
135
+ "module_codes": indented(module_codes.codes),
135
136
  "module_exit": module_exit,
136
137
  "module_code_objects_decl": indented(module_code_objects_decl, 0),
137
138
  "module_code_objects_init": indented(module_code_objects_init, 1),
@@ -9,7 +9,6 @@ it is really necessary.
9
9
 
10
10
  """
11
11
 
12
-
13
12
  import math
14
13
  import re
15
14
  import sys