Nuitka-winsvc 1.8.6__cp312-cp312-win_amd64.whl → 1.9.3__cp312-cp312-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.
Files changed (214) hide show
  1. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/RECORD +212 -203
  3. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/WHEEL +1 -1
  4. nuitka/BytecodeCaching.py +4 -1
  5. nuitka/HardImportRegistry.py +348 -0
  6. nuitka/MainControl.py +45 -25
  7. nuitka/OptionParsing.py +31 -20
  8. nuitka/Options.py +47 -16
  9. nuitka/Progress.py +32 -2
  10. nuitka/PythonFlavors.py +1 -1
  11. nuitka/PythonVersions.py +61 -0
  12. nuitka/Tracing.py +25 -12
  13. nuitka/TreeXML.py +5 -5
  14. nuitka/Variables.py +15 -24
  15. nuitka/Version.py +16 -6
  16. nuitka/__main__.py +15 -0
  17. nuitka/__past__.py +15 -17
  18. nuitka/build/Backend.scons +44 -35
  19. nuitka/build/CCompilerVersion.scons +10 -9
  20. nuitka/build/Onefile.scons +11 -26
  21. nuitka/build/SconsCaching.py +2 -0
  22. nuitka/build/SconsCompilerSettings.py +72 -22
  23. nuitka/build/SconsHacks.py +1 -0
  24. nuitka/build/SconsInterface.py +5 -0
  25. nuitka/build/SconsSpawn.py +16 -3
  26. nuitka/build/SconsUtils.py +11 -12
  27. nuitka/build/include/nuitka/checksum_tools.h +0 -4
  28. nuitka/build/include/nuitka/compiled_asyncgen.h +1 -1
  29. nuitka/build/include/nuitka/compiled_coroutine.h +1 -1
  30. nuitka/build/include/nuitka/compiled_frame.h +7 -4
  31. nuitka/build/include/nuitka/compiled_function.h +13 -3
  32. nuitka/build/include/nuitka/compiled_generator.h +1 -1
  33. nuitka/build/include/nuitka/constants.h +2 -0
  34. nuitka/build/include/nuitka/environment_variables.h +45 -0
  35. nuitka/build/include/nuitka/exceptions.h +32 -4
  36. nuitka/build/include/nuitka/filesystem_paths.h +6 -1
  37. nuitka/build/include/nuitka/freelists.h +11 -1
  38. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  39. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  40. nuitka/build/include/nuitka/helpers.h +2 -0
  41. nuitka/build/include/nuitka/importing.h +3 -0
  42. nuitka/build/include/nuitka/prelude.h +17 -6
  43. nuitka/build/include/nuitka/unfreezing.h +1 -1
  44. nuitka/build/inline_copy/bin/scons.py +14 -0
  45. nuitka/build/inline_copy/tqdm/tqdm/__init__.py +2 -2
  46. nuitka/build/inline_copy/tqdm/tqdm/utils.py +14 -8
  47. nuitka/build/inline_copy/zlib/LICENSE +22 -0
  48. nuitka/build/inline_copy/zlib/crc32.c +1049 -0
  49. nuitka/build/inline_copy/zlib/crc32.h +9446 -0
  50. nuitka/build/inline_copy/zlib/zconf.h +551 -0
  51. nuitka/build/inline_copy/zlib/zlib.h +1938 -0
  52. nuitka/build/inline_copy/zlib/zutil.h +275 -0
  53. nuitka/build/static_src/CompiledAsyncgenType.c +41 -41
  54. nuitka/build/static_src/CompiledCodeHelpers.c +14 -7
  55. nuitka/build/static_src/CompiledCoroutineType.c +60 -51
  56. nuitka/build/static_src/CompiledFrameType.c +12 -12
  57. nuitka/build/static_src/CompiledFunctionType.c +149 -28
  58. nuitka/build/static_src/CompiledGeneratorType.c +64 -65
  59. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +1 -1
  60. nuitka/build/static_src/CompiledMethodType.c +5 -3
  61. nuitka/build/static_src/HelperEnvironmentVariables.c +120 -0
  62. nuitka/build/static_src/HelpersAttributes.c +1 -1
  63. nuitka/build/static_src/HelpersBuiltin.c +1 -1
  64. nuitka/build/static_src/HelpersChecksumTools.c +19 -4
  65. nuitka/build/static_src/HelpersComparisonEq.c +4 -4
  66. nuitka/build/static_src/HelpersComparisonNe.c +4 -4
  67. nuitka/build/static_src/HelpersConstantsBlob.c +40 -23
  68. nuitka/build/static_src/HelpersDictionaries.c +3 -1
  69. nuitka/build/static_src/HelpersDictionariesGenerated.c +9 -9
  70. nuitka/build/static_src/HelpersFilesystemPaths.c +12 -2
  71. nuitka/build/static_src/HelpersImport.c +29 -1
  72. nuitka/build/static_src/HelpersImportHard.c +19 -0
  73. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +5 -4
  74. nuitka/build/static_src/HelpersPythonPgo.c +5 -5
  75. nuitka/build/static_src/HelpersSafeStrings.c +2 -1
  76. nuitka/build/static_src/HelpersStrings.c +12 -10
  77. nuitka/build/static_src/HelpersTypes.c +1 -1
  78. nuitka/build/static_src/InspectPatcher.c +3 -2
  79. nuitka/build/static_src/MainProgram.c +182 -214
  80. nuitka/build/static_src/MetaPathBasedLoader.c +36 -23
  81. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +4 -2
  82. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +38 -2
  83. nuitka/build/static_src/OnefileBootstrap.c +124 -93
  84. nuitka/code_generation/CodeGeneration.py +4 -2
  85. nuitka/code_generation/CodeObjectCodes.py +5 -1
  86. nuitka/code_generation/ConstantCodes.py +4 -0
  87. nuitka/code_generation/Contexts.py +111 -3
  88. nuitka/code_generation/DictCodes.py +5 -5
  89. nuitka/code_generation/FunctionCodes.py +4 -2
  90. nuitka/code_generation/GlobalConstants.py +10 -0
  91. nuitka/code_generation/ImportCodes.py +69 -33
  92. nuitka/code_generation/ModuleCodes.py +4 -1
  93. nuitka/code_generation/Namify.py +6 -5
  94. nuitka/code_generation/YieldCodes.py +3 -3
  95. nuitka/code_generation/templates/CodeTemplatesModules.py +61 -95
  96. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +3 -3
  97. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +2 -2
  98. nuitka/distutils/DistutilCommands.py +3 -0
  99. nuitka/finalizations/FinalizeMarkups.py +1 -1
  100. nuitka/freezer/DependsExe.py +2 -1
  101. nuitka/freezer/DllDependenciesPosix.py +11 -1
  102. nuitka/freezer/IncludedEntryPoints.py +54 -16
  103. nuitka/freezer/Onefile.py +7 -3
  104. nuitka/freezer/Standalone.py +39 -17
  105. nuitka/importing/Importing.py +195 -62
  106. nuitka/importing/PreloadedPackages.py +2 -1
  107. nuitka/importing/Recursion.py +98 -27
  108. nuitka/importing/StandardLibrary.py +7 -4
  109. nuitka/nodes/BuiltinOpenNodes.py +28 -1
  110. nuitka/nodes/BuiltinRangeNodes.py +2 -2
  111. nuitka/nodes/BuiltinSumNodes.py +1 -1
  112. nuitka/nodes/ChildrenHavingMixins.py +326 -2
  113. nuitka/nodes/HardImportNodesGenerated.py +141 -38
  114. nuitka/nodes/ImportHardNodes.py +0 -8
  115. nuitka/nodes/ImportNodes.py +267 -361
  116. nuitka/nodes/IterationHandles.py +36 -17
  117. nuitka/nodes/LocalsScopes.py +3 -1
  118. nuitka/nodes/NodeBases.py +8 -14
  119. nuitka/nodes/OperatorNodes.py +9 -9
  120. nuitka/nodes/OutlineNodes.py +3 -3
  121. nuitka/nodes/PackageMetadataNodes.py +19 -9
  122. nuitka/nodes/SliceNodes.py +1 -1
  123. nuitka/nodes/VariableAssignNodes.py +25 -15
  124. nuitka/nodes/VariableRefNodes.py +7 -7
  125. nuitka/nodes/YieldNodes.py +2 -2
  126. nuitka/nodes/shapes/BuiltinTypeShapes.py +81 -6
  127. nuitka/nodes/shapes/ShapeMixins.py +21 -0
  128. nuitka/nodes/shapes/StandardShapes.py +9 -3
  129. nuitka/optimizations/OptimizeBuiltinCalls.py +1 -1
  130. nuitka/optimizations/TraceCollections.py +75 -0
  131. nuitka/pgo/PGO.py +14 -6
  132. nuitka/plugins/PluginBase.py +83 -11
  133. nuitka/plugins/Plugins.py +78 -35
  134. nuitka/plugins/standard/AntiBloatPlugin.py +46 -1
  135. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +1 -1
  136. nuitka/plugins/standard/DelvewheelPlugin.py +2 -1
  137. nuitka/plugins/standard/DillPlugin.py +3 -99
  138. nuitka/plugins/standard/DllFilesPlugin.py +45 -0
  139. nuitka/plugins/standard/GiPlugin.py +23 -10
  140. nuitka/plugins/standard/GlfwPlugin.py +1 -0
  141. nuitka/plugins/standard/ImplicitImports.py +267 -15
  142. nuitka/plugins/standard/KivyPlugin.py +1 -0
  143. nuitka/plugins/standard/MatplotlibPlugin.py +43 -25
  144. nuitka/plugins/standard/OptionsNannyPlugin.py +5 -6
  145. nuitka/plugins/standard/PkgResourcesPlugin.py +1 -1
  146. nuitka/plugins/standard/PmwPlugin.py +1 -1
  147. nuitka/plugins/standard/PySidePyQtPlugin.py +37 -20
  148. nuitka/plugins/standard/TkinterPlugin.py +44 -30
  149. nuitka/plugins/standard/TransformersPlugin.py +3 -1
  150. nuitka/plugins/standard/standard.nuitka-package.config.yml +522 -86
  151. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +8 -1
  152. nuitka/reports/CompilationReportReader.py +53 -0
  153. nuitka/reports/LicenseReport.rst.j2 +4 -4
  154. nuitka/reports/Reports.py +129 -47
  155. nuitka/specs/HardImportSpecs.py +6 -0
  156. nuitka/tools/data_composer/DataComposer.py +29 -17
  157. nuitka/tools/onefile_compressor/OnefileCompressor.py +173 -110
  158. nuitka/tools/podman/__main__.py +17 -2
  159. nuitka/tools/scanning/DisplayPackageDLLs.py +11 -2
  160. nuitka/tools/scanning/DisplayPackageData.py +1 -1
  161. nuitka/tools/specialize/CTypeDescriptions.py +36 -27
  162. nuitka/tools/specialize/SpecializeC.py +1 -1
  163. nuitka/tools/specialize/SpecializePython.py +16 -0
  164. nuitka/tools/testing/Common.py +3 -4
  165. nuitka/tools/testing/OutputComparison.py +23 -0
  166. nuitka/tools/testing/SearchModes.py +2 -2
  167. nuitka/tools/testing/compare_with_cpython/__main__.py +13 -4
  168. nuitka/tools/testing/measure_construct_performance/__main__.py +2 -5
  169. nuitka/tools/watch/__main__.py +194 -56
  170. nuitka/tree/Building.py +8 -2
  171. nuitka/tree/ComplexCallHelperFunctions.py +45 -15
  172. nuitka/tree/ReformulationAssignmentStatements.py +18 -12
  173. nuitka/tree/ReformulationCallExpressions.py +1 -1
  174. nuitka/tree/ReformulationClasses.py +11 -5
  175. nuitka/tree/ReformulationClasses3.py +30 -12
  176. nuitka/tree/ReformulationComparisonExpressions.py +4 -2
  177. nuitka/tree/ReformulationContractionExpressions.py +19 -11
  178. nuitka/tree/ReformulationDictionaryCreation.py +9 -3
  179. nuitka/tree/ReformulationExecStatements.py +6 -6
  180. nuitka/tree/ReformulationForLoopStatements.py +5 -5
  181. nuitka/tree/ReformulationFunctionStatements.py +6 -2
  182. nuitka/tree/ReformulationImportStatements.py +7 -2
  183. nuitka/tree/ReformulationLambdaExpressions.py +1 -1
  184. nuitka/tree/ReformulationMatchStatements.py +3 -1
  185. nuitka/tree/ReformulationNamespacePackages.py +7 -3
  186. nuitka/tree/ReformulationPrintStatements.py +1 -1
  187. nuitka/tree/ReformulationSequenceCreation.py +18 -6
  188. nuitka/tree/ReformulationWithStatements.py +8 -8
  189. nuitka/tree/ReformulationYieldExpressions.py +2 -2
  190. nuitka/tree/SourceHandling.py +27 -5
  191. nuitka/tree/VariableClosure.py +11 -1
  192. nuitka/utils/AppDirs.py +2 -2
  193. nuitka/utils/CStrings.py +39 -3
  194. nuitka/utils/CommandLineOptions.py +42 -1
  195. nuitka/utils/Distributions.py +305 -38
  196. nuitka/utils/Download.py +27 -8
  197. nuitka/utils/FileOperations.py +103 -20
  198. nuitka/utils/Hashing.py +2 -3
  199. nuitka/utils/Importing.py +60 -3
  200. nuitka/utils/InstalledPythons.py +31 -36
  201. nuitka/utils/Jinja2.py +11 -5
  202. nuitka/utils/ModuleNames.py +11 -3
  203. nuitka/utils/ReExecute.py +7 -0
  204. nuitka/utils/SharedLibraries.py +38 -14
  205. nuitka/utils/SlotMetaClasses.py +55 -0
  206. nuitka/utils/Utils.py +10 -0
  207. nuitka/utils/Yaml.py +9 -1
  208. nuitka/build/inline_copy/tqdm/tqdm/_tqdm_gui.py +0 -9
  209. nuitka/build/inline_copy/tqdm/tqdm/gui.py +0 -191
  210. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka-run.bat +0 -0
  211. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka.bat +0 -0
  212. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/LICENSE.txt +0 -0
  213. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/entry_points.txt +0 -0
  214. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/top_level.txt +0 -0
