Nuitka-winsvc 2.3.11__cp311-cp311-win_amd64.whl → 2.4.5__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 (213) hide show
  1. Nuitka_winsvc-2.3.11.data/scripts/nuitka-run.bat → Nuitka_winsvc-2.4.5.data/scripts/nuitka-run.cmd +1 -1
  2. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.5.dist-info}/METADATA +1 -1
  3. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.5.dist-info}/RECORD +213 -210
  4. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.5.dist-info}/WHEEL +1 -1
  5. nuitka/CacheCleanup.py +6 -1
  6. nuitka/HardImportRegistry.py +30 -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/Progress.py +2 -1
  14. nuitka/PythonFlavors.py +22 -4
  15. nuitka/PythonVersions.py +18 -0
  16. nuitka/Tracing.py +1 -0
  17. nuitka/TreeXML.py +6 -3
  18. nuitka/Version.py +1 -1
  19. nuitka/__main__.py +55 -10
  20. nuitka/__past__.py +5 -0
  21. nuitka/build/Backend.scons +6 -1
  22. nuitka/build/CCompilerVersion.scons +1 -0
  23. nuitka/build/Onefile.scons +4 -0
  24. nuitka/build/SconsCaching.py +2 -1
  25. nuitka/build/SconsCompilerSettings.py +1 -0
  26. nuitka/build/SconsHacks.py +5 -1
  27. nuitka/build/SconsInterface.py +2 -0
  28. nuitka/build/SconsUtils.py +4 -1
  29. nuitka/build/include/nuitka/allocator.h +27 -5
  30. nuitka/build/include/nuitka/calling.h +1 -1
  31. nuitka/build/include/nuitka/compiled_frame.h +23 -23
  32. nuitka/build/include/nuitka/compiled_method.h +1 -1
  33. nuitka/build/include/nuitka/exception_groups.h +0 -2
  34. nuitka/build/include/nuitka/helper/attributes.h +7 -1
  35. nuitka/build/include/nuitka/helper/subscripts.h +1 -1
  36. nuitka/build/include/nuitka/helpers.h +10 -3
  37. nuitka/build/include/nuitka/prelude.h +6 -15
  38. nuitka/build/include/nuitka/printing.h +2 -0
  39. nuitka/build/include/nuitka/unfreezing.h +11 -5
  40. nuitka/build/inline_copy/tqdm/tqdm/_monitor.py +4 -1
  41. nuitka/build/static_src/CompiledAsyncgenType.c +2 -4
  42. nuitka/build/static_src/CompiledCellType.c +7 -7
  43. nuitka/build/static_src/CompiledCodeHelpers.c +49 -36
  44. nuitka/build/static_src/CompiledCoroutineType.c +2 -4
  45. nuitka/build/static_src/CompiledFrameType.c +109 -82
  46. nuitka/build/static_src/CompiledFunctionType.c +36 -9
  47. nuitka/build/static_src/CompiledGeneratorType.c +12 -10
  48. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +2 -2
  49. nuitka/build/static_src/CompiledMethodType.c +14 -13
  50. nuitka/build/static_src/HelpersAttributes.c +13 -15
  51. nuitka/build/static_src/HelpersBuiltin.c +16 -7
  52. nuitka/build/static_src/HelpersCalling.c +13 -13
  53. nuitka/build/static_src/HelpersCallingGenerated.c +22 -22
  54. nuitka/build/static_src/HelpersComparisonEq.c +110 -110
  55. nuitka/build/static_src/HelpersComparisonEqUtils.c +1 -1
  56. nuitka/build/static_src/HelpersComparisonGe.c +110 -110
  57. nuitka/build/static_src/HelpersComparisonGt.c +110 -110
  58. nuitka/build/static_src/HelpersComparisonLe.c +110 -110
  59. nuitka/build/static_src/HelpersComparisonLt.c +110 -110
  60. nuitka/build/static_src/HelpersComparisonNe.c +110 -110
  61. nuitka/build/static_src/HelpersConstantsBlob.c +480 -481
  62. nuitka/build/static_src/HelpersDictionaries.c +9 -0
  63. nuitka/build/static_src/HelpersFilesystemPaths.c +28 -13
  64. nuitka/build/static_src/HelpersImport.c +1 -1
  65. nuitka/build/static_src/HelpersLists.c +5 -1
  66. nuitka/build/static_src/HelpersMatching.c +95 -35
  67. nuitka/build/static_src/HelpersOperationInplaceAdd.c +23 -23
  68. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -0
  69. nuitka/build/static_src/HelpersOperationInplaceBitand.c +11 -11
  70. nuitka/build/static_src/HelpersOperationInplaceBitor.c +11 -11
  71. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +11 -11
  72. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +17 -17
  73. nuitka/build/static_src/HelpersOperationInplaceLshift.c +9 -9
  74. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
  75. nuitka/build/static_src/HelpersOperationInplaceMod.c +47 -47
  76. nuitka/build/static_src/HelpersOperationInplaceMult.c +28 -28
  77. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +17 -17
  78. nuitka/build/static_src/HelpersOperationInplacePow.c +17 -17
  79. nuitka/build/static_src/HelpersOperationInplaceRshift.c +9 -9
  80. nuitka/build/static_src/HelpersOperationInplaceSub.c +17 -17
  81. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +17 -17
  82. nuitka/build/static_src/HelpersSequences.c +1 -1
  83. nuitka/build/static_src/HelpersTypes.c +8 -4
  84. nuitka/build/static_src/InspectPatcher.c +14 -2
  85. nuitka/build/static_src/MainProgram.c +20 -1
  86. nuitka/build/static_src/MetaPathBasedLoader.c +163 -140
  87. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +13 -4
  88. nuitka/build/static_src/OnefileBootstrap.c +100 -6
  89. nuitka/code_generation/AttributeCodes.py +12 -10
  90. nuitka/code_generation/CodeGeneration.py +6 -7
  91. nuitka/code_generation/ConstantCodes.py +53 -10
  92. nuitka/code_generation/Emission.py +1 -1
  93. nuitka/code_generation/GlobalConstants.py +6 -6
  94. nuitka/code_generation/Indentation.py +4 -5
  95. nuitka/code_generation/LoaderCodes.py +3 -0
  96. nuitka/code_generation/LocalsDictCodes.py +36 -14
  97. nuitka/code_generation/MatchCodes.py +23 -4
  98. nuitka/code_generation/ModuleCodes.py +1 -8
  99. nuitka/code_generation/Namify.py +2 -0
  100. nuitka/code_generation/PackageResourceCodes.py +5 -1
  101. nuitka/code_generation/templates/CodeTemplatesConstants.py +22 -4
  102. nuitka/code_generation/templates/CodeTemplatesLoader.py +1 -1
  103. nuitka/code_generation/templates/CodeTemplatesModules.py +27 -9
  104. nuitka/code_generation/templates/CodeTemplatesVariables.py +16 -2
  105. nuitka/code_generation/templates_c/CodeTemplateCallsMethodPositional.c.j2 +2 -2
  106. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +1 -1
  107. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
  108. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +7 -7
  109. nuitka/freezer/DependsExe.py +3 -1
  110. nuitka/freezer/DllDependenciesMacOS.py +5 -12
  111. nuitka/freezer/IncludedDataFiles.py +15 -4
  112. nuitka/freezer/IncludedEntryPoints.py +8 -2
  113. nuitka/freezer/Onefile.py +6 -1
  114. nuitka/freezer/Standalone.py +9 -2
  115. nuitka/importing/Importing.py +14 -5
  116. nuitka/importing/Recursion.py +3 -0
  117. nuitka/nodes/AttributeNodesGenerated.py +21 -12
  118. nuitka/nodes/BuiltinOpenNodes.py +5 -0
  119. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +11 -11
  120. nuitka/nodes/BuiltinRefNodes.py +41 -1
  121. nuitka/nodes/ChildrenHavingMixins.py +143 -355
  122. nuitka/nodes/ClassNodes.py +30 -12
  123. nuitka/nodes/CodeObjectSpecs.py +9 -0
  124. nuitka/nodes/ExpressionBasesGenerated.py +11 -11
  125. nuitka/nodes/FunctionNodes.py +7 -11
  126. nuitka/nodes/FutureSpecs.py +16 -3
  127. nuitka/nodes/GeneratorNodes.py +2 -2
  128. nuitka/nodes/HardImportNodesGenerated.py +11 -134
  129. nuitka/nodes/LocalsScopes.py +19 -23
  130. nuitka/nodes/MatchNodes.py +18 -7
  131. nuitka/nodes/ModuleAttributeNodes.py +1 -20
  132. nuitka/nodes/ModuleNodes.py +23 -6
  133. nuitka/nodes/NodeBases.py +3 -2
  134. nuitka/nodes/NodeMetaClasses.py +26 -10
  135. nuitka/nodes/ReturnNodes.py +1 -1
  136. nuitka/nodes/StatementBasesGenerated.py +11 -11
  137. nuitka/nodes/SubscriptNodes.py +4 -4
  138. nuitka/nodes/VariableAssignNodes.py +1 -1
  139. nuitka/nodes/VariableRefNodes.py +28 -2
  140. nuitka/optimizations/FunctionInlining.py +3 -6
  141. nuitka/optimizations/Optimization.py +13 -12
  142. nuitka/optimizations/TraceCollections.py +19 -4
  143. nuitka/plugins/PluginBase.py +121 -133
  144. nuitka/plugins/Plugins.py +92 -4
  145. nuitka/plugins/YamlPluginBase.py +121 -0
  146. nuitka/plugins/standard/AntiBloatPlugin.py +87 -28
  147. nuitka/plugins/standard/DataFilesPlugin.py +15 -6
  148. nuitka/plugins/standard/DelvewheelPlugin.py +7 -3
  149. nuitka/plugins/standard/DllFilesPlugin.py +5 -3
  150. nuitka/plugins/standard/ImplicitImports.py +34 -20
  151. nuitka/plugins/standard/MatplotlibPlugin.py +3 -1
  152. nuitka/plugins/standard/MultiprocessingPlugin.py +2 -2
  153. nuitka/plugins/standard/OptionsNannyPlugin.py +1 -1
  154. nuitka/plugins/standard/PySidePyQtPlugin.py +11 -12
  155. nuitka/plugins/standard/SpacyPlugin.py +136 -0
  156. nuitka/plugins/standard/standard.nuitka-package.config.yml +489 -182
  157. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +6 -0
  158. nuitka/reports/Reports.py +53 -5
  159. nuitka/specs/BuiltinParameterSpecs.py +1 -1
  160. nuitka/specs/HardImportSpecs.py +0 -6
  161. nuitka/tools/data_composer/DataComposer.py +29 -27
  162. nuitka/tools/environments/CreateEnvironment.py +1 -0
  163. nuitka/tools/environments/Virtualenv.py +25 -11
  164. nuitka/tools/general/find_module/FindModuleCode.py +13 -3
  165. nuitka/tools/onefile_compressor/OnefileCompressor.py +21 -4
  166. nuitka/tools/scanning/DisplayPackageDLLs.py +17 -3
  167. nuitka/tools/specialize/CTypeDescriptions.py +13 -7
  168. nuitka/tools/specialize/SpecializePython.py +18 -1
  169. nuitka/tools/testing/Common.py +19 -6
  170. nuitka/tools/testing/check_reference_counts/__main__.py +1 -1
  171. nuitka/tools/testing/run_nuitka_tests/__main__.py +0 -20
  172. nuitka/tools/watch/AutoStage.py +144 -0
  173. nuitka/tools/watch/__main__.py +79 -32
  174. nuitka/tree/Building.py +105 -104
  175. nuitka/tree/ComplexCallHelperFunctions.py +16 -26
  176. nuitka/tree/InternalModule.py +8 -0
  177. nuitka/tree/ReformulationAssignmentStatements.py +29 -59
  178. nuitka/tree/ReformulationClasses.py +10 -17
  179. nuitka/tree/ReformulationClasses3.py +69 -43
  180. nuitka/tree/ReformulationComparisonExpressions.py +6 -16
  181. nuitka/tree/ReformulationContractionExpressions.py +14 -23
  182. nuitka/tree/ReformulationDictionaryCreation.py +6 -10
  183. nuitka/tree/ReformulationExecStatements.py +10 -10
  184. nuitka/tree/ReformulationForLoopStatements.py +6 -12
  185. nuitka/tree/ReformulationFunctionStatements.py +21 -28
  186. nuitka/tree/ReformulationImportStatements.py +8 -10
  187. nuitka/tree/ReformulationLambdaExpressions.py +3 -6
  188. nuitka/tree/ReformulationMatchStatements.py +166 -60
  189. nuitka/tree/ReformulationMultidist.py +3 -1
  190. nuitka/tree/ReformulationNamespacePackages.py +1 -1
  191. nuitka/tree/ReformulationPrintStatements.py +3 -6
  192. nuitka/tree/ReformulationSequenceCreation.py +13 -26
  193. nuitka/tree/ReformulationTryFinallyStatements.py +15 -0
  194. nuitka/tree/ReformulationWithStatements.py +12 -16
  195. nuitka/tree/SourceHandling.py +13 -8
  196. nuitka/tree/VariableClosure.py +5 -21
  197. nuitka/utils/Distributions.py +80 -11
  198. nuitka/utils/Download.py +38 -31
  199. nuitka/utils/Execution.py +13 -2
  200. nuitka/utils/FileOperations.py +55 -28
  201. nuitka/utils/Images.py +6 -1
  202. nuitka/utils/Importing.py +1 -1
  203. nuitka/utils/ModuleNames.py +11 -5
  204. nuitka/utils/ReExecute.py +17 -13
  205. nuitka/utils/SharedLibraries.py +32 -8
  206. nuitka/utils/Signing.py +3 -1
  207. nuitka/utils/StaticLibraries.py +51 -41
  208. nuitka/utils/Timing.py +1 -1
  209. nuitka/utils/Utils.py +29 -7
  210. /Nuitka_winsvc-2.3.11.data/scripts/nuitka.bat → /Nuitka_winsvc-2.4.5.data/scripts/nuitka.cmd +0 -0
  211. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.5.dist-info}/LICENSE.txt +0 -0
  212. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.5.dist-info}/entry_points.txt +0 -0
  213. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.5.dist-info}/top_level.txt +0 -0
