Nuitka-winsvc 2.3.9__cp311-cp311-win_amd64.whl → 2.4.1__cp311-cp311-win_amd64.whl

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

Potentially problematic release.


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

Files changed (213) hide show
  1. Nuitka_winsvc-2.3.9.data/scripts/nuitka-run.bat → Nuitka_winsvc-2.4.1.data/scripts/nuitka-run.cmd +1 -1
  2. {Nuitka_winsvc-2.3.9.dist-info → Nuitka_winsvc-2.4.1.dist-info}/METADATA +1 -1
  3. {Nuitka_winsvc-2.3.9.dist-info → Nuitka_winsvc-2.4.1.dist-info}/RECORD +213 -210
  4. {Nuitka_winsvc-2.3.9.dist-info → Nuitka_winsvc-2.4.1.dist-info}/WHEEL +1 -1
  5. nuitka/CacheCleanup.py +6 -1
  6. nuitka/HardImportRegistry.py +29 -2
  7. nuitka/MainControl.py +62 -35
  8. nuitka/ModuleRegistry.py +11 -3
  9. nuitka/OptionParsing.py +78 -39
  10. nuitka/Options.py +142 -35
  11. nuitka/OutputDirectories.py +5 -0
  12. nuitka/PostProcessing.py +23 -14
  13. nuitka/PythonFlavors.py +22 -4
  14. nuitka/PythonVersions.py +18 -0
  15. nuitka/Tracing.py +26 -23
  16. nuitka/TreeXML.py +6 -3
  17. nuitka/Version.py +1 -1
  18. nuitka/__main__.py +55 -10
  19. nuitka/build/Backend.scons +6 -1
  20. nuitka/build/CCompilerVersion.scons +1 -0
  21. nuitka/build/Onefile.scons +4 -0
  22. nuitka/build/SconsCaching.py +1 -0
  23. nuitka/build/SconsCompilerSettings.py +1 -0
  24. nuitka/build/SconsHacks.py +5 -1
  25. nuitka/build/SconsInterface.py +2 -0
  26. nuitka/build/SconsUtils.py +5 -2
  27. nuitka/build/include/nuitka/allocator.h +27 -5
  28. nuitka/build/include/nuitka/calling.h +1 -1
  29. nuitka/build/include/nuitka/compiled_frame.h +23 -23
  30. nuitka/build/include/nuitka/compiled_method.h +1 -1
  31. nuitka/build/include/nuitka/exception_groups.h +0 -2
  32. nuitka/build/include/nuitka/helper/attributes.h +7 -1
  33. nuitka/build/include/nuitka/helper/subscripts.h +1 -1
  34. nuitka/build/include/nuitka/helpers.h +7 -4
  35. nuitka/build/include/nuitka/prelude.h +6 -10
  36. nuitka/build/include/nuitka/printing.h +2 -0
  37. nuitka/build/include/nuitka/unfreezing.h +5 -5
  38. nuitka/build/inline_copy/tqdm/tqdm/_monitor.py +4 -1
  39. nuitka/build/static_src/CompiledAsyncgenType.c +2 -4
  40. nuitka/build/static_src/CompiledCellType.c +7 -7
  41. nuitka/build/static_src/CompiledCodeHelpers.c +51 -36
  42. nuitka/build/static_src/CompiledCoroutineType.c +2 -4
  43. nuitka/build/static_src/CompiledFrameType.c +109 -82
  44. nuitka/build/static_src/CompiledFunctionType.c +36 -9
  45. nuitka/build/static_src/CompiledGeneratorType.c +12 -10
  46. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +2 -2
  47. nuitka/build/static_src/CompiledMethodType.c +14 -13
  48. nuitka/build/static_src/HelpersAttributes.c +13 -15
  49. nuitka/build/static_src/HelpersBuiltin.c +18 -9
  50. nuitka/build/static_src/HelpersCalling.c +13 -13
  51. nuitka/build/static_src/HelpersCallingGenerated.c +22 -22
  52. nuitka/build/static_src/HelpersComparisonEq.c +110 -110
  53. nuitka/build/static_src/HelpersComparisonEqUtils.c +1 -1
  54. nuitka/build/static_src/HelpersComparisonGe.c +110 -110
  55. nuitka/build/static_src/HelpersComparisonGt.c +110 -110
  56. nuitka/build/static_src/HelpersComparisonLe.c +110 -110
  57. nuitka/build/static_src/HelpersComparisonLt.c +110 -110
  58. nuitka/build/static_src/HelpersComparisonNe.c +110 -110
  59. nuitka/build/static_src/HelpersConstantsBlob.c +480 -481
  60. nuitka/build/static_src/HelpersDictionaries.c +9 -0
  61. nuitka/build/static_src/HelpersFiles.c +2 -2
  62. nuitka/build/static_src/HelpersFilesystemPaths.c +28 -13
  63. nuitka/build/static_src/HelpersHeapStorage.c +4 -0
  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/MainProgram.c +28 -9
  85. nuitka/build/static_src/MetaPathBasedLoader.c +126 -110
  86. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +13 -4
  87. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +30 -1
  88. nuitka/build/static_src/OnefileBootstrap.c +34 -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/GlobalConstants.py +6 -6
  93. nuitka/code_generation/Indentation.py +3 -4
  94. nuitka/code_generation/LoaderCodes.py +3 -0
  95. nuitka/code_generation/LocalsDictCodes.py +36 -14
  96. nuitka/code_generation/MatchCodes.py +23 -4
  97. nuitka/code_generation/ModuleCodes.py +0 -7
  98. nuitka/code_generation/Namify.py +2 -0
  99. nuitka/code_generation/PackageResourceCodes.py +5 -1
  100. nuitka/code_generation/templates/CodeTemplatesConstants.py +6 -4
  101. nuitka/code_generation/templates/CodeTemplatesLoader.py +1 -1
  102. nuitka/code_generation/templates/CodeTemplatesModules.py +3 -3
  103. nuitka/code_generation/templates/CodeTemplatesVariables.py +16 -2
  104. nuitka/code_generation/templates_c/CodeTemplateCallsMethodPositional.c.j2 +2 -2
  105. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +1 -1
  106. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
  107. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +7 -7
  108. nuitka/freezer/DependsExe.py +3 -1
  109. nuitka/freezer/DllDependenciesMacOS.py +28 -14
  110. nuitka/freezer/IncludedDataFiles.py +12 -3
  111. nuitka/freezer/IncludedEntryPoints.py +8 -2
  112. nuitka/freezer/Onefile.py +6 -1
  113. nuitka/freezer/Standalone.py +9 -2
  114. nuitka/importing/Importing.py +14 -5
  115. nuitka/importing/Recursion.py +3 -0
  116. nuitka/nodes/AttributeNodesGenerated.py +21 -12
  117. nuitka/nodes/BuiltinOpenNodes.py +5 -0
  118. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +11 -11
  119. nuitka/nodes/BuiltinRefNodes.py +41 -1
  120. nuitka/nodes/ChildrenHavingMixins.py +143 -355
  121. nuitka/nodes/ClassNodes.py +30 -12
  122. nuitka/nodes/CodeObjectSpecs.py +9 -0
  123. nuitka/nodes/ExpressionBasesGenerated.py +11 -11
  124. nuitka/nodes/FunctionNodes.py +11 -12
  125. nuitka/nodes/FutureSpecs.py +16 -3
  126. nuitka/nodes/GeneratorNodes.py +2 -2
  127. nuitka/nodes/HardImportNodesGenerated.py +11 -134
  128. nuitka/nodes/LocalsScopes.py +19 -23
  129. nuitka/nodes/MatchNodes.py +18 -7
  130. nuitka/nodes/ModuleAttributeNodes.py +1 -20
  131. nuitka/nodes/ModuleNodes.py +23 -6
  132. nuitka/nodes/NodeBases.py +13 -11
  133. nuitka/nodes/NodeMetaClasses.py +26 -10
  134. nuitka/nodes/ReturnNodes.py +1 -1
  135. nuitka/nodes/StatementBasesGenerated.py +11 -11
  136. nuitka/nodes/SubscriptNodes.py +4 -4
  137. nuitka/nodes/VariableAssignNodes.py +1 -1
  138. nuitka/nodes/VariableRefNodes.py +28 -2
  139. nuitka/nodes/shapes/BuiltinTypeShapes.py +21 -1
  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 +91 -3
  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 +491 -186
  157. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +17 -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 +9 -1
  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 +22 -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 +21 -9
  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 +69 -41
  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.9.data/scripts/nuitka.bat → /Nuitka_winsvc-2.4.1.data/scripts/nuitka.cmd +0 -0
  211. {Nuitka_winsvc-2.3.9.dist-info → Nuitka_winsvc-2.4.1.dist-info}/LICENSE.txt +0 -0
  212. {Nuitka_winsvc-2.3.9.dist-info → Nuitka_winsvc-2.4.1.dist-info}/entry_points.txt +0 -0
  213. {Nuitka_winsvc-2.3.9.dist-info → Nuitka_winsvc-2.4.1.dist-info}/top_level.txt +0 -0