@@ -47,10 +47,8 @@
47
47
  #define SYSFLAG_BYTES_WARNING 0
48
48
  #define SYSFLAG_UTF8 0
49
49
  #define SYSFLAG_UNBUFFERED 0
50
- #endif
51
-
52
- #ifndef NUITKA_MAIN_MODULE_NAME
53
50
  #define NUITKA_MAIN_MODULE_NAME "__main__"
51
+ #define NUITKA_MAIN_IS_PACKAGE_BOOL false
54
52
  #endif
55
53
 
56
54
  // It doesn't work for MinGW64 to update the standard output handles early on,
@@ -118,112 +116,7 @@ static void prepareFrozenModules(void) {
118
116
  }
119
117
  #endif
120
118
 
121
- #if SYSFLAG_NO_RANDOMIZATION == 1 || SYSFLAG_UNBUFFERED == 1 || defined(_NUITKA_STANDALONE)
122
-
123
- #if defined(_WIN32)
124
- #define environment_char_t wchar_t
125
-
126
- static environment_char_t const *getEnvironmentVariable(char const *name) {
127
- // Max size for environment variables according to docs.
128
- wchar_t buffer[32768];
129
- buffer[0] = 0;
130
-
131
- wchar_t name_wide[40];
132
- name_wide[0] = 0;
133
- appendStringSafeW(name_wide, name, sizeof(name_wide) / sizeof(wchar_t));
134
-
135
- // Size must be in bytes apparently, not in characters. Cannot be larger anyway.
136
- DWORD res = GetEnvironmentVariableW(name_wide, buffer, 65536);
137
-
138
- if (res == 0 || res > sizeof(buffer)) {
139
- return NULL;
140
- }
141
-
142
- return wcsdup(buffer);
143
- }
144
-
145
- static void setEnvironmentVariable(char const *name, environment_char_t const *value) {
146
- assert(name != NULL);
147
- assert(value != NULL);
148
-
149
- wchar_t name_wide[40];
150
- name_wide[0] = 0;
151
- appendStringSafeW(name_wide, name, sizeof(name_wide) / sizeof(wchar_t));
152
-
153
- DWORD res = SetEnvironmentVariableW(name_wide, value);
154
- assert(wcscmp(getEnvironmentVariable(name), value) == 0);
155
-
156
- assert(res != 0);
157
- }
158
-
159
- static void unsetEnvironmentVariable(char const *name) {
160
- wchar_t name_wide[40];
161
- name_wide[0] = 0;
162
- appendStringSafeW(name_wide, name, sizeof(name_wide) / sizeof(wchar_t));
163
-
164
- DWORD res = SetEnvironmentVariableW(name_wide, NULL);
165
-
166
- assert(res != 0);
167
- }
168
-
169
- #define makeEnvironmentLiteral(x) L##x
170
-
171
- #else
172
- #define environment_char_t char
173
-
174
- #define makeEnvironmentLiteral(x) x
175
-
176
- static environment_char_t const *getEnvironmentVariable(char const *name) { return getenv(name); }
177
-
178
- static void setEnvironmentVariable(char const *name, environment_char_t const *value) { setenv(name, value, 1); }
179
-
180
- static void unsetEnvironmentVariable(char const *name) { unsetenv(name); }
181
-
182
- #endif
183
-
184
- static void undoEnvironmentVariable(PyThreadState *tstate, char const *variable_name,
185
- environment_char_t const *old_value) {
186
- PyObject *os_module = IMPORT_HARD_OS();
187
- CHECK_OBJECT(os_module);
188
-
189
- PyObject *os_environ = PyObject_GetAttrString(os_module, "environ");
190
- CHECK_OBJECT(os_environ);
191
-
192
- PyObject *variable_name_str = Nuitka_String_FromString(variable_name);
193
- CHECK_OBJECT(variable_name_str);
194
-
195
- if (old_value) {
196
- setEnvironmentVariable(variable_name, old_value);
197
-
198
- #ifdef _WIN32
199
- PyObject *env_value = NuitkaUnicode_FromWideChar(old_value, -1);
200
- #else
201
- PyObject *env_value = Nuitka_String_FromString(old_value);
202
- #endif
203
- CHECK_OBJECT(env_value);
204
-
205
- int res = PyObject_SetItem(os_environ, variable_name_str, env_value);
206
-
207
- if (unlikely(res != 0)) {
208
- PyErr_PrintEx(1);
209
- Py_Exit(1);
210
- }
211
-
212
- Py_DECREF(env_value);
213
- } else {
214
- unsetEnvironmentVariable(variable_name);
215
-
216
- int res = PyObject_DelItem(os_environ, variable_name_str);
217
-
218
- if (unlikely(res != 0)) {
219
- CLEAR_ERROR_OCCURRED(tstate);
220
- }
221
- }
222
-
223
- Py_DECREF(variable_name_str);
224
- Py_DECREF(os_environ);
225
- }
226
- #endif
119
+ #include "nuitka/environment_variables.h"
227
120
 