@@ -1121,10 +1121,17 @@ static void nuitka_segfault_handler(int sig) {
1121
1121
  puts("have multiple reasons. Please check https://nuitka.net/info/segfault.html");
1122
1122
  puts("for solutions.");
1123
1123
 
1124
- exit(-SIGSEGV);
1124
+ signal(SIGSEGV, SIG_DFL);
1125
+ raise(SIGSEGV);
1125
1126
  }
1126
1127
  #endif
1127
1128
 
1129
+ #if _NUITKA_NATIVE_WCHAR_ARGV == 1
1130
+ extern wchar_t const *getBinaryFilenameWideChars(bool resolve_symlinks);
1131
+ #else
1132
+ extern char const *getBinaryFilenameHostEncoded(bool resolve_symlinks);
1133
+ #endif
1134
+
1128
1135
  #ifdef _NUITKA_WINMAIN_ENTRY_POINT
1129
1136
  int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpCmdLine, int nCmdShow) {
1130
1137
  /* MSVC, MINGW64 */
@@ -1272,15 +1279,26 @@ int main(int argc, char **argv) {
1272
1279
 
1273
1280
  /* Initial command line handling only. */
1274
1281
 
1282
+ // Make sure, we use the absolute program path for argv[0]
1283
+ #if !defined(_NUITKA_ONEFILE_MODE) && _NUITKA_NATIVE_WCHAR_ARGV == 0
1284
+ argv[0] = (char *)getBinaryFilenameHostEncoded(false);
1285
+ #endif
1286
+
1275
1287
  #if PYTHON_VERSION >= 0x300 && _NUITKA_NATIVE_WCHAR_ARGV == 0
1276
1288
  NUITKA_PRINT_TRACE("main(): Calling convertCommandLineParameters.");
1277
1289
  orig_argv = convertCommandLineParameters(argc, argv);
1278
1290
  #elif PYTHON_VERSION < 0x300 && _NUITKA_NATIVE_WCHAR_ARGV == 1
1291
+ NUITKA_PRINT_TRACE("main(): Calling getCommandLineToArgvA.");
1279
1292
  orig_argv = getCommandLineToArgvA(GetCommandLineA());
1280
1293
  #else
1281
1294
  orig_argv = argv;
1282
1295
  #endif
1283
1296
 
1297
+ // Make sure, we use the absolute program path for argv[0]
1298
+ #if !defined(_NUITKA_ONEFILE_MODE) && _NUITKA_NATIVE_WCHAR_ARGV == 1 && PYTHON_VERSION >= 0x300
1299
+ orig_argv[0] = (wchar_t *)getBinaryFilenameWideChars(false);
1300
+ #endif
1301
+
1284
1302
  // Make sure the compiled path of Python is replaced.
1285
1303
  Py_SetProgramName(orig_argv[0]);
1286
1304
 
@@ -1685,6 +1703,7 @@ orig_argv = argv;
1685
1703
  }
1686
1704
  #endif
1687
1705
  PyDict_DelItemString(Nuitka_GetSysModules(), NUITKA_MAIN_MODULE_NAME);
1706
+ DROP_ERROR_OCCURRED(tstate);
1688
1707
 
1689
1708
  #if _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
1690
1709
  NUITKA_PRINT_TRACE("main(): Calling plugin SvcLaunchService() entry point.");
@@ -174,11 +174,7 @@ static PyObject *_makeDunderPathObject(PyThreadState *tstate, PyObject *module_p
174
174
  return NULL;
175
175
  }
176
176
 
177
- int res = PyList_SetItem(path_list, 0, module_path_entry);
178
- if (unlikely(res != 0)) {
179
- return NULL;
180
- }
181
- Py_INCREF(module_path_entry);
177
+ PyList_SET_ITEM0(path_list, 0, module_path_entry);
182
178
 
183
179
  CHECK_OBJECT(path_list);
184
180
  return path_list;
@@ -256,7 +252,7 @@ static struct Nuitka_MetaPathBasedLoaderEntry *findEntry(char const *name) {
256
252
 
257
253
  while (current->name != NULL) {
258
254
  if ((current->flags & NUITKA_TRANSLATED_FLAG) != 0) {
259
- current->name = UNTRANSLATE(current->name);
255
+ current->name = UN_TRANSLATE(current->name);
260
256
  current->flags -= NUITKA_TRANSLATED_FLAG;
261
257
  }
262
258
 
@@ -284,7 +280,7 @@ static struct Nuitka_MetaPathBasedLoaderEntry *findContainingPackageEntry(char c
284
280
 
285
281
  while (current->name != NULL) {
286
282
  if ((current->flags & NUITKA_TRANSLATED_FLAG) != 0) {
287
- current->name = UNTRANSLATE(current->name);
283
+ current->name = UN_TRANSLATE(current->name);
288
284
  current->flags -= NUITKA_TRANSLATED_FLAG;
289
285
  }
290
286
 
@@ -590,46 +586,18 @@ static PyObject *_nuitka_loader_get_data(PyObject *self, PyObject *args, PyObjec
590
586
  return GET_FILE_BYTES(tstate, filename);
591
587
  }
592
588
 
593
- #ifdef _WIN32
594
- static void setModuleFileValue(PyThreadState *tstate, PyObject *module, wchar_t const *filename) {
595
- #else
596
- static void setModuleFileValue(PyThreadState *tstate, PyObject *module, char const *filename) {
597
- #endif
598
- bool needs_update = false;
599
-
600
- PyObject *existing_file_value = LOOKUP_ATTRIBUTE(tstate, module, const_str_plain___file__);
601
-
602
- #if PYTHON_VERSION < 0x300
603
- if (existing_file_value != NULL) {
604
- if (PyCObject_Check(existing_file_value)) {
605
- PyObject_DelAttr(module, const_str_plain___file__);
606
- existing_file_value = LOOKUP_ATTRIBUTE(tstate, module, const_str_plain___file__);
607
- }
608
- }
609
- #endif
589
+ static void setModuleFileValue(PyThreadState *tstate, PyObject *module, filename_char_t const *filename) {
590
+ CHECK_OBJECT(module);
591
+ assert(filename != NULL);
610
592
 
611
- if (existing_file_value == NULL) {
612
- CLEAR_ERROR_OCCURRED(tstate);
613
- needs_update = true;
614
- } else {
615
- if (existing_file_value == Py_None) {
616
- needs_update = true;
617
- }
593
+ assert(PyModule_Check(module));
618
594
 
619
- Py_DECREF(existing_file_value);
620
- }
595
+ PyObject *dict = PyModule_GetDict(module);
621
596
 
622
- if (needs_update) {
623
- #ifdef _WIN32
624
- int res = SET_ATTRIBUTE(tstate, module, const_str_plain___file__, NuitkaUnicode_FromWideChar(filename, -1));
625
- #else
626
- int res = SET_ATTRIBUTE(tstate, module, const_str_plain___file__, PyUnicode_FromString(filename));
627
- #endif
628
- if (unlikely(res < 0)) {
629
- // Might be refuted, which wouldn't be harmful.
630
- CLEAR_ERROR_OCCURRED(tstate);
631
- }
632
- }
597
+ // TODO: We should have DICT_SET_ITEM0/1 for these things.
598
+ PyObject *new_file_value = Nuitka_String_FromFilename(filename);
599
+ DICT_SET_ITEM(dict, const_str_plain___file__, new_file_value);
600
+ Py_DECREF(new_file_value);
633
601
  }
634
602
 
635
603
  #if PYTHON_VERSION < 0x300
@@ -689,21 +657,55 @@ static void _fillExtensionModuleDllEntryFunctionName(PyThreadState *tstate, char
689
657
  // Append the the entry name from full path module name with dots,
690
658
  // and translate these into directory separators.
691
659
  static void _makeModuleCFilenameValue(filename_char_t *filename, size_t filename_size, char const *module_name_cstr,
692
- PyObject *module_name) {
660
+ PyObject *module_name, bool is_package) {
693
661
  #ifdef _WIN32
694
662
  appendWStringSafeW(filename, getBinaryDirectoryWideChars(true), filename_size);
695
- appendCharSafeW(filename, SEP, filename_size);
663
+ appendWCharSafeW(filename, SEP_L, filename_size);
696
664
  appendModuleNameAsPathW(filename, module_name, filename_size);
665
+ if (is_package) {
666
+ appendWCharSafeW(filename, SEP_L, filename_size);
667
+ appendStringSafeW(filename, "__init__", filename_size);
668
+ }
697
669
  appendStringSafeW(filename, ".pyd", filename_size);
698
670
  #else
699
671
  appendStringSafe(filename, getBinaryDirectoryHostEncoded(true), filename_size);
700
672
  appendCharSafe(filename, SEP, filename_size);
701
673
  appendModuleNameAsPath(filename, module_name_cstr, filename_size);
674
+ if (is_package) {
675
+ appendCharSafe(filename, SEP, filename_size);
676
+ appendStringSafe(filename, "__init__", filename_size);
677
+ }
702
678
  appendStringSafe(filename, ".so", filename_size);
703
679
  #endif
704
680
  }
705
681
  #endif
706
682
 
683
+ #if PYTHON_VERSION >= 0x3c0 && defined(_NUITKA_USE_UNEXPOSED_API)
684
+ extern _Thread_local const char *pkgcontext;
685
+ #endif
686
+
687
+ static const char *NuitkaImport_SwapPackageContext(const char *new_context) {
688
+ // TODO: The locking APIs for 3.13 give errors here that are not explained
689
+ // yet.
690
+ #if PYTHON_VERSION >= 0x3c0 && PYTHON_VERSION < 0x3d0
691
+ // spell-checker: ignore pkgcontext
692
+ const char *old_context = _PyRuntime.imports.pkgcontext;
693
+ _PyRuntime.imports.pkgcontext = new_context;
694
+ #if PYTHON_VERSION >= 0x3c0 && defined(_NUITKA_USE_UNEXPOSED_API)
695
+ pkgcontext = new_context;
696
+ #endif
697
+ return old_context;
698
+ #elif PYTHON_VERSION >= 0x370
699
+ char const *old_context = _Py_PackageContext;
700
+ _Py_PackageContext = (char *)new_context;
701
+ return old_context;
702
+ #else
703
+ char *old_context = _Py_PackageContext;
704
+ _Py_PackageContext = (char *)new_context;
705
+ return (char const *)old_context;
706
+ #endif
707
+ }
708
+
707
709
  static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const filename_char_t *filename,
708
710
  bool is_package) {
709
711
  // Determine the package name and basename of the module to load.
@@ -729,6 +731,8 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
729
731
  }
730
732
 
731
733
  #ifndef _NUITKA_EXPERIMENTAL_DEBUG_STANDALONE
734
+ // Disable all but critical errors, prevents dialogs from showing.
735
+ // spell-checker: ignore SEM_FAILCRITICALERRORS
732
736
  unsigned int old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
733
737
  #endif
734
738
 
@@ -782,6 +786,13 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
782
786
  // structure internals of 3.8 or higher.
783
787
  // spell-checker: ignore getdlopenflags,dlopenflags
784
788
 
789
+ #ifdef __wasi__
790
+ const char *error = "dynamic libraries are not implemented in wasi";
791
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ImportError, error);
792
+ return NULL;
793
+
794
+ entrypoint_t entrypoint = NULL;
795
+ #else
785
796
  static PyObject *dlopenflags_object = NULL;
786
797
  if (dlopenflags_object == NULL) {
787
798
  dlopenflags_object = CALL_FUNCTION_NO_ARGS(tstate, Nuitka_SysGetObject("getdlopenflags"));
@@ -806,16 +817,11 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
806
817
  }
807
818
 
808
819
  entrypoint_t entrypoint = (entrypoint_t)dlsym(handle, entry_function_name);
820
+ #endif // __wasi__
809
821
  #endif
810
822
  assert(entrypoint);
811
823
 
812
- #if PYTHON_VERSION < 0x370
813
- char *old_context = _Py_PackageContext;
814
- #else
815
- char const *old_context = _Py_PackageContext;
816
- #endif
817
-
818
- _Py_PackageContext = (char *)package;
824
+ char const *old_context = NuitkaImport_SwapPackageContext(package);
819
825
 
820
826
  // Finally call into the DLL.
821
827
  PGO_onModuleEntered(full_name);
@@ -836,7 +842,13 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
836
842
  PySys_WriteStderr("import %s # return from entrypoint\n", full_name);
837
843
  }
838
844
 
839
- _Py_PackageContext = old_context;
845
+ #if 0
846
+ PRINT_STRING("FRESH");
847
+ PRINT_ITEM(module);
848
+ PRINT_NEW_LINE();
849
+ #endif
850
+
851
+ NuitkaImport_SwapPackageContext(old_context);
840
852
 
841
853
  #if PYTHON_VERSION < 0x300
842
854
  PyObject *module = Nuitka_GetModuleString(tstate, full_name);
@@ -918,6 +930,8 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
918
930
  } else {
919
931
  def = PyModule_GetDef(module);
920
932
 
933
+ def->m_base.m_init = entrypoint;
934
+
921
935
  // Set "__spec__" and "__file__" after load.
922
936
  setModuleFileValue(tstate, module, filename);
923
937
  PyObject *full_name_obj = Nuitka_String_FromString(full_name);
@@ -976,11 +990,8 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
976
990
  #else
977
991
  PyObject *full_name_obj = PyUnicode_FromString(full_name);
978
992
  CHECK_OBJECT(full_name_obj);
979
- #ifdef _WIN32
980
- PyObject *filename_obj = NuitkaUnicode_FromWideChar(filename, -1);
981
- #else
982
- PyObject *filename_obj = PyUnicode_FromString(filename);
983
- #endif
993
+ PyObject *filename_obj = Nuitka_String_FromFilename(filename);
994
+
984
995
  CHECK_OBJECT(filename_obj);
985
996
 
986
997
  #if PYTHON_VERSION < 0x3d0
@@ -1052,20 +1063,11 @@ static PyObject *loadModule(PyThreadState *tstate, PyObject *module, PyObject *m
1052
1063
  struct Nuitka_MetaPathBasedLoaderEntry const *entry) {
1053
1064
  #ifdef _NUITKA_STANDALONE
1054
1065
  if ((entry->flags & NUITKA_EXTENSION_MODULE_FLAG) != 0) {
1055
- filename_char_t filename[MAXPATHLEN + 1] = {0};
1056
- _makeModuleCFilenameValue(filename, sizeof(filename) / sizeof(filename_char_t), entry->name, module_name);
1057
-
1058
- // Set "__spec__" and "__file__", some modules expect it early.
1059
- setModuleFileValue(tstate, module, filename);
1060
-
1061
1066
  bool is_package = (entry->flags & NUITKA_PACKAGE_FLAG) != 0;
1062
1067
 
1063
- #if PYTHON_VERSION >= 0x350
1064
- PyObject *spec_value = createModuleSpec(tstate, module_name,
1065
- LOOKUP_ATTRIBUTE(tstate, module, const_str_plain___file__), is_package);
1066
-
1067
- SET_ATTRIBUTE(tstate, module, const_str_plain___spec__, spec_value);
1068
- #endif
1068
+ filename_char_t filename[MAXPATHLEN + 1] = {0};
1069
+ _makeModuleCFilenameValue(filename, sizeof(filename) / sizeof(filename_char_t), entry->name, module_name,
1070
+ is_package);
1069
1071
 
1070
1072
  callIntoExtensionModule(tstate, entry->name, filename, is_package);
1071
1073
  } else
@@ -1087,7 +1089,7 @@ static PyObject *loadModule(PyThreadState *tstate, PyObject *module, PyObject *m
1087
1089
  (entry->flags & NUITKA_PACKAGE_FLAG) != 0);
1088
1090
  } else {
1089
1091
  assert((entry->flags & NUITKA_EXTENSION_MODULE_FLAG) == 0);
1090
- assert(entry->python_initfunc);
1092
+ assert(entry->python_init_func);
1091
1093
 
1092
1094
  {
1093
1095
  NUITKA_MAY_BE_UNUSED bool res = Nuitka_SetModule(module_name, module);
@@ -1098,7 +1100,7 @@ static PyObject *loadModule(PyThreadState *tstate, PyObject *module, PyObject *m
1098
1100
  #if PYTHON_VERSION < 0x300
1099
1101
  NUITKA_MAY_BE_UNUSED
1100
1102
  #endif
1101
- PyObject *result = entry->python_initfunc(tstate, module, entry);
1103
+ PyObject *result = entry->python_init_func(tstate, module, entry);
1102
1104
  CHECK_OBJECT_X(result);
1103
1105
 
1104
1106
  #if PYTHON_VERSION >= 0x300
@@ -1317,7 +1319,7 @@ static PyObject *_nuitka_loader_iter_modules(struct Nuitka_LoaderObject *self, P
1317
1319
 
1318
1320
  while (current->name != NULL) {
1319
1321
  if ((current->flags & NUITKA_TRANSLATED_FLAG) != 0) {
1320
- current->name = UNTRANSLATE(current->name);
1322
+ current->name = UN_TRANSLATE(current->name);
1321
1323
  current->flags -= NUITKA_TRANSLATED_FLAG;
1322
1324
  }
1323
1325
 
@@ -1431,35 +1433,6 @@ PyObject *getImportLibBootstrapModule(void) {
1431
1433
  }
1432
1434
  #endif
1433
1435
 
1434
- #if PYTHON_VERSION >= 0x340
1435
-
1436
- static PyObject *_nuitka_loader_repr_module(PyObject *self, PyObject *args, PyObject *kwds) {
1437
- PyObject *module;
1438
- PyObject *unused;
1439
-
1440
- int res =
1441
- PyArg_ParseTupleAndKeywords(args, kwds, "O|O:module_repr", (char **)_kw_list_find_module, &module, &unused);
1442
-
1443
- if (unlikely(res == 0)) {
1444
- return NULL;
1445
- }
1446
-
1447
- PyThreadState *tstate = PyThreadState_GET();
1448
-
1449
- return PyUnicode_FromFormat("<module '%s' from %R>", PyModule_GetName(module),
1450
- Nuitka_GetFilenameObject(tstate, module));
1451
- }
1452
-
1453
- static PyObject *getModuleSpecClass(PyObject *importlib_module) {
1454
- static PyObject *module_spec_class = NULL;
1455
-
1456
- if (module_spec_class == NULL) {
1457
- module_spec_class = PyObject_GetAttrString(importlib_module, "ModuleSpec");
1458
- }
1459
-
1460
- return module_spec_class;
1461
- }
1462
-
1463
1436
  static PyObject *getModuleFileValue(PyThreadState *tstate, struct Nuitka_MetaPathBasedLoaderEntry const *entry) {
1464
1437
  PyObject *dir_name = getModuleDirectory(tstate, entry);
1465
1438
 
@@ -1496,6 +1469,35 @@ static PyObject *getModuleFileValue(PyThreadState *tstate, struct Nuitka_MetaPat
1496
1469
  return result;
1497
1470
  }
1498
1471
 
1472
+ #if PYTHON_VERSION >= 0x340
1473
+
1474
+ static PyObject *_nuitka_loader_repr_module(PyObject *self, PyObject *args, PyObject *kwds) {
1475
+ PyObject *module;
1476
+ PyObject *unused;
1477
+
1478
+ int res =
1479
+ PyArg_ParseTupleAndKeywords(args, kwds, "O|O:module_repr", (char **)_kw_list_find_module, &module, &unused);
1480
+
1481
+ if (unlikely(res == 0)) {
1482
+ return NULL;
1483
+ }
1484
+
1485
+ PyThreadState *tstate = PyThreadState_GET();
1486
+
1487
+ return PyUnicode_FromFormat("<module '%s' from %R>", PyModule_GetName(module),
1488
+ Nuitka_GetFilenameObject(tstate, module));
1489
+ }
1490
+
1491
+ static PyObject *getModuleSpecClass(PyObject *importlib_module) {
1492
+ static PyObject *module_spec_class = NULL;
1493
+
1494
+ if (module_spec_class == NULL) {
1495
+ module_spec_class = PyObject_GetAttrString(importlib_module, "ModuleSpec");
1496
+ }
1497
+
1498
+ return module_spec_class;
1499
+ }
1500
+
1499
1501
  static PyObject *createModuleSpec(PyThreadState *tstate, PyObject *module_name, PyObject *origin, bool is_package) {
1500
1502
  CHECK_OBJECT(module_name);
1501
1503
  assert(Nuitka_String_Check(module_name));
@@ -1805,7 +1807,7 @@ static PyObject *_nuitka_loader_sys_path_hook(PyObject *self, PyObject *args, Py
1805
1807
 
1806
1808
  while (entry->name != NULL) {
1807
1809
  if ((entry->flags & NUITKA_TRANSLATED_FLAG) != 0) {
1808
- entry->name = UNTRANSLATE(entry->name);
1810
+ entry->name = UN_TRANSLATE(entry->name);
1809
1811
  entry->flags -= NUITKA_TRANSLATED_FLAG;
1810
1812
  }
1811
1813
 
@@ -1892,14 +1894,28 @@ static void Nuitka_Loader_tp_dealloc(struct Nuitka_LoaderObject *loader) {
1892
1894
 
1893
1895
  static int Nuitka_Loader_tp_traverse(struct Nuitka_LoaderObject *loader, visitproc visit, void *arg) { return 0; }
1894
1896
 
1897
+ static PyObject *Nuitka_Loader_get_name(struct Nuitka_LoaderObject *loader, void *closure) {
1898
+ PyObject *result = Nuitka_String_FromString(loader->m_loader_entry->name);
1899
+
1900
+ return result;
1901
+ }
1902
+ static PyObject *Nuitka_Loader_get_path(struct Nuitka_LoaderObject *loader, void *closure) {
1903
+ PyThreadState *tstate = PyThreadState_GET();
1904
+ PyObject *result = getModuleFileValue(tstate, loader->m_loader_entry);
1905
+
1906
+ return result;
1907
+ }
1908
+
1895
1909
  static PyObject *Nuitka_Loader_get__module__(struct Nuitka_LoaderObject *loader, void *closure) {
1896
1910
  PyObject *result = const_str_plain___nuitka__;
1897
1911
 
1898
- Py_INCREF(result);
1912
+ Py_INCREF_IMMORTAL(result);
1899
1913
  return result;
1900
1914
  }
1901
1915
 
1902
1916
  static PyGetSetDef Nuitka_Loader_tp_getset[] = {{(char *)"__module__", (getter)Nuitka_Loader_get__module__, NULL, NULL},
1917
+ {(char *)"name", (getter)Nuitka_Loader_get_name, NULL, NULL},
1918
+ {(char *)"path", (getter)Nuitka_Loader_get_path, NULL, NULL},
1903
1919
  {NULL}};
1904
1920
 
1905
1921
  PyTypeObject Nuitka_Loader_Type = {
@@ -1946,8 +1962,44 @@ PyObject *Nuitka_Loader_New(struct Nuitka_MetaPathBasedLoaderEntry const *entry)
1946
1962
  return (PyObject *)result;
1947
1963
  }
1948
1964
 
1949
- void registerMetaPathBasedUnfreezer(struct Nuitka_MetaPathBasedLoaderEntry *_loader_entries,
1950
- unsigned char **bytecode_data) {
1965
+ #ifdef _NUITKA_MODULE
1966
+ void updateMetaPathBasedLoaderModuleRoot(char const *module_root_name) {
1967
+ assert(module_root_name != NULL);
1968
+ char const *last_dot = strrchr(module_root_name, '.');
1969
+
1970
+ if (last_dot != NULL) {
1971
+ struct Nuitka_MetaPathBasedLoaderEntry *current = loader_entries;
1972
+ assert(current);
1973
+
1974
+ while (current->name != NULL) {
1975
+ if ((current->flags & NUITKA_TRANSLATED_FLAG) != 0) {
1976
+ current->name = UN_TRANSLATE(current->name);
1977
+ current->flags -= NUITKA_TRANSLATED_FLAG;
1978
+ }
1979
+
1980
+ char name[2048];
1981
+
1982
+ if (strcmp(last_dot + 1, current->name) == 0) {
1983
+ copyStringSafeN(name, module_root_name, last_dot - module_root_name + 1, sizeof(name));
1984
+ appendStringSafe(name, current->name, sizeof(name));
1985
+
1986
+ current->name = strdup(name);
1987
+ } else if (strncmp(last_dot + 1, current->name, strlen(last_dot + 1)) == 0 &&
1988
+ current->name[strlen(last_dot + 1)] == '.') {
1989
+ copyStringSafeN(name, module_root_name, last_dot - module_root_name + 1, sizeof(name));
1990
+ appendStringSafe(name, current->name, sizeof(name));
1991
+
1992
+ current->name = strdup(name);
1993
+ }
1994
+
1995
+ current++;
1996
+ }
1997
+ }
1998
+ }
1999
+ #endif
2000
+
2001
+ void registerMetaPathBasedLoader(struct Nuitka_MetaPathBasedLoaderEntry *_loader_entries,
2002
+ unsigned char **bytecode_data) {
1951
2003
  // Do it only once.
1952
2004
  if (loader_entries) {
1953
2005
  assert(_loader_entries == loader_entries);
@@ -1961,43 +2013,14 @@ void registerMetaPathBasedUnfreezer(struct Nuitka_MetaPathBasedLoaderEntry *_loa
1961
2013
  PySys_WriteStderr("Setup nuitka compiled module/bytecode/extension importer.\n");
1962
2014
  }
1963
2015
 
1964
- #ifdef _NUITKA_MODULE
1965
- if (_Py_PackageContext != NULL) {
1966
- char const *last_dot = strrchr(_Py_PackageContext, '.');
1967
-
1968
- if (last_dot != NULL) {
1969
- struct Nuitka_MetaPathBasedLoaderEntry *current = _loader_entries;
1970
- assert(current);
1971
-
1972
- while (current->name != NULL) {
1973
- if ((current->flags & NUITKA_TRANSLATED_FLAG) != 0) {
1974
- current->name = UNTRANSLATE(current->name);
1975
- current->flags -= NUITKA_TRANSLATED_FLAG;
1976
- }
1977
-
1978
- char name[2048];
1979
-
1980
- if (strcmp(last_dot + 1, current->name) == 0) {
1981
- copyStringSafeN(name, _Py_PackageContext, last_dot - _Py_PackageContext + 1, sizeof(name));
1982
- appendStringSafe(name, current->name, sizeof(name));
1983
-
1984
- current->name = strdup(name);
1985
- } else if (strncmp(last_dot + 1, current->name, strlen(last_dot + 1)) == 0 &&
1986
- current->name[strlen(last_dot + 1)] == '.') {
1987
- copyStringSafeN(name, _Py_PackageContext, last_dot - _Py_PackageContext + 1, sizeof(name));
1988
- appendStringSafe(name, current->name, sizeof(name));
1989
-
1990
- current->name = strdup(name);
1991
- }
2016
+ loader_entries = _loader_entries;
1992
2017
 
1993
- current++;
1994
- }
1995
- }
2018
+ #if defined(_NUITKA_MODULE) && PYTHON_VERSION < 0x3c0
2019
+ if (_Py_PackageContext != NULL) {
2020
+ updateMetaPathBasedLoaderModuleRoot(_Py_PackageContext);
1996
2021
  }
1997
2022
  #endif
1998
2023
 
1999
- loader_entries = _loader_entries;
2000
-
2001
2024
  Nuitka_PyType_Ready(&Nuitka_Loader_Type, NULL, true, false, false, false, false);
2002
2025
 
2003
2026
  #ifdef _NUITKA_EXE
@@ -13,7 +13,16 @@
13
13
  static PyObject *metadata_values_dict = NULL;
14
14
 
15
15
  // For initialization of the metadata dictionary during startup.
16
- void setDistributionsMetadata(PyObject *metadata_values) { metadata_values_dict = metadata_values; }
16
+ void setDistributionsMetadata(PyThreadState *tstate, PyObject *metadata_values) {
17
+ metadata_values_dict = MAKE_DICT_EMPTY(tstate);
18
+
19
+ // We get the items passed, and need to add it to the dictionary.
20
+ int res = PyDict_MergeFromSeq2(metadata_values_dict, metadata_values, 1);
21
+ assert(res == 0);
22
+
23
+ // PRINT_ITEM(metadata_values_dict);
24
+ // PRINT_NEW_LINE();
25
+ }
17
26
 
18
27
  bool Nuitka_DistributionNext(Py_ssize_t *pos, PyObject **distribution_name_ptr) {
19
28
  PyObject *value;
@@ -35,8 +44,8 @@ if sys.version_info >= (3, 8):\n\
35
44
  else:\n\
36
45
  from importlib_metadata import Distribution,distribution\n\
37
46
  class nuitka_distribution(Distribution):\n\
38
- def __init__(self, base_path, metadata, entry_points):\n\
39
- self.base_path = base_path; self.metadata_data = metadata\n\
47
+ def __init__(self, path, metadata, entry_points):\n\
48
+ self._path = path; self.metadata_data = metadata\n\
40
49
  self.entry_points_data = entry_points\n\
41
50
  def read_text(self, filename):\n\
42
51
  if filename == 'METADATA':\n\
@@ -44,7 +53,7 @@ class nuitka_distribution(Distribution):\n\
44
53
  elif filename == 'entry_points.txt':\n\
45
54
  return self.entry_points_data\n\
46
55
  def locate_file(self, path):\n\
47
- return os.path.join(self.base_path, path)\n\
56
+ return os.path.join(self._path, path)\n\
48
57
  ";
49
58
 
50
59
  PyObject *nuitka_distribution_code_object = Py_CompileString(nuitka_distribution_code, "<exec>", Py_file_input);