@@ -850,7 +850,7 @@ static void setInputOutputHandles(PyThreadState *tstate) {
850
850
  #else
851
851
  PyObject *filename = getExpandedTemplatePath(NUITKA_FORCED_STDOUT_PATH);
852
852
  #endif
853
- PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
853
+ PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding, false);
854
854
  if (unlikely(stdout_file == NULL)) {
855
855
  PyErr_PrintEx(1);
856
856
  Py_Exit(1);
@@ -867,7 +867,7 @@ static void setInputOutputHandles(PyThreadState *tstate) {
867
867
  #else
868
868
  PyObject *filename = getExpandedTemplatePath(NUITKA_FORCED_STDERR_PATH);
869
869
  #endif
870
- PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", false, encoding);
870
+ PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", false, encoding, false);
871
871
  if (unlikely(stderr_file == NULL)) {
872
872
  PyErr_PrintEx(1);
873
873
  Py_Exit(1);
@@ -888,19 +888,19 @@ static void setInputOutputHandles(PyThreadState *tstate) {
888
888
  if (shallSetOutputHandleToNull("stdin")) {
889
889
  // CPython core requires stdin to be buffered due to methods usage, and it won't matter
890
890
  // here much.
891
- PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(tstate, devnull_filename, "r", true, encoding);
891
+ PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(tstate, devnull_filename, "r", true, encoding, false);
892
892
 
893
893
  setStdinHandle(tstate, stdin_file);
894
894
  }
895
895
 
896
896
  if (shallSetOutputHandleToNull("stdout")) {
897
- PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, devnull_filename, "w", false, encoding);
897
+ PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, devnull_filename, "w", false, encoding, false);
898
898
 
899
899
  setStdoutHandle(tstate, stdout_file);
900
900
  }
901
901
 
902
902
  if (shallSetOutputHandleToNull("stderr")) {
903
- PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, devnull_filename, "w", false, encoding);
903
+ PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, devnull_filename, "w", false, encoding, false);
904
904
 
905
905
  setStderrHandle(tstate, stderr_file);
906
906
  }