228
121
  #ifdef _NUITKA_STANDALONE
229
122
 
@@ -374,17 +267,16 @@ static void PRINT_REFCOUNTS(void) {
374
267
  }
375
268
  #endif
376
269
 
377
- static int HANDLE_PROGRAM_EXIT(void) {
270
+ static int HANDLE_PROGRAM_EXIT(PyThreadState *tstate) {
378
271
  #if _DEBUG_REFCOUNTS
379
272
  PRINT_REFCOUNTS();
380
273
  #endif
381
274
 
382
275
  int exit_code;
383
276
 
384
- PyThreadState *tstate = PyThreadState_GET();
385
-
386
277
  if (HAS_ERROR_OCCURRED(tstate)) {
387
- #if PYTHON_VERSION >= 0x300
278
+ // TODO: Clarify which versions this applies to still
279
+ #if PYTHON_VERSION >= 0x300 && PYTHON_VERSION < 0x3c0
388
280
  /* Remove the frozen importlib traceback part, which would not be compatible. */
389
281
 
390
282
  while (tstate->curexc_traceback) {
@@ -402,6 +294,7 @@ static int HANDLE_PROGRAM_EXIT(void) {
402
294
  break;
403
295
  }
404
296
  #endif
297
+ NUITKA_FINALIZE_PROGRAM(tstate);
405
298
 
406
299
  PyErr_PrintEx(0);
407
300
 
@@ -413,13 +306,10 @@ static int HANDLE_PROGRAM_EXIT(void) {
413
306
  return exit_code;
414
307
  }
415
308
 
416
- static PyObject *EXECUTE_MAIN_MODULE(char const *module_name) {
309
+ static PyObject *EXECUTE_MAIN_MODULE(PyThreadState *tstate, char const *module_name, bool is_package) {
417
310
  NUITKA_INIT_PROGRAM_LATE(module_name);
418
311
 
419
- PyThreadState *tstate = PyThreadState_GET();
420
-
421
- #if NUITKA_MAIN_PACKAGE_MODE
422
- {
312
+ if (is_package) {
423
313
  char const *w = module_name;
424
314
 
425
315
  for (;;) {
@@ -442,7 +332,6 @@ static PyObject *EXECUTE_MAIN_MODULE(char const *module_name) {
442
332
  }
443
333
  }
444
334
  }
445
- #endif
446
335
 
447
336
  return IMPORT_EMBEDDED_MODULE(tstate, module_name);
448
337
  }
@@ -452,10 +341,10 @@ static PyObject *EXECUTE_MAIN_MODULE(char const *module_name) {
452
341
 
453
342
  // Callback from Windows Service logic.
454
343
  bool SvcStartPython(void) {
455
- EXECUTE_MAIN_MODULE(NUITKA_MAIN_MODULE_NAME);
456
-
457
344
  PyThreadState *tstate = PyThreadState_GET();
458
345
 
346
+ EXECUTE_MAIN_MODULE(tstate, NUITKA_MAIN_MODULE_NAME, NUITKA_MAIN_IS_PACKAGE_BOOL);
347
+
459
348
  if (HAS_ERROR_OCCURRED(tstate)) {
460
349
  return true;
461
350
  } else {
@@ -473,107 +362,117 @@ static bool is_multiprocessing_fork = false;
473
362
  static int multiprocessing_resource_tracker_arg = -1;
474
363
 
475
364
  // This is a joblib loky fork
365
+ #ifdef _WIN32
366
+ static bool is_joblib_popen_loky_win32 = false;
367
+ static int loky_joblib_pipe_handle_arg = 0;
368
+ static int loky_joblib_parent_pid_arg = 0;
369
+ #else
476
370
  static bool is_joblib_popen_loky_posix = false;
371
+ #endif
477
372
  // This is a joblib resource tracker if not -1
478
373
  static int loky_resource_tracker_arg = -1;
479
374
 
480
- // Parse the command line parameters and provide it to "sys" built-in module,
481
- // as well as decide if it's a multiprocessing usage.
375
+ // Parse the command line parameters to decide if it's a multiprocessing usage
376
+ // or something else special.
482
377
  #if _NUITKA_NATIVE_WCHAR_ARGV == 0
483
- static void setCommandLineParameters(int argc, char **argv, bool initial) {
378
+ static void setCommandLineParameters(int argc, char **argv) {
484
379
  #else
485
- static void setCommandLineParameters(int argc, wchar_t **argv, bool initial) {
380
+ static void setCommandLineParameters(int argc, wchar_t **argv) {
486
381
  #endif
487
- if (initial) {
488
382
  #ifdef _NUITKA_EXPERIMENTAL_DEBUG_SELF_FORKING
489
383
  #if _NUITKA_NATIVE_WCHAR_ARGV == 0
490
- printf("Commandline: ");
491
- for (int i = 0; i < argc; i++) {
492
- if (i != 0) {
493
- printf(" ");
494
- }
495
- printf("'%s'", argv[i]);
384
+ printf("Commandline: ");
385
+ for (int i = 0; i < argc; i++) {
386
+ if (i != 0) {
387
+ printf(" ");
496
388
  }
497
- printf("\n");
389
+ printf("'%s'", argv[i]);
390
+ }
391
+ printf("\n");
498
392
  #else
499
- wprintf(L"Commandline: '%lS' %d\n", GetCommandLineW(), argc);
393
+ wprintf(L"Commandline: '%lS' %d\n", GetCommandLineW(), argc);
500
394
  #endif
501
395
  #endif
502
396
 
503
- // We might need to handle special parameters from plugins that are
504
- // very deeply woven into command line handling. These are right now
505
- // multiprocessing, which indicates that it's forking via extra
397
+ // We might need to handle special parameters from plugins that are
398
+ // very deeply woven into command line handling. These are right now
399
+ // multiprocessing, which indicates that it's forking via extra
506
400
 
507
- // command line argument. And Windows Service indicates need to
508
- // install and exit here too.
401
+ // command line argument. And Windows Service indicates need to
402
+ // install and exit here too.
509
403
 
510
- for (int i = 1; i < argc; i++) {
511
- if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "--multiprocessing-fork")) == 0) {
512
- is_multiprocessing_fork = true;
513
- break;
514
- }
404
+ for (int i = 1; i < argc; i++) {
405
+ if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "--multiprocessing-fork")) == 0) {
406
+ is_multiprocessing_fork = true;
407
+ break;
408
+ }
515
409
 
516
- if ((i + 1 < argc) &&
517
- (strcmpFilename(argv[i], FILENAME_EMPTY_STR "--multiprocessing-resource-tracker")) == 0) {
410
+ if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "--multiprocessing-resource-tracker")) == 0) {
518
411
  #if _NUITKA_NATIVE_WCHAR_ARGV == 0
519
- multiprocessing_resource_tracker_arg = atoi(argv[i + 1]);
412
+ multiprocessing_resource_tracker_arg = atoi(argv[i + 1]);
520
413
  #else
521
- multiprocessing_resource_tracker_arg = _wtoi(argv[i + 1]);
414
+ multiprocessing_resource_tracker_arg = _wtoi(argv[i + 1]);
522
415
  #endif
523
- break;
524
- }
416
+ break;
417
+ }
525
418
 
526
- if (i == 1) {
419
+ if (i == 1) {
527
420
  #ifdef _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
528
- if (strcmpFilename(argv[i], FILENAME_EMPTY_STR "install") == 0) {
529
- NUITKA_PRINT_TRACE("main(): Calling plugin SvcInstall().");
421
+ if (strcmpFilename(argv[i], FILENAME_EMPTY_STR "install") == 0) {
422
+ NUITKA_PRINT_TRACE("main(): Calling plugin SvcInstall().");
530
423
 
531
- SvcInstall();
532
- NUITKA_CANNOT_GET_HERE("SvcInstall must not return");
533
- }
534
- #endif
424
+ SvcInstall();
425
+ NUITKA_CANNOT_GET_HERE("SvcInstall must not return");
535
426
  }
536
-
537
- if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "-c") == 0)) {
538
- // The joblib loky resource tracker is launched like this.
539
- #if _NUITKA_NATIVE_WCHAR_ARGV == 0
540
- int res = sscanf(argv[i + 1],
541
- "from joblib.externals.loky.backend.resource_tracker import main; main(%i, False)",
542
- &loky_resource_tracker_arg);
543
- #else
544
- int res = swscanf(argv[i + 1],
545
- L"from joblib.externals.loky.backend.resource_tracker import main; main(%i, False)",
546
- &loky_resource_tracker_arg);
547
427
  #endif
548
- if (res == 1) {
549
- break;
550
- }
428
+ }
429
+
430
+ if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "-c") == 0)) {
431
+ // The joblib loky resource tracker is launched like this.
432
+ if (scanFilename(argv[i + 1],
433
+ FILENAME_EMPTY_STR
434
+ "from joblib.externals.loky.backend.resource_tracker import main; main(%i, False)",
435
+ &loky_resource_tracker_arg)) {
436
+ break;
551
437
  }
552
438
 
553
- if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "-m") == 0)) {
554
- // The joblib loky posix popen is launching like this.
555
- if (strcmpFilename(argv[i + 1], FILENAME_EMPTY_STR "joblib.externals.loky.backend.popen_loky_posix") ==
556
- 0) {
557
- is_joblib_popen_loky_posix = true;
558
- break;
559
- }
439
+ #if defined(_WIN32)
440
+ if (strcmpFilename(argv[i + 1], FILENAME_EMPTY_STR
441
+ "from joblib.externals.loky.backend.popen_loky_win32 import main; main()") == 0) {
442
+ is_joblib_popen_loky_win32 = true;
443
+ break;
560
444
  }
561
445
 
562
- #if !defined(_NUITKA_DEPLOYMENT_MODE) && !defined(_NUITKA_NO_DEPLOYMENT_SELF_EXECUTION)
563
- if ((strcmpFilename(argv[i], FILENAME_EMPTY_STR "-c") == 0) ||
564
- (strcmpFilename(argv[i], FILENAME_EMPTY_STR "-m") == 0)) {
565
- fprintf(stderr,
566
- "Error, the program tried to call itself with '" FILENAME_FORMAT_STR "' argument. Disable with "
567
- "'--no-deployment-flag=self-execution'.\n",
568
- argv[i]);
569
- exit(2);
446
+ if (scanFilename(argv[i + 1],
447
+ FILENAME_EMPTY_STR "from joblib.externals.loky.backend.popen_loky_win32 import main; "
448
+ "main(pipe_handle=%i, parent_pid=%i)",
449
+ &loky_joblib_pipe_handle_arg, &loky_joblib_parent_pid_arg)) {
450
+ is_joblib_popen_loky_win32 = true;
451
+ break;
570
452
  }
453
+
571
454
  #endif
572
455
  }
573
456
 
574
- #ifdef _NUITKA_EXPERIMENTAL_DEBUG_SELF_FORKING
575
- assert(argc == 1 || is_multiprocessing_fork || is_joblib_popen_loky_posix || loky_resource_tracker_arg != -1 ||
576
- multiprocessing_resource_tracker_arg != -1);
457
+ #if !defined(_WIN32)
458
+ if ((i + 1 < argc) && (strcmpFilename(argv[i], FILENAME_EMPTY_STR "-m") == 0)) {
459
+ // The joblib loky posix popen is launching like this.
460
+ if (strcmpFilename(argv[i + 1], FILENAME_EMPTY_STR "joblib.externals.loky.backend.popen_loky_posix") == 0) {
461
+ is_joblib_popen_loky_posix = true;
462
+ break;
463
+ }
464
+ }
465
+ #endif
466
+
467
+ #if !defined(_NUITKA_DEPLOYMENT_MODE) && !defined(_NUITKA_NO_DEPLOYMENT_SELF_EXECUTION)
468
+ if ((strcmpFilename(argv[i], FILENAME_EMPTY_STR "-c") == 0) ||
469
+ (strcmpFilename(argv[i], FILENAME_EMPTY_STR "-m") == 0)) {
470
+ fprintf(stderr,
471
+ "Error, the program tried to call itself with '" FILENAME_FORMAT_STR "' argument. Disable with "
472
+ "'--no-deployment-flag=self-execution'.\n",
473
+ argv[i]);
474
+ exit(2);
475
+ }
577
476
  #endif
578
477
  }
579
478
  }
@@ -1028,8 +927,7 @@ static void Nuitka_Py_Initialize(void) {
1028
927
  if (unlikely(status._type != 0)) {
1029
928
  Py_ExitStatusException(status);
1030
929
  }
1031
- _PyRuntimeState *runtime = &_PyRuntime;
1032
-
930
+ NUITKA_MAY_BE_UNUSED _PyRuntimeState *runtime = &_PyRuntime;
1033
931
  assert(!runtime->initialized);
1034
932
 
1035
933
  PyConfig config;
@@ -1059,6 +957,25 @@ static void Nuitka_Py_Initialize(void) {
1059
957
  config.module_search_paths_set = 1;
1060
958
  #endif
1061
959
 
960
+ // Need to disable frozen modules, Nuitka can handle them better itself.
961
+ #if PYTHON_VERSION >= 0x3b0
962
+ #ifdef _NUITKA_STANDALONE
963
+ config.use_frozen_modules = 0;
964
+ #else
965
+ // Emulate PYTHON_FROZEN_MODULES for accelerated mode, it is only added in 3.13,
966
+ // but we need to control it for controlling things for accelerated binaries
967
+ // too.
968
+ #if PYTHON_VERSION >= 0x3b0 && PYTHON_VERSION <= 0x3d0
969
+ environment_char_t const *frozen_modules_env = getEnvironmentVariable("PYTHON_FROZEN_MODULES");
970
+
971
+ if (frozen_modules_env == NULL ||
972
+ (compareEnvironmentString(frozen_modules_env, makeEnvironmentLiteral("off")) == 0)) {
973
+ config.use_frozen_modules = 0;
974
+ }
975
+ #endif
976
+ #endif
977
+ #endif
978
+
1062
979
  config.install_signal_handlers = 1;
1063
980
 
1064
981
  NUITKA_PRINT_TIMING("Nuitka_Py_Initialize(): Calling Py_InitializeFromConfig.");
@@ -1195,6 +1112,10 @@ static void changeStandardHandleTarget(FILE *std_handle, filename_char_t const *
1195
1112
  #endif
1196
1113
  #endif
1197
1114
 
1115
+ #if defined(_NUITKA_EXPERIMENTAL_SHOW_STARTUP_TIME)
1116
+ static void Nuitka_at_exit(void) { NUITKA_PRINT_TIMING("Nuitka_at_exit(): Called by C exit()"); }
1117
+ #endif
1118
+
1198
1119
  #ifdef _NUITKA_WINMAIN_ENTRY_POINT
1199
1120
  int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpCmdLine, int nCmdShow) {
1200
1121
  /* MSVC, MINGW64 */
@@ -1208,6 +1129,11 @@ int main(int argc, char **argv) {
1208
1129
  #endif
1209
1130
  #endif
1210
1131
 
1132
+ // Trace when the process exits.
1133
+ #if defined(_NUITKA_EXPERIMENTAL_SHOW_STARTUP_TIME)
1134
+ atexit(Nuitka_at_exit);
1135
+ #endif
1136
+
1211
1137
  // First things, set up stdout/stderr according to user specification.
1212
1138
  #if NUITKA_STANDARD_HANDLES_EARLY == 1
1213
1139
  #if defined(NUITKA_FORCED_STDOUT_PATH)
@@ -1239,6 +1165,8 @@ int main(int argc, char **argv) {
1239
1165
  setbuf(stderr, (char *)NULL);
1240
1166
 
1241
1167
  #if PYTHON_VERSION >= 0x300
1168
+ // spell-checker: ignore PYTHONUNBUFFERED
1169
+
1242
1170
  environment_char_t const *old_env_unbuffered = getEnvironmentVariable("PYTHONUNBUFFERED");
1243
1171
  setEnvironmentVariable("PYTHONUNBUFFERED", makeEnvironmentLiteral("1"));
1244
1172
  #endif
@@ -1248,7 +1176,8 @@ int main(int argc, char **argv) {
1248
1176
  NUITKA_INIT_PROGRAM_EARLY(argc, argv);
1249
1177
 
1250
1178
  #ifdef __FreeBSD__
1251
- /* FP exceptions run in "no stop" mode by default */
1179
+ // FP exceptions run in "no stop" mode by default
1180
+ // spell-checker: ignore fpgetmask,fpsetmask
1252
1181
 
1253
1182
  fp_except_t m;
1254
1183
 
@@ -1336,8 +1265,8 @@ orig_argv = argv;
1336
1265
  orig_argc = argc;
1337
1266
 
1338
1267
  // Early command line parsing.
1339
- NUITKA_PRINT_TRACE("main(): Calling initial setCommandLineParameters.");
1340
- setCommandLineParameters(argc, argv, true);
1268
+ NUITKA_PRINT_TRACE("main(): Calling setCommandLineParameters.");
1269
+ setCommandLineParameters(argc, argv);
1341
1270
 
1342
1271
  /* For Python installations that need the home set, we inject it back here. */
1343
1272
  #if defined(PYTHON_HOME_PATH)
@@ -1407,9 +1336,6 @@ orig_argv = argv;
1407
1336
  Py_NoSiteFlag = SYSFLAG_NO_SITE;
1408
1337
 
1409
1338
  /* Set the command line parameters for run time usage. */
1410
- NUITKA_PRINT_TRACE("main(): Calling setCommandLineParameters.");
1411
- setCommandLineParameters(argc, argv, false);
1412
-
1413
1339
  PySys_SetArgv(argc, orig_argv);
1414
1340
  // Empty "sys.path" again, the above adds program directory to it.
1415
1341
  #if SYSFLAG_ISOLATED
@@ -1487,8 +1413,10 @@ orig_argv = argv;
1487
1413
  #if PYTHON_VERSION >= 0x300
1488
1414
  // Make sure the importlib fully bootstraps as we couldn't load it with the
1489
1415
  // standard loader.
1490
- PyObject *importlib_module = getImportLibBootstrapModule();
1491
- CHECK_OBJECT(importlib_module);
1416
+ {
1417
+ NUITKA_MAY_BE_UNUSED PyObject *importlib_module = getImportLibBootstrapModule();
1418
+ CHECK_OBJECT(importlib_module);
1419
+ }
1492
1420
  #endif
1493
1421
 
1494
1422
  NUITKA_PRINT_TRACE("main(): Calling setEarlyFrozenModulesFileAttribute().");
@@ -1510,7 +1438,7 @@ orig_argv = argv;
1510
1438
 
1511
1439
  #if NO_PYTHON_WARNINGS && PYTHON_VERSION >= 0x342 && PYTHON_VERSION < 0x3a0 && defined(_NUITKA_FULL_COMPAT)
1512
1440
  // For full compatibility bump the warnings registry version,
1513
- // otherwise modules "__warningsregistry__" will mismatch.
1441
+ // otherwise modules "__warningregistry__" will mismatch.
1514
1442
  PyObject *warnings_module = PyImport_ImportModule("warnings");
1515
1443
  PyObject *meth = PyObject_GetAttrString(warnings_module, "_filters_mutated");
1516
1444
 
@@ -1560,16 +1488,53 @@ orig_argv = argv;
1560
1488
  #ifdef _NUITKA_PLUGIN_MULTIPROCESSING_ENABLED
1561
1489
  if (unlikely(is_multiprocessing_fork)) {
1562
1490
  NUITKA_PRINT_TRACE("main(): Calling __parents_main__.");
1563
- EXECUTE_MAIN_MODULE("__parents_main__");
1491
+ EXECUTE_MAIN_MODULE(tstate, "__parents_main__", false);
1564
1492
 
1565
- int exit_code = HANDLE_PROGRAM_EXIT();
1493
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
1566
1494
 
1567
1495
  NUITKA_PRINT_TRACE("main(): Calling __parents_main__ Py_Exit.");
1568
1496
  Py_Exit(exit_code);
1497
+ #if defined(_WIN32)
1498
+ } else if (unlikely(is_joblib_popen_loky_win32)) {
1499
+ NUITKA_PRINT_TRACE("main(): Calling joblib.externals.loky.backend.popen_loky_win32.");
1500
+ PyObject *joblib_popen_loky_win32_module =
1501
+ EXECUTE_MAIN_MODULE(tstate, "joblib.externals.loky.backend.popen_loky_win32", true);
1502
+
1503
+ // Remove the "-c" and options part like CPython would do as well.
1504
+ PyObject *argv_list = Nuitka_SysGetObject("argv");
1505
+ Py_ssize_t size = PyList_Size(argv_list);
1506
+
1507
+ // Negative indexes are not supported by this function.
1508
+ int res = PyList_SetSlice(argv_list, 1, size - 2, const_tuple_empty);
1509
+ assert(res == 0);
1510
+
1511
+ PyObject *main_function = PyObject_GetAttrString(joblib_popen_loky_win32_module, "main");
1512
+ CHECK_OBJECT(main_function);
1513
+
1514
+ if (loky_joblib_pipe_handle_arg == 0) {
1515
+ CALL_FUNCTION_NO_ARGS(tstate, main_function);
1516
+ } else {
1517
+ char const *kw_keys[] = {"pipe_handle", "parent_pid"};
1518
+ PyObject *kw_values[] = {
1519
+ PyLong_FromLong(loky_joblib_pipe_handle_arg),
1520
+ PyLong_FromLong(loky_joblib_parent_pid_arg),
1521
+ };
1522
+
1523
+ PyObject *kw_args = MAKE_DICT_X_CSTR(kw_keys, kw_values, sizeof(kw_values) / sizeof(PyObject *));
1524
+
1525
+ CALL_FUNCTION_WITH_KEYARGS(tstate, main_function, kw_args);
1526
+ }
1527
+ static int loky_joblib_parent_pid_arg = 0;
1528
+
1529
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
1530
+
1531
+ NUITKA_PRINT_TRACE("main(): Calling 'joblib.externals.loky.backend.popen_loky_posix' Py_Exit.");
1532
+ Py_Exit(exit_code);
1533
+ #else
1569
1534
  } else if (unlikely(is_joblib_popen_loky_posix)) {
1570
1535
  NUITKA_PRINT_TRACE("main(): Calling joblib.externals.loky.backend.popen_loky_posix.");
1571
1536
  PyObject *joblib_popen_loky_posix_module =
1572
- EXECUTE_MAIN_MODULE("joblib.externals.loky.backend.popen_loky_posix");
1537
+ EXECUTE_MAIN_MODULE(tstate, "joblib.externals.loky.backend.popen_loky_posix", true);
1573
1538
 
1574
1539
  // Remove the "-m" like CPython would do as well.
1575
1540
  int res = PyList_SetSlice(Nuitka_SysGetObject("argv"), 0, 2, const_tuple_empty);
@@ -1580,35 +1545,38 @@ orig_argv = argv;
1580
1545
 
1581
1546
  CALL_FUNCTION_NO_ARGS(tstate, main_function);
1582
1547
 
1583
- int exit_code = HANDLE_PROGRAM_EXIT();
1548
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
1584
1549
 
1585
- NUITKA_PRINT_TRACE("main(): Calling joblib.externals.loky.backend.popen_loky_posix Py_Exit.");
1550
+ NUITKA_PRINT_TRACE("main(): Calling 'joblib.externals.loky.backend.popen_loky_posix' Py_Exit.");
1586
1551
  Py_Exit(exit_code);
1552
+ #endif
1587
1553
  } else if (unlikely(multiprocessing_resource_tracker_arg != -1)) {
1588
1554
  NUITKA_PRINT_TRACE("main(): Launching as 'multiprocessing.resource_tracker'.");
1589
- PyObject *resource_tracker_module = EXECUTE_MAIN_MODULE("multiprocessing.resource_tracker");
1555
+ PyObject *resource_tracker_module = EXECUTE_MAIN_MODULE(tstate, "multiprocessing.resource_tracker", true);
1590
1556
 
1591
1557
  PyObject *main_function = PyObject_GetAttrString(resource_tracker_module, "main");
1592
1558
  CHECK_OBJECT(main_function);
1593
1559
 
1594
1560
  CALL_FUNCTION_WITH_SINGLE_ARG(tstate, main_function, PyInt_FromLong(multiprocessing_resource_tracker_arg));
1595
1561
 
1596
- int exit_code = HANDLE_PROGRAM_EXIT();
1562
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
1597
1563
 
1598
- NUITKA_PRINT_TRACE("main(): Calling resource_tracker Py_Exit.");
1564
+ NUITKA_PRINT_TRACE("main(): Calling 'multiprocessing.resource_tracker' Py_Exit.");
1599
1565
  Py_Exit(exit_code);
1600
1566
  } else if (unlikely(loky_resource_tracker_arg != -1)) {
1601
1567
  NUITKA_PRINT_TRACE("main(): Launching as 'joblib.externals.loky.backend.resource_tracker'.");
1602
- PyObject *resource_tracker_module = EXECUTE_MAIN_MODULE("joblib.externals.loky.backend.resource_tracker");
1568
+ PyObject *resource_tracker_module =
1569
+ EXECUTE_MAIN_MODULE(tstate, "joblib.externals.loky.backend.resource_tracker", true);
1570
+ CHECK_OBJECT(resource_tracker_module);
1603
1571
 
1604
1572
  PyObject *main_function = PyObject_GetAttrString(resource_tracker_module, "main");
1605
1573
  CHECK_OBJECT(main_function);
1606
1574
 
1607
1575
  CALL_FUNCTION_WITH_SINGLE_ARG(tstate, main_function, PyInt_FromLong(loky_resource_tracker_arg));
1608
1576
 
1609
- int exit_code = HANDLE_PROGRAM_EXIT();
1577
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
1610
1578
 
1611
- NUITKA_PRINT_TRACE("main(): Calling resource_tracker Py_Exit.");
1579
+ NUITKA_PRINT_TRACE("main(): Calling 'joblib.externals.loky.backend.resource_tracker' Py_Exit.");
1612
1580
  Py_Exit(exit_code);
1613
1581
  } else {
1614
1582
  #endif
@@ -1632,7 +1600,7 @@ orig_argv = argv;
1632
1600
  #else
1633
1601
  /* Execute the "__main__" module. */
1634
1602
  NUITKA_PRINT_TIMING("main(): Calling " NUITKA_MAIN_MODULE_NAME ".");
1635
- EXECUTE_MAIN_MODULE(NUITKA_MAIN_MODULE_NAME);
1603
+ EXECUTE_MAIN_MODULE(tstate, NUITKA_MAIN_MODULE_NAME, NUITKA_MAIN_IS_PACKAGE_BOOL);
1636
1604
  NUITKA_PRINT_TIMING("main(): Exited from " NUITKA_MAIN_MODULE_NAME ".");
1637
1605
 
1638
1606
  #endif
@@ -1653,13 +1621,13 @@ orig_argv = argv;
1653
1621
  checkGlobalConstants();
1654
1622
 
1655
1623
  /* TODO: Walk over all loaded compiled modules, and make this kind of checks. */
1656
- #if !NUITKA_MAIN_PACKAGE_MODE
1624
+ #if !NUITKA_MAIN_IS_PACKAGE_BOOL
1657
1625
  checkModuleConstants___main__(tstate);
1658
1626
  #endif
1659
1627
 
1660
1628
  #endif
1661
1629
 
1662
- int exit_code = HANDLE_PROGRAM_EXIT();
1630
+ int exit_code = HANDLE_PROGRAM_EXIT(tstate);
1663
1631
 
1664
1632
  NUITKA_PRINT_TIMING("main(): Calling Py_Exit.");
1665
1633
  Py_Exit(exit_code);