@@ -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
 
@@ -1452,7 +1470,7 @@ orig_argv = argv;
1452
1470
  // platform ones in the future.
1453
1471
  PyObject *encoding = NULL;
1454
1472
 
1455
- PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
1473
+ PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding, false);
1456
1474
  if (unlikely(stdout_file == NULL)) {
1457
1475
  PyErr_PrintEx(1);
1458
1476
  Py_Exit(1);
@@ -1469,7 +1487,7 @@ orig_argv = argv;
1469
1487
  // platform ones in the future.
1470
1488
  PyObject *encoding = NULL;
1471
1489
 
1472
- PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
1490
+ PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding, false);
1473
1491
  if (unlikely(stderr_file == NULL)) {
1474
1492
  PyErr_PrintEx(1);
1475
1493
  Py_Exit(1);
@@ -1488,7 +1506,7 @@ orig_argv = argv;
1488
1506
 
1489
1507
  // CPython core requires stdin to be buffered due to methods usage, and it won't matter
1490
1508
  // here much.
1491
- PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "r", true, encoding);
1509
+ PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "r", true, encoding, false);
1492
1510
 
1493
1511
  Py_DECREF(filename);
1494
1512
 
@@ -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));
@@ -1669,9 +1671,9 @@ static PyObject *_nuitka_loader_exec_module(PyObject *self, PyObject *args, PyOb
1669
1671
 
1670
1672
  if (extension_module_filename != NULL) {
1671
1673
  // Set filename attribute
1672
- res = SET_ATTRIBUTE(tstate, module, const_str_plain___file__, extension_module_filename);
1674
+ bool b_res = SET_ATTRIBUTE(tstate, module, const_str_plain___file__, extension_module_filename);
1673
1675
 
1674
- if (unlikely(res < 0)) {
1676
+ if (unlikely(b_res == false)) {
1675
1677
  // Might be refuted, which wouldn't be harmful.
1676
1678
  CLEAR_ERROR_OCCURRED(tstate);
1677
1679
  }
@@ -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,8 @@ 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
+ void registerMetaPathBasedLoader(struct Nuitka_MetaPathBasedLoaderEntry *_loader_entries,
1966
+ unsigned char **bytecode_data) {
1951
1967
  // Do it only once.
1952
1968
  if (loader_entries) {
1953
1969
  assert(_loader_entries == loader_entries);
@@ -1971,7 +1987,7 @@ void registerMetaPathBasedUnfreezer(struct Nuitka_MetaPathBasedLoaderEntry *_loa
1971
1987
 
1972
1988
  while (current->name != NULL) {
1973
1989
  if ((current->flags & NUITKA_TRANSLATED_FLAG) != 0) {
1974
- current->name = UNTRANSLATE(current->name);
1990
+ current->name = UN_TRANSLATE(current->name);
1975
1991
  current->flags -= NUITKA_TRANSLATED_FLAG;
1976
1992
  }
1977
1993
 
@@ -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);
@@ -186,7 +186,7 @@ static PyObject *Nuitka_ResourceReaderFiles_read_text(struct Nuitka_ResourceRead
186
186
  return NULL;
187
187
  }
188
188
 
189
- PyObject *file_object = BUILTIN_OPEN_SIMPLE(tstate, file_name, "r", true, encoding);
189
+ PyObject *file_object = BUILTIN_OPEN_SIMPLE(tstate, file_name, "r", true, encoding, true);
190
190
 
191
191
  Py_DECREF(file_name);
192
192
 
@@ -442,6 +442,33 @@ static PyObject *Nuitka_ResourceReaderFiles_absolute(struct Nuitka_ResourceReade
442
442
  return Nuitka_ResourceReaderFiles_New(tstate, files->m_loader_entry, abspath);
443
443
  }
444
444
 
445
+ static PyObject *Nuitka_ResourceReaderFiles_get_parent(struct Nuitka_ResourceReaderFilesObject *files) {
446
+ PyThreadState *tstate = PyThreadState_GET();
447
+
448
+ PyObject *path = _Nuitka_ResourceReaderFiles_GetPath(tstate, files);
449
+
450
+ PyObject *abspath = OS_PATH_ABSPATH(tstate, path);
451
+
452
+ if (unlikely(abspath == NULL)) {
453
+ return NULL;
454
+ }
455
+
456
+ PyObject *dirname = OS_PATH_DIRNAME(tstate, abspath);
457
+
458
+ if (unlikely(dirname == NULL)) {
459
+ return NULL;
460
+ }
461
+
462
+ return Nuitka_ResourceReaderFiles_New(tstate, files->m_loader_entry, dirname);
463
+ }
464
+
465
+ static int Nuitka_ResourceReaderFiles_set_parent(struct Nuitka_ResourceReaderFilesObject *files, PyObject *value) {
466
+ PyThreadState *tstate = PyThreadState_GET();
467
+
468
+ SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_AttributeError, "readonly attribute");
469
+ return -1;
470
+ }
471
+
445
472
  static PyMethodDef Nuitka_ResourceReaderFiles_methods[] = {
446
473
  {"iterdir", (PyCFunction)Nuitka_ResourceReaderFiles_iterdir, METH_NOARGS, NULL},
447
474
  {"read_bytes", (PyCFunction)Nuitka_ResourceReaderFiles_read_bytes, METH_NOARGS, NULL},
@@ -505,6 +532,8 @@ static PyObject *Nuitka_ResourceReaderFiles_tp_richcompare(struct Nuitka_Resourc
505
532
 
506
533
  static PyGetSetDef Nuitka_ResourceReaderFiles_getset[] = {
507
534
  {(char *)"name", (getter)Nuitka_ResourceReaderFiles_get_name, (setter)Nuitka_ResourceReaderFiles_set_name, NULL},
535
+ {(char *)"parent", (getter)Nuitka_ResourceReaderFiles_get_parent, (setter)Nuitka_ResourceReaderFiles_set_parent,
536
+ NULL},
508
537
  {NULL}};
509
538
 
510
539
  // Initialized during readying the type for nb_truediv
@@ -813,6 +813,30 @@ extern bool checkSplashScreen(void);
813
813
  #endif
814
814
  #endif
815
815
 
816
+ #ifdef _WIN32
817
+ static wchar_t *getCommandLineForChildProcess(void) {
818
+ int argc;
819
+ LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
820
+ assert(argv != NULL);
821
+ assert(argc > 0);
822
+
823
+ static wchar_t result[32768];
824
+ result[0] = 0;
825
+
826
+ appendWStringSafeW(result, getBinaryPath(), sizeof(result) / sizeof(wchar_t));
827
+
828
+ for (int i = 1; i < argc; i++) {
829
+ appendWCharSafeW(result, L' ', sizeof(result) / sizeof(wchar_t));
830
+ appendWStringSafeW(result, argv[i], sizeof(result) / sizeof(wchar_t));
831
+ }
832
+
833
+ #if defined(_NUITKA_EXPERIMENTAL_DEBUG_ONEFILE_HANDLING)
834
+ wprintf(L"Command line composed to '%ls'\n", result);
835
+ #endif
836
+ return result;
837
+ }
838
+ #endif
839
+
816
840
  #ifdef _NUITKA_WINMAIN_ENTRY_POINT
817
841
  int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpCmdLine, int nCmdShow) {
818
842
  int argc = __argc;
@@ -1243,12 +1267,12 @@ int main(int argc, char **argv) {
1243
1267
 
1244
1268
  PROCESS_INFORMATION pi;
1245
1269
 
1246
- bool_res = CreateProcessW(first_filename, // application name
1247
- GetCommandLineW(), // command line
1248
- NULL, // process attributes
1249
- NULL, // thread attributes
1250
- TRUE, // inherit handles
1251
- NORMAL_PRIORITY_CLASS, // creation flags
1270
+ bool_res = CreateProcessW(first_filename, // application name
1271
+ getCommandLineForChildProcess(), // command line
1272
+ NULL, // process attributes
1273
+ NULL, // thread attributes
1274
+ TRUE, // inherit handles
1275
+ NORMAL_PRIORITY_CLASS, // creation flags
1252
1276
  NULL, NULL, &si, &pi);
1253
1277
 
1254
1278
  NUITKA_PRINT_TIMING("ONEFILE: Started slave process.");
@@ -1307,6 +1331,10 @@ int main(int argc, char **argv) {
1307
1331
  exit_code = 2;
1308
1332
  } else if (pid == 0) {
1309
1333
  // Child process
1334
+
1335
+ // Make sure, we use the absolute program path for argv[0]
1336
+ argv[0] = getBinaryPath();
1337
+
1310
1338
  execv(first_filename, argv);
1311
1339
 
1312
1340
  fatalErrorChild("Error, couldn't launch child (exec)", errno);