Nuitka-winsvc 2.2.3__cp311-cp311-win_amd64.whl → 2.3__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.
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/METADATA +1 -1
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/RECORD +198 -197
- nuitka/Bytecodes.py +4 -2
- nuitka/HardImportRegistry.py +1 -0
- nuitka/MainControl.py +16 -10
- nuitka/ModuleRegistry.py +15 -0
- nuitka/OptionParsing.py +30 -8
- nuitka/Options.py +104 -44
- nuitka/PostProcessing.py +9 -8
- nuitka/PythonVersions.py +2 -1
- nuitka/Serialization.py +47 -30
- nuitka/Version.py +1 -1
- nuitka/build/Backend.scons +46 -19
- nuitka/build/CCompilerVersion.scons +3 -3
- nuitka/build/Onefile.scons +4 -4
- nuitka/build/SconsCaching.py +3 -2
- nuitka/build/SconsCompilerSettings.py +11 -5
- nuitka/build/SconsInterface.py +22 -6
- nuitka/build/SconsUtils.py +9 -1
- nuitka/build/include/nuitka/allocator.h +58 -2
- nuitka/build/include/nuitka/compiled_frame.h +48 -13
- nuitka/build/include/nuitka/compiled_function.h +4 -0
- nuitka/build/include/nuitka/constants.h +6 -0
- nuitka/build/include/nuitka/exception_groups.h +6 -6
- nuitka/build/include/nuitka/exceptions.h +3 -3
- nuitka/build/include/nuitka/freelists.h +11 -0
- nuitka/build/include/nuitka/helper/dictionaries.h +5 -4
- nuitka/build/include/nuitka/helper/lists.h +5 -5
- nuitka/build/include/nuitka/helper/lists_generated.h +12 -12
- nuitka/build/include/nuitka/helper/sequences.h +6 -0
- nuitka/build/include/nuitka/helper/slices.h +14 -8
- nuitka/build/include/nuitka/helper/subscripts.h +1 -184
- nuitka/build/include/nuitka/helper/tuples.h +42 -33
- nuitka/build/include/nuitka/importing.h +5 -0
- nuitka/build/include/nuitka/prelude.h +35 -2
- nuitka/build/include/nuitka/safe_string_ops.h +1 -0
- nuitka/build/include/nuitka/threading.h +13 -10
- nuitka/build/static_src/CompiledAsyncgenType.c +19 -8
- nuitka/build/static_src/CompiledCellType.c +1 -1
- nuitka/build/static_src/CompiledCodeHelpers.c +18 -16
- nuitka/build/static_src/CompiledCoroutineType.c +23 -19
- nuitka/build/static_src/CompiledFrameType.c +46 -34
- nuitka/build/static_src/CompiledFunctionType.c +55 -34
- nuitka/build/static_src/CompiledGeneratorType.c +21 -19
- nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +127 -130
- nuitka/build/static_src/CompiledMethodType.c +15 -17
- nuitka/build/static_src/HelpersAllocator.c +71 -0
- nuitka/build/static_src/HelpersAttributes.c +1 -1
- nuitka/build/static_src/HelpersBuiltin.c +5 -5
- nuitka/build/static_src/HelpersBytes.c +2 -2
- nuitka/build/static_src/HelpersCalling.c +3 -0
- nuitka/build/static_src/HelpersCallingGenerated.c +131 -131
- nuitka/build/static_src/HelpersComparisonEq.c +329 -329
- nuitka/build/static_src/HelpersComparisonEqUtils.c +3 -1
- nuitka/build/static_src/HelpersComparisonGe.c +322 -322
- nuitka/build/static_src/HelpersComparisonGt.c +321 -321
- nuitka/build/static_src/HelpersComparisonLe.c +322 -322
- nuitka/build/static_src/HelpersComparisonLt.c +321 -321
- nuitka/build/static_src/HelpersComparisonNe.c +329 -329
- nuitka/build/static_src/HelpersConsole.c +96 -0
- nuitka/build/static_src/HelpersConstantsBlob.c +10 -6
- nuitka/build/static_src/HelpersDeepcopy.c +10 -8
- nuitka/build/static_src/HelpersDictionaries.c +17 -11
- nuitka/build/static_src/HelpersDictionariesGenerated.c +65 -29
- nuitka/build/static_src/HelpersExceptions.c +107 -9
- nuitka/build/static_src/HelpersFilesystemPaths.c +64 -4
- nuitka/build/static_src/HelpersFloats.c +20 -14
- nuitka/build/static_src/HelpersImport.c +1 -1
- nuitka/build/static_src/HelpersJitSources.c +1 -1
- nuitka/build/static_src/HelpersLists.c +29 -19
- nuitka/build/static_src/HelpersListsGenerated.c +24 -24
- nuitka/build/static_src/HelpersMatching.c +32 -5
- nuitka/build/static_src/HelpersOperationBinaryAdd.c +90 -63
- nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +4 -4
- nuitka/build/static_src/HelpersOperationBinaryBitand.c +33 -33
- nuitka/build/static_src/HelpersOperationBinaryBitor.c +33 -33
- nuitka/build/static_src/HelpersOperationBinaryBitxor.c +33 -33
- nuitka/build/static_src/HelpersOperationBinaryDivmod.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryFloordiv.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryLshift.c +30 -30
- nuitka/build/static_src/HelpersOperationBinaryMatmult.c +7 -7
- nuitka/build/static_src/HelpersOperationBinaryMod.c +90 -90
- nuitka/build/static_src/HelpersOperationBinaryMult.c +64 -58
- nuitka/build/static_src/HelpersOperationBinaryOlddiv.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryPow.c +27 -27
- nuitka/build/static_src/HelpersOperationBinaryRshift.c +30 -30
- nuitka/build/static_src/HelpersOperationBinarySub.c +24 -24
- nuitka/build/static_src/HelpersOperationBinaryTruediv.c +24 -24
- nuitka/build/static_src/HelpersOperationInplaceAdd.c +67 -49
- nuitka/build/static_src/HelpersOperationInplaceBitand.c +25 -25
- nuitka/build/static_src/HelpersOperationInplaceBitor.c +25 -25
- nuitka/build/static_src/HelpersOperationInplaceBitxor.c +25 -25
- nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +28 -28
- nuitka/build/static_src/HelpersOperationInplaceLshift.c +18 -18
- nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
- nuitka/build/static_src/HelpersOperationInplaceMod.c +70 -70
- nuitka/build/static_src/HelpersOperationInplaceMult.c +33 -33
- nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +28 -28
- nuitka/build/static_src/HelpersOperationInplacePow.c +28 -28
- nuitka/build/static_src/HelpersOperationInplaceRshift.c +18 -18
- nuitka/build/static_src/HelpersOperationInplaceSub.c +28 -28
- nuitka/build/static_src/HelpersOperationInplaceTruediv.c +28 -28
- nuitka/build/static_src/HelpersRaising.c +10 -3
- nuitka/build/static_src/HelpersSafeStrings.c +14 -4
- nuitka/build/static_src/HelpersSlices.c +12 -5
- nuitka/build/static_src/HelpersStrings.c +1 -1
- nuitka/build/static_src/HelpersTuples.c +20 -15
- nuitka/build/static_src/InspectPatcher.c +74 -6
- nuitka/build/static_src/MainProgram.c +90 -25
- nuitka/build/static_src/MetaPathBasedLoader.c +81 -45
- nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +2 -2
- nuitka/build/static_src/OnefileBootstrap.c +16 -17
- nuitka/code_generation/CodeGeneration.py +5 -2
- nuitka/code_generation/ConstantCodes.py +2 -2
- nuitka/code_generation/DictCodes.py +2 -2
- nuitka/code_generation/GlobalConstants.py +5 -0
- nuitka/code_generation/GlobalsLocalsCodes.py +2 -2
- nuitka/code_generation/ListCodes.py +2 -2
- nuitka/code_generation/LocalsDictCodes.py +1 -1
- nuitka/code_generation/ModuleCodes.py +19 -0
- nuitka/code_generation/PackageResourceCodes.py +14 -0
- nuitka/code_generation/SliceCodes.py +3 -3
- nuitka/code_generation/SubscriptCodes.py +5 -13
- nuitka/code_generation/TupleCodes.py +1 -1
- nuitka/code_generation/c_types/CTypePyObjectPointers.py +7 -7
- nuitka/code_generation/templates/CodeTemplatesConstants.py +7 -5
- nuitka/code_generation/templates/CodeTemplatesLoader.py +2 -0
- nuitka/code_generation/templates/CodeTemplatesModules.py +78 -54
- nuitka/code_generation/templates_c/CodeTemplateCallsMixed.c.j2 +1 -1
- nuitka/code_generation/templates_c/CodeTemplateCallsPositional.c.j2 +8 -8
- nuitka/code_generation/templates_c/CodeTemplateCallsPositionalMethodDescr.c.j2 +5 -5
- nuitka/code_generation/templates_c/CodeTemplateMakeListHinted.c.j2 +2 -2
- nuitka/code_generation/templates_c/CodeTemplateMakeListSmall.c.j2 +2 -2
- nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +57 -21
- nuitka/code_generation/templates_c/HelperImportHard.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +5 -5
- nuitka/code_generation/templates_c/HelperOperationComparison.c.j2 +18 -18
- nuitka/code_generation/templates_c/HelperOperationComparisonBytes.c.j2 +11 -11
- nuitka/code_generation/templates_c/HelperOperationComparisonFloat.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperOperationComparisonInt.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperOperationComparisonList.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonLong.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperOperationComparisonStr.c.j2 +11 -11
- nuitka/code_generation/templates_c/HelperOperationComparisonTuple.c.j2 +7 -7
- nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +10 -10
- nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
- nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +3 -3
- nuitka/code_generation/templates_c/HelperSlotsList.c.j2 +4 -1
- nuitka/code_generation/templates_c/HelperSlotsTuple.c.j2 +4 -1
- nuitka/finalizations/FinalizeMarkups.py +0 -18
- nuitka/freezer/DependsExe.py +9 -4
- nuitka/freezer/DllDependenciesMacOS.py +1 -1
- nuitka/freezer/DllDependenciesWin32.py +1 -1
- nuitka/freezer/ImportDetection.py +1 -0
- nuitka/freezer/IncludedDataFiles.py +13 -4
- nuitka/freezer/Onefile.py +0 -1
- nuitka/freezer/Standalone.py +3 -1
- nuitka/importing/ImportCache.py +3 -2
- nuitka/importing/Importing.py +16 -3
- nuitka/importing/StandardLibrary.py +4 -0
- nuitka/nodes/ChildrenHavingMixins.py +2 -0
- nuitka/nodes/ExpressionBasesGenerated.py +4 -0
- nuitka/nodes/HardImportNodesGenerated.py +83 -0
- nuitka/nodes/ModuleNodes.py +10 -2
- nuitka/nodes/OsSysNodes.py +16 -0
- nuitka/nodes/SubscriptNodes.py +3 -3
- nuitka/plugins/PluginBase.py +2 -0
- nuitka/plugins/standard/DataFilesPlugin.py +22 -1
- nuitka/plugins/standard/DillPlugin/DillPlugin.c +3 -3
- nuitka/plugins/standard/OptionsNannyPlugin.py +9 -41
- nuitka/plugins/standard/PkgResourcesPlugin.py +8 -2
- nuitka/plugins/standard/PySidePyQtPlugin.py +3 -0
- nuitka/plugins/standard/standard.nuitka-package.config.yml +18 -12
- nuitka/plugins/standard/stdlib2.nuitka-package.config.yml +2 -2
- nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +2 -2
- nuitka/specs/HardImportSpecs.py +3 -0
- nuitka/specs/ParameterSpecs.py +26 -15
- nuitka/tools/general/find_module/FindModuleCode.py +3 -2
- nuitka/tools/specialize/CTypeDescriptions.py +11 -9
- nuitka/tools/testing/Common.py +12 -5
- nuitka/tools/testing/SearchModes.py +5 -1
- nuitka/tools/watch/GitHub.py +1 -7
- nuitka/tree/Building.py +9 -6
- nuitka/tree/ReformulationMatchStatements.py +39 -3
- nuitka/tree/TreeHelpers.py +8 -0
- nuitka/utils/CStrings.py +7 -0
- nuitka/utils/Execution.py +10 -1
- nuitka/utils/FileOperations.py +21 -13
- nuitka/utils/Importing.py +24 -0
- nuitka/utils/ReExecute.py +7 -3
- nuitka/utils/SharedLibraries.py +17 -0
- nuitka/utils/Yaml.py +9 -1
- {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.data}/scripts/nuitka-run.bat +0 -0
- {Nuitka_winsvc-2.2.3.data → Nuitka_winsvc-2.3.data}/scripts/nuitka.bat +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/WHEEL +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.2.3.dist-info → Nuitka_winsvc-2.3.dist-info}/top_level.txt +0 -0
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
#define SYSFLAG_UNBUFFERED 0
|
|
35
35
|
#define NUITKA_MAIN_MODULE_NAME "__main__"
|
|
36
36
|
#define NUITKA_MAIN_IS_PACKAGE_BOOL false
|
|
37
|
+
#define _NUITKA_ATTACH_CONSOLE_WINDOW 1
|
|
37
38
|
#endif
|
|
38
39
|
|
|
39
40
|
// It doesn't work for MinGW64 to update the standard output handles early on,
|
|
@@ -48,6 +49,10 @@
|
|
|
48
49
|
#define NUITKA_STANDARD_HANDLES_EARLY 0
|
|
49
50
|
#endif
|
|
50
51
|
|
|
52
|
+
#if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
|
|
53
|
+
#include "HelpersConsole.c"
|
|
54
|
+
#endif
|
|
55
|
+
|
|
51
56
|
extern PyCodeObject *codeobj_main;
|
|
52
57
|
|
|
53
58
|
/* For later use in "Py_GetArgcArgv" we expose the needed value */
|
|
@@ -328,20 +333,23 @@ static PyObject *EXECUTE_MAIN_MODULE(PyThreadState *tstate, char const *module_n
|
|
|
328
333
|
return IMPORT_EMBEDDED_MODULE(tstate, module_name);
|
|
329
334
|
}
|
|
330
335
|
|
|
331
|
-
#
|
|
336
|
+
#if _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
|
|
332
337
|
#include "nuitka_windows_service.h"
|
|
333
338
|
|
|
334
339
|
// Callback from Windows Service logic.
|
|
335
|
-
|
|
340
|
+
void SvcStartPython(void) {
|
|
336
341
|
PyThreadState *tstate = PyThreadState_GET();
|
|
337
342
|
|
|
338
343
|
EXECUTE_MAIN_MODULE(tstate, NUITKA_MAIN_MODULE_NAME, NUITKA_MAIN_IS_PACKAGE_BOOL);
|
|
339
344
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
NUITKA_PRINT_TIMING("SvcStartPython() Python exited.")
|
|
346
|
+
|
|
347
|
+
int exit_code = HANDLE_PROGRAM_EXIT(tstate);
|
|
348
|
+
|
|
349
|
+
// TODO: Log exception and call ReportSvcStatus
|
|
350
|
+
|
|
351
|
+
NUITKA_PRINT_TIMING("SvcStartPython(): Calling Py_Exit.");
|
|
352
|
+
Py_Exit(exit_code);
|
|
345
353
|
}
|
|
346
354
|
|
|
347
355
|
void SvcStopPython(void) { PyErr_SetInterrupt(); }
|
|
@@ -409,12 +417,12 @@ static void setCommandLineParameters(int argc, wchar_t **argv) {
|
|
|
409
417
|
}
|
|
410
418
|
|
|
411
419
|
if (i == 1) {
|
|
412
|
-
#
|
|
420
|
+
#if _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
|
|
413
421
|
if (strcmpFilename(argv[i], FILENAME_EMPTY_STR "install") == 0) {
|
|
414
422
|
NUITKA_PRINT_TRACE("main(): Calling plugin SvcInstall().");
|
|
415
423
|
|
|
416
424
|
SvcInstall();
|
|
417
|
-
NUITKA_CANNOT_GET_HERE("SvcInstall must not return");
|
|
425
|
+
NUITKA_CANNOT_GET_HERE("main(): SvcInstall must not return");
|
|
418
426
|
}
|
|
419
427
|
#endif
|
|
420
428
|
}
|
|
@@ -801,7 +809,7 @@ static void setInputOutputHandles(PyThreadState *tstate) {
|
|
|
801
809
|
// reason.
|
|
802
810
|
#if NUITKA_STANDARD_HANDLES_EARLY == 1 && PYTHON_VERSION >= 0x370
|
|
803
811
|
#if defined(NUITKA_FORCED_STDOUT_PATH) || defined(NUITKA_FORCED_STDERR_PATH)
|
|
804
|
-
PyObject *args = MAKE_DICT_EMPTY();
|
|
812
|
+
PyObject *args = MAKE_DICT_EMPTY(tstate);
|
|
805
813
|
|
|
806
814
|
DICT_SET_ITEM(args, const_str_plain_encoding, Nuitka_String_FromString("utf-8"));
|
|
807
815
|
DICT_SET_ITEM(args, const_str_plain_line_buffering, Py_True);
|
|
@@ -837,7 +845,7 @@ static void setInputOutputHandles(PyThreadState *tstate) {
|
|
|
837
845
|
#if NUITKA_STANDARD_HANDLES_EARLY == 0
|
|
838
846
|
#if defined(NUITKA_FORCED_STDOUT_PATH)
|
|
839
847
|
{
|
|
840
|
-
#
|
|
848
|
+
#if defined(_WIN32)
|
|
841
849
|
PyObject *filename = getExpandedTemplatePath(L"" NUITKA_FORCED_STDOUT_PATH);
|
|
842
850
|
#else
|
|
843
851
|
PyObject *filename = getExpandedTemplatePath(NUITKA_FORCED_STDOUT_PATH);
|
|
@@ -912,15 +920,23 @@ static void setInputOutputHandles(PyThreadState *tstate) {
|
|
|
912
920
|
}
|
|
913
921
|
|
|
914
922
|
static void Nuitka_Py_Initialize(void) {
|
|
923
|
+
#if PYTHON_VERSION > 0x350 && !defined(_NUITKA_EXPERIMENTAL_DISABLE_ALLOCATORS)
|
|
924
|
+
initNuitkaAllocators();
|
|
925
|
+
#endif
|
|
926
|
+
|
|
915
927
|
#if PYTHON_VERSION < 0x380 || defined(_NUITKA_EXPERIMENTAL_OLD_PY_INITIALIZE)
|
|
916
928
|
Py_Initialize();
|
|
917
929
|
#else
|
|
930
|
+
#if PYTHON_VERSION < 0x3d0
|
|
918
931
|
PyStatus status = _PyRuntime_Initialize();
|
|
919
932
|
if (unlikely(status._type != 0)) {
|
|
920
933
|
Py_ExitStatusException(status);
|
|
921
934
|
}
|
|
922
935
|
NUITKA_MAY_BE_UNUSED _PyRuntimeState *runtime = &_PyRuntime;
|
|
923
936
|
assert(!runtime->initialized);
|
|
937
|
+
#else
|
|
938
|
+
PyStatus status;
|
|
939
|
+
#endif
|
|
924
940
|
|
|
925
941
|
PyConfig config;
|
|
926
942
|
_PyConfig_InitCompatConfig(&config);
|
|
@@ -998,23 +1014,13 @@ static void Nuitka_Py_Initialize(void) {
|
|
|
998
1014
|
static void changeStandardHandleTarget(int std_handle_id, FILE *std_handle, filename_char_t const *template_path) {
|
|
999
1015
|
filename_char_t filename_buffer[1024];
|
|
1000
1016
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
#ifdef _WIN32
|
|
1004
|
-
bool res = expandTemplatePathW(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(filename_char_t));
|
|
1005
|
-
|
|
1006
|
-
if (res == false) {
|
|
1007
|
-
wprintf(L"Error, couldn't expand pattern '%lS'\n", template_path);
|
|
1008
|
-
abort();
|
|
1009
|
-
}
|
|
1010
|
-
#else
|
|
1011
|
-
bool res = expandTemplatePath(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(filename_char_t));
|
|
1017
|
+
bool res =
|
|
1018
|
+
expandTemplatePathFilename(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(filename_char_t));
|
|
1012
1019
|
|
|
1013
1020
|
if (res == false) {
|
|
1014
|
-
printf("Error, couldn't expand pattern
|
|
1021
|
+
printf("Error, couldn't expand pattern '" FILENAME_FORMAT_STR "'\n", template_path);
|
|
1015
1022
|
abort();
|
|
1016
1023
|
}
|
|
1017
|
-
#endif
|
|
1018
1024
|
|
|
1019
1025
|
if (GetStdHandle(std_handle_id) == 0) {
|
|
1020
1026
|
FILE *file_handle;
|
|
@@ -1129,7 +1135,13 @@ int main(int argc, char **argv) {
|
|
|
1129
1135
|
atexit(Nuitka_at_exit);
|
|
1130
1136
|
#endif
|
|
1131
1137
|
|
|
1132
|
-
//
|
|
1138
|
+
// Attach to the parent console respecting redirection only, otherwise we
|
|
1139
|
+
// cannot even output traces.
|
|
1140
|
+
#if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
|
|
1141
|
+
inheritAttachedConsole();
|
|
1142
|
+
#endif
|
|
1143
|
+
|
|
1144
|
+
// Set up stdout/stderr according to user specification.
|
|
1133
1145
|
#if NUITKA_STANDARD_HANDLES_EARLY == 1
|
|
1134
1146
|
#if defined(NUITKA_FORCED_STDOUT_PATH)
|
|
1135
1147
|
#ifdef _WIN32
|
|
@@ -1416,6 +1428,57 @@ orig_argv = argv;
|
|
|
1416
1428
|
}
|
|
1417
1429
|
#endif
|
|
1418
1430
|
|
|
1431
|
+
#if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
|
|
1432
|
+
if (needs_stdout_attaching) {
|
|
1433
|
+
PyObject *filename = Nuitka_String_FromString("CONOUT$");
|
|
1434
|
+
// This defaults to "utf-8" internally. We may add an argument of use
|
|
1435
|
+
// platform ones in the future.
|
|
1436
|
+
PyObject *encoding = NULL;
|
|
1437
|
+
|
|
1438
|
+
PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
|
|
1439
|
+
if (unlikely(stdout_file == NULL)) {
|
|
1440
|
+
PyErr_PrintEx(1);
|
|
1441
|
+
Py_Exit(1);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
Py_DECREF(filename);
|
|
1445
|
+
|
|
1446
|
+
Nuitka_SysSetObject("stdout", stdout_file);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
if (needs_stderr_attaching) {
|
|
1450
|
+
PyObject *filename = Nuitka_String_FromString("CONOUT$");
|
|
1451
|
+
// This defaults to "utf-8" internally. We may add an argument of use
|
|
1452
|
+
// platform ones in the future.
|
|
1453
|
+
PyObject *encoding = NULL;
|
|
1454
|
+
|
|
1455
|
+
PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "w", SYSFLAG_UNBUFFERED != 1, encoding);
|
|
1456
|
+
if (unlikely(stderr_file == NULL)) {
|
|
1457
|
+
PyErr_PrintEx(1);
|
|
1458
|
+
Py_Exit(1);
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
Py_DECREF(filename);
|
|
1462
|
+
|
|
1463
|
+
Nuitka_SysSetObject("stderr", stderr_file);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
if (needs_stdin_attaching) {
|
|
1467
|
+
PyObject *filename = Nuitka_String_FromString("CONIN$");
|
|
1468
|
+
// This defaults to "utf-8" internally. We may add an argument of use
|
|
1469
|
+
// platform ones in the future.
|
|
1470
|
+
PyObject *encoding = NULL;
|
|
1471
|
+
|
|
1472
|
+
// CPython core requires stdin to be buffered due to methods usage, and it won't matter
|
|
1473
|
+
// here much.
|
|
1474
|
+
PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(tstate, filename, "r", true, encoding);
|
|
1475
|
+
|
|
1476
|
+
Py_DECREF(filename);
|
|
1477
|
+
|
|
1478
|
+
Nuitka_SysSetObject("stdin", stdin_file);
|
|
1479
|
+
}
|
|
1480
|
+
#endif
|
|
1481
|
+
|
|
1419
1482
|
NUITKA_PRINT_TRACE("main(): Setting Python input/output handles.");
|
|
1420
1483
|
setInputOutputHandles(tstate);
|
|
1421
1484
|
|
|
@@ -1444,8 +1507,10 @@ orig_argv = argv;
|
|
|
1444
1507
|
/* Enable meta path based loader. */
|
|
1445
1508
|
setupMetaPathBasedLoader(tstate);
|
|
1446
1509
|
|
|
1510
|
+
#if PYTHON_VERSION < 0x3d0
|
|
1447
1511
|
/* Initialize warnings module. */
|
|
1448
1512
|
_PyWarnings_Init();
|
|
1513
|
+
#endif
|
|
1449
1514
|
|
|
1450
1515
|
#if NO_PYTHON_WARNINGS && PYTHON_VERSION >= 0x342 && PYTHON_VERSION < 0x3a0 && defined(_NUITKA_FULL_COMPAT)
|
|
1451
1516
|
// For full compatibility bump the warnings registry version,
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
#ifdef _WIN32
|
|
23
23
|
#undef SEP
|
|
24
24
|
#define SEP '\\'
|
|
25
|
+
#define SEP_L L'\\'
|
|
26
|
+
#else
|
|
27
|
+
#define SEP_L SEP
|
|
25
28
|
#endif
|
|
26
29
|
|
|
27
30
|
#ifdef _WIN32
|
|
@@ -66,6 +69,7 @@ static char *appendModuleNameAsPath(char *buffer, char const *module_name, size_
|
|
|
66
69
|
// Skip to the end
|
|
67
70
|
while (*buffer != 0) {
|
|
68
71
|
buffer++;
|
|
72
|
+
buffer_size -= 1;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
while (*module_name) {
|
|
@@ -90,20 +94,17 @@ static char *appendModuleNameAsPath(char *buffer, char const *module_name, size_
|
|
|
90
94
|
|
|
91
95
|
#if defined(_WIN32) && defined(_NUITKA_STANDALONE)
|
|
92
96
|
|
|
93
|
-
static void appendModuleNameAsPathW(wchar_t *buffer,
|
|
94
|
-
|
|
95
|
-
while (*buffer != 0) {
|
|
96
|
-
buffer++;
|
|
97
|
-
}
|
|
97
|
+
static void appendModuleNameAsPathW(wchar_t *buffer, PyObject *module_name, size_t buffer_size) {
|
|
98
|
+
wchar_t const *module_name_wstr = PyUnicode_AsWideCharString(module_name, NULL);
|
|
98
99
|
|
|
99
|
-
while (*
|
|
100
|
-
|
|
100
|
+
while (*module_name_wstr != 0) {
|
|
101
|
+
wchar_t c = *module_name_wstr++;
|
|
101
102
|
|
|
102
|
-
if (c == '.') {
|
|
103
|
-
c =
|
|
103
|
+
if (c == L'.') {
|
|
104
|
+
c = SEP_L;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
appendWCharSafeW(buffer, c, buffer_size);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
#endif
|
|
@@ -199,7 +200,9 @@ static PyObject *loadModuleFromCodeObject(PyObject *module, PyCodeObject *code_o
|
|
|
199
200
|
|
|
200
201
|
if (is_package) {
|
|
201
202
|
/* Set __path__ properly, unlike frozen module importer does. */
|
|
202
|
-
|
|
203
|
+
NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
|
|
204
|
+
|
|
205
|
+
PyObject *path_list = MAKE_LIST_EMPTY(tstate, 1);
|
|
203
206
|
if (unlikely(path_list == NULL)) {
|
|
204
207
|
return NULL;
|
|
205
208
|
}
|
|
@@ -313,7 +316,7 @@ static PyObject *_getImportingSuffixesByPriority(PyThreadState *tstate, int kind
|
|
|
313
316
|
static PyObject *result = NULL;
|
|
314
317
|
|
|
315
318
|
if (result == NULL) {
|
|
316
|
-
result = MAKE_LIST_EMPTY(0);
|
|
319
|
+
result = MAKE_LIST_EMPTY(tstate, 0);
|
|
317
320
|
|
|
318
321
|
PyObject *imp_module = PyImport_ImportModule("imp");
|
|
319
322
|
PyObject *get_suffixes_func = PyObject_GetAttrString(imp_module, "get_suffixes");
|
|
@@ -371,7 +374,7 @@ static bool scanModuleInPackagePath(PyThreadState *tstate, PyObject *module_name
|
|
|
371
374
|
return false;
|
|
372
375
|
}
|
|
373
376
|
|
|
374
|
-
PyObject *candidates = MAKE_LIST_EMPTY(0);
|
|
377
|
+
PyObject *candidates = MAKE_LIST_EMPTY(tstate, 0);
|
|
375
378
|
|
|
376
379
|
// Search only relative to the parent name of course.
|
|
377
380
|
char const *module_relative_name_str = Nuitka_String_AsString(module_name) + strlen(parent_module_name) + 1;
|
|
@@ -434,7 +437,7 @@ static bool scanModuleInPackagePath(PyThreadState *tstate, PyObject *module_name
|
|
|
434
437
|
PyObject *fullpath = JOIN_PATH2(directory, candidate);
|
|
435
438
|
|
|
436
439
|
if (installed_extension_modules == NULL) {
|
|
437
|
-
installed_extension_modules = MAKE_DICT_EMPTY();
|
|
440
|
+
installed_extension_modules = MAKE_DICT_EMPTY(tstate);
|
|
438
441
|
}
|
|
439
442
|
|
|
440
443
|
// Force path to unicode, to have easier consumption, as we need a wchar_t or char *
|
|
@@ -458,11 +461,7 @@ static bool scanModuleInPackagePath(PyThreadState *tstate, PyObject *module_name
|
|
|
458
461
|
return result;
|
|
459
462
|
}
|
|
460
463
|
|
|
461
|
-
|
|
462
|
-
static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const wchar_t *filename);
|
|
463
|
-
#else
|
|
464
|
-
static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const char *filename);
|
|
465
|
-
#endif
|
|
464
|
+
static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name, const filename_char_t *filename);
|
|
466
465
|
|
|
467
466
|
static PyObject *callIntoInstalledExtensionModule(PyThreadState *tstate, PyObject *module_name,
|
|
468
467
|
PyObject *extension_module_filename) {
|
|
@@ -561,7 +560,7 @@ static PyObject *_nuitka_loader_find_module(PyObject *self, PyObject *args, PyOb
|
|
|
561
560
|
PySys_WriteStderr("import %s # denied responsibility\n", name);
|
|
562
561
|
}
|
|
563
562
|
|
|
564
|
-
|
|
563
|
+
Py_INCREF_IMMORTAL(Py_None);
|
|
565
564
|
return Py_None;
|
|
566
565
|
}
|
|
567
566
|
|
|
@@ -638,11 +637,46 @@ typedef PyObject *(*entrypoint_t)(void);
|
|
|
638
637
|
static PyObject *createModuleSpec(PyThreadState *tstate, PyObject *module_name, PyObject *origin, bool is_package);
|
|
639
638
|
#endif
|
|
640
639
|
|
|
641
|
-
|
|
642
|
-
|
|
640
|
+
static void _fillExtensionModuleDllEntryFunctionName(PyThreadState *tstate, char *buffer, size_t buffer_size,
|
|
641
|
+
char const *name) {
|
|
642
|
+
|
|
643
|
+
#if PYTHON_VERSION >= 0x350
|
|
644
|
+
PyObject *name_bytes_obj = PyBytes_FromString(name);
|
|
645
|
+
PyObject *name_obj = BYTES_DECODE2(tstate, name_bytes_obj, Nuitka_String_FromString("utf8"));
|
|
646
|
+
Py_DECREF(name_bytes_obj);
|
|
647
|
+
|
|
648
|
+
PyObject *name_ascii = UNICODE_ENCODE2(tstate, name_obj, const_str_plain_ascii);
|
|
649
|
+
|
|
650
|
+
if (name_ascii == NULL) {
|
|
651
|
+
DROP_ERROR_OCCURRED(tstate);
|
|
652
|
+
|
|
653
|
+
PyObject *name_punycode = UNICODE_ENCODE2(tstate, name_obj, const_str_plain_punycode);
|
|
654
|
+
|
|
655
|
+
CHECK_OBJECT(name_punycode);
|
|
656
|
+
|
|
657
|
+
snprintf(buffer, buffer_size, "PyInitU_%s", PyBytes_AsString(name_punycode));
|
|
658
|
+
|
|
659
|
+
Py_DECREF(name_punycode);
|
|
660
|
+
} else {
|
|
661
|
+
Py_DECREF(name_ascii);
|
|
662
|
+
|
|
663
|
+
snprintf(buffer, buffer_size, "PyInit_%s", name);
|
|
664
|
+
}
|
|
665
|
+
Py_DECREF(name_obj);
|
|
666
|
+
#else
|
|
667
|
+
|
|
668
|
+
snprintf(buffer, buffer_size,
|
|
669
|
+
#if PYTHON_VERSION < 0x300
|
|
670
|
+
"init%s",
|
|
643
671
|
#else
|
|
644
|
-
|
|
672
|
+
"PyInit_%s",
|
|
673
|
+
#endif
|
|
674
|
+
name);
|
|
645
675
|
#endif
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full_name,
|
|
679
|
+
const filename_char_t *filename) {
|
|
646
680
|
// Determine the package name and basename of the module to load.
|
|
647
681
|
char const *dot = strrchr(full_name, '.');
|
|
648
682
|
char const *name;
|
|
@@ -658,13 +692,7 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
|
|
|
658
692
|
}
|
|
659
693
|
|
|
660
694
|
char entry_function_name[1024];
|
|
661
|
-
|
|
662
|
-
#if PYTHON_VERSION < 0x300
|
|
663
|
-
"init%s",
|
|
664
|
-
#else
|
|
665
|
-
"PyInit_%s",
|
|
666
|
-
#endif
|
|
667
|
-
name);
|
|
695
|
+
_fillExtensionModuleDllEntryFunctionName(tstate, entry_function_name, sizeof(entry_function_name), name);
|
|
668
696
|
|
|
669
697
|
#ifdef _WIN32
|
|
670
698
|
if (isVerbose()) {
|
|
@@ -701,15 +729,18 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
|
|
|
701
729
|
|
|
702
730
|
// Report either way even if failed to get error message.
|
|
703
731
|
if (size == 0) {
|
|
704
|
-
PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed with error code %d", filename,
|
|
705
|
-
|
|
732
|
+
int ret = PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed with error code %d", filename,
|
|
733
|
+
error_code);
|
|
734
|
+
|
|
735
|
+
assert(ret >= 0);
|
|
706
736
|
} else {
|
|
707
737
|
// Strip trailing newline.
|
|
708
738
|
if (size >= 2 && error_message[size - 2] == '\r' && error_message[size - 1] == '\n') {
|
|
709
739
|
size -= 2;
|
|
710
740
|
error_message[size] = '\0';
|
|
711
741
|
}
|
|
712
|
-
PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed: %s", filename, error_message);
|
|
742
|
+
int ret = PyOS_snprintf(buffer, sizeof(buffer), "LoadLibraryExW '%S' failed: %s", filename, error_message);
|
|
743
|
+
assert(ret >= 0);
|
|
713
744
|
}
|
|
714
745
|
|
|
715
746
|
SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ImportError, buffer);
|
|
@@ -911,20 +942,23 @@ static PyObject *callIntoExtensionModule(PyThreadState *tstate, char const *full
|
|
|
911
942
|
#endif
|
|
912
943
|
CHECK_OBJECT(filename_obj);
|
|
913
944
|
|
|
945
|
+
#if PYTHON_VERSION < 0x3d0
|
|
914
946
|
int res = _PyImport_FixupExtensionObject(module, full_name_obj, filename_obj
|
|
915
947
|
#if PYTHON_VERSION >= 0x370
|
|
916
948
|
,
|
|
917
949
|
Nuitka_GetSysModules()
|
|
918
950
|
#endif
|
|
919
|
-
|
|
920
951
|
);
|
|
952
|
+
#endif
|
|
921
953
|
|
|
922
954
|
Py_DECREF(full_name_obj);
|
|
923
955
|
Py_DECREF(filename_obj);
|
|
924
956
|
|
|
957
|
+
#if PYTHON_VERSION < 0x3d0
|
|
925
958
|
if (unlikely(res == -1)) {
|
|
926
959
|
return NULL;
|
|
927
960
|
}
|
|
961
|
+
#endif
|
|
928
962
|
#endif
|
|
929
963
|
|
|
930
964
|
return module;
|
|
@@ -984,7 +1018,7 @@ static PyObject *loadModule(PyThreadState *tstate, PyObject *module, PyObject *m
|
|
|
984
1018
|
|
|
985
1019
|
appendWStringSafeW(filename, getBinaryDirectoryWideChars(true), sizeof(filename) / sizeof(wchar_t));
|
|
986
1020
|
appendCharSafeW(filename, SEP, sizeof(filename) / sizeof(wchar_t));
|
|
987
|
-
appendModuleNameAsPathW(filename,
|
|
1021
|
+
appendModuleNameAsPathW(filename, module_name, sizeof(filename) / sizeof(wchar_t));
|
|
988
1022
|
appendStringSafeW(filename, ".pyd", sizeof(filename) / sizeof(wchar_t));
|
|
989
1023
|
#else
|
|
990
1024
|
char filename[MAXPATHLEN + 1] = {0};
|
|
@@ -1114,7 +1148,7 @@ static PyObject *_EXECUTE_EMBEDDED_MODULE(PyThreadState *tstate, PyObject *modul
|
|
|
1114
1148
|
return result;
|
|
1115
1149
|
}
|
|
1116
1150
|
|
|
1117
|
-
|
|
1151
|
+
Py_INCREF_IMMORTAL(Py_None);
|
|
1118
1152
|
return Py_None;
|
|
1119
1153
|
}
|
|
1120
1154
|
|
|
@@ -1222,7 +1256,7 @@ static PyObject *_nuitka_loader_is_package(PyObject *self, PyObject *args, PyObj
|
|
|
1222
1256
|
result = Py_None;
|
|
1223
1257
|
}
|
|
1224
1258
|
|
|
1225
|
-
|
|
1259
|
+
Py_INCREF_IMMORTAL(result);
|
|
1226
1260
|
return result;
|
|
1227
1261
|
}
|
|
1228
1262
|
|
|
@@ -1237,7 +1271,9 @@ static PyObject *_nuitka_loader_iter_modules(struct Nuitka_LoaderObject *self, P
|
|
|
1237
1271
|
return NULL;
|
|
1238
1272
|
}
|
|
1239
1273
|
|
|
1240
|
-
|
|
1274
|
+
NUITKA_MAY_BE_UNUSED PyThreadState *tstate = PyThreadState_GET();
|
|
1275
|
+
|
|
1276
|
+
PyObject *result = MAKE_LIST_EMPTY(tstate, 0);
|
|
1241
1277
|
|
|
1242
1278
|
struct Nuitka_MetaPathBasedLoaderEntry *current = loader_entries;
|
|
1243
1279
|
assert(current);
|
|
@@ -1293,9 +1329,9 @@ static PyObject *_nuitka_loader_iter_modules(struct Nuitka_LoaderObject *self, P
|
|
|
1293
1329
|
Py_DECREF(old);
|
|
1294
1330
|
}
|
|
1295
1331
|
|
|
1296
|
-
PyObject *r = MAKE_TUPLE_EMPTY(2);
|
|
1332
|
+
PyObject *r = MAKE_TUPLE_EMPTY(tstate, 2);
|
|
1297
1333
|
PyTuple_SET_ITEM(r, 0, name);
|
|
1298
|
-
|
|
1334
|
+
PyTuple_SET_ITEM_IMMORTAL(r, 1, BOOL_FROM((current->flags & NUITKA_PACKAGE_FLAG) != 0));
|
|
1299
1335
|
|
|
1300
1336
|
LIST_APPEND1(result, r);
|
|
1301
1337
|
|
|
@@ -1448,7 +1484,7 @@ static PyObject *createModuleSpec(PyThreadState *tstate, PyObject *module_name,
|
|
|
1448
1484
|
return NULL;
|
|
1449
1485
|
}
|
|
1450
1486
|
|
|
1451
|
-
PyObject *args = MAKE_TUPLE2(module_name, (PyObject *)&Nuitka_Loader_Type);
|
|
1487
|
+
PyObject *args = MAKE_TUPLE2(tstate, module_name, (PyObject *)&Nuitka_Loader_Type);
|
|
1452
1488
|
|
|
1453
1489
|
PyObject *kw_values[] = {is_package ? Py_True : Py_False, origin};
|
|
1454
1490
|
|
|
@@ -1534,7 +1570,7 @@ static PyObject *_nuitka_loader_find_spec(PyObject *self, PyObject *args, PyObje
|
|
|
1534
1570
|
PySys_WriteStderr("import %s # denied responsibility\n", full_name);
|
|
1535
1571
|
}
|
|
1536
1572
|
|
|
1537
|
-
|
|
1573
|
+
Py_INCREF_IMMORTAL(Py_None);
|
|
1538
1574
|
return Py_None;
|
|
1539
1575
|
}
|
|
1540
1576
|
|
|
@@ -1674,13 +1710,13 @@ static PyObject *_nuitka_loader_find_distributions(PyObject *self, PyObject *arg
|
|
|
1674
1710
|
return NULL;
|
|
1675
1711
|
}
|
|
1676
1712
|
|
|
1677
|
-
|
|
1713
|
+
PyThreadState *tstate = PyThreadState_GET();
|
|
1714
|
+
|
|
1715
|
+
PyObject *temp = MAKE_LIST_EMPTY(tstate, 0);
|
|
1678
1716
|
|
|
1679
1717
|
Py_ssize_t pos = 0;
|
|
1680
1718
|
PyObject *distribution_name;
|
|
1681
1719
|
|
|
1682
|
-
PyThreadState *tstate = PyThreadState_GET();
|
|
1683
|
-
|
|
1684
1720
|
while (Nuitka_DistributionNext(&pos, &distribution_name)) {
|
|
1685
1721
|
bool include = false;
|
|
1686
1722
|
if (name == Py_None) {
|
|
@@ -111,7 +111,7 @@ static PyObject *Nuitka_ResourceReaderFiles_iterdir(struct Nuitka_ResourceReader
|
|
|
111
111
|
return NULL;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
PyObject *files_objects = MAKE_LIST_EMPTY(0);
|
|
114
|
+
PyObject *files_objects = MAKE_LIST_EMPTY(tstate, 0);
|
|
115
115
|
|
|
116
116
|
Py_ssize_t n = PyList_GET_SIZE(file_names);
|
|
117
117
|
for (Py_ssize_t i = 0; i < n; i++) {
|
|
@@ -418,7 +418,7 @@ static PyObject *Nuitka_ResourceReaderFiles_enter(struct Nuitka_ResourceReaderFi
|
|
|
418
418
|
static PyObject *Nuitka_ResourceReaderFiles_exit(struct Nuitka_ResourceReaderFilesObject *files) {
|
|
419
419
|
CHECK_OBJECT(files);
|
|
420
420
|
|
|
421
|
-
|
|
421
|
+
Py_INCREF_IMMORTAL(Py_None);
|
|
422
422
|
return Py_None;
|
|
423
423
|
}
|
|
424
424
|
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
#define _NUITKA_AUTO_UPDATE_DEBUG_BOOL 1
|
|
68
68
|
#define _NUITKA_AUTO_UPDATE_URL_SPEC "https://..."
|
|
69
69
|
|
|
70
|
+
#define _NUITKA_ATTACH_CONSOLE_WINDOW 1
|
|
70
71
|
#endif
|
|
71
72
|
|
|
72
73
|
#if _NUITKA_ONEFILE_COMPRESSION_BOOL == 1
|
|
@@ -105,6 +106,10 @@
|
|
|
105
106
|
#include "HelpersFilesystemPaths.c"
|
|
106
107
|
#include "HelpersSafeStrings.c"
|
|
107
108
|
|
|
109
|
+
#if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
|
|
110
|
+
#include "HelpersConsole.c"
|
|
111
|
+
#endif
|
|
112
|
+
|
|
108
113
|
// For tracing outputs if enabled at compile time.
|
|
109
114
|
#include "nuitka/tracing.h"
|
|
110
115
|
|
|
@@ -137,22 +142,6 @@ static void fatalErrorMemory(void) { fatalError("Error, couldn't allocate memory
|
|
|
137
142
|
// Could not launch child process.
|
|
138
143
|
static void fatalErrorChild(char const *message, error_code_t error_code) { fatalIOError(message, error_code); }
|
|
139
144
|
|
|
140
|
-
#if defined(_WIN32)
|
|
141
|
-
static void appendWCharSafeW(wchar_t *target, wchar_t c, size_t buffer_size) {
|
|
142
|
-
while (*target != 0) {
|
|
143
|
-
target++;
|
|
144
|
-
buffer_size -= 1;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (buffer_size < 1) {
|
|
148
|
-
abort();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
*target++ = c;
|
|
152
|
-
*target = 0;
|
|
153
|
-
}
|
|
154
|
-
#endif
|
|
155
|
-
|
|
156
145
|
static void fatalErrorTempFileCreate(filename_char_t const *filename) {
|
|
157
146
|
fprintf(stderr, "Error, failed to open '" FILENAME_FORMAT_STR "' for writing.\n", filename);
|
|
158
147
|
exit(2);
|
|
@@ -993,6 +982,12 @@ int wmain(int argc, wchar_t **argv) {
|
|
|
993
982
|
int main(int argc, char **argv) {
|
|
994
983
|
#endif
|
|
995
984
|
#endif
|
|
985
|
+
// Attach to the parent console respecting redirection only, otherwise we cannot
|
|
986
|
+
// even output traces.
|
|
987
|
+
#if defined(_WIN32) && defined(_NUITKA_ATTACH_CONSOLE_WINDOW)
|
|
988
|
+
inheritAttachedConsole();
|
|
989
|
+
#endif
|
|
990
|
+
|
|
996
991
|
NUITKA_PRINT_TIMING("ONEFILE: Entered main().");
|
|
997
992
|
|
|
998
993
|
filename_char_t const *pattern = FILENAME_EMPTY_STR _NUITKA_ONEFILE_TEMP_SPEC;
|
|
@@ -1240,6 +1235,10 @@ int main(int argc, char **argv) {
|
|
|
1240
1235
|
|
|
1241
1236
|
STARTUPINFOW si;
|
|
1242
1237
|
memset(&si, 0, sizeof(si));
|
|
1238
|
+
si.dwFlags = STARTF_USESTDHANDLES;
|
|
1239
|
+
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
|
1240
|
+
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
1241
|
+
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
|
1243
1242
|
si.cb = sizeof(si);
|
|
1244
1243
|
|
|
1245
1244
|
PROCESS_INFORMATION pi;
|
|
@@ -1248,7 +1247,7 @@ int main(int argc, char **argv) {
|
|
|
1248
1247
|
GetCommandLineW(), // command line
|
|
1249
1248
|
NULL, // process attributes
|
|
1250
1249
|
NULL, // thread attributes
|
|
1251
|
-
|
|
1250
|
+
TRUE, // inherit handles
|
|
1252
1251
|
NORMAL_PRIORITY_CLASS, // creation flags
|
|
1253
1252
|
NULL, NULL, &si, &pi);
|
|
1254
1253
|
|
|
@@ -283,6 +283,7 @@ from .PackageResourceCodes import (
|
|
|
283
283
|
generateOsPathIsabsCallCode,
|
|
284
284
|
generateOsPathIsdirCallCode,
|
|
285
285
|
generateOsPathIsfileCallCode,
|
|
286
|
+
generateOsPathNormpathCallCode,
|
|
286
287
|
generateOsUnameCallCode,
|
|
287
288
|
generatePkglibGetDataCallCode,
|
|
288
289
|
generatePkgResourcesDistributionValueCode,
|
|
@@ -339,7 +340,7 @@ from .StringCodes import (
|
|
|
339
340
|
from .SubscriptCodes import (
|
|
340
341
|
generateAssignmentSubscriptCode,
|
|
341
342
|
generateDelSubscriptCode,
|
|
342
|
-
|
|
343
|
+
generateMatchSubscriptCheckCode,
|
|
343
344
|
generateSubscriptLookupCode,
|
|
344
345
|
)
|
|
345
346
|
from .TensorflowCodes import generateTensorflowFunctionCallCode
|
|
@@ -847,7 +848,7 @@ addExpressionDispatchDict(
|
|
|
847
848
|
"EXPRESSION_CLASS_BODY_P3": generateFunctionOutlineCode,
|
|
848
849
|
"EXPRESSION_SUBSCRIPT_LOOKUP": generateSubscriptLookupCode,
|
|
849
850
|
"EXPRESSION_SUBSCRIPT_LOOKUP_FOR_UNPACK": generateSubscriptLookupCode,
|
|
850
|
-
"
|
|
851
|
+
"EXPRESSION_MATCH_SUBSCRIPT_CHECK": generateMatchSubscriptCheckCode,
|
|
851
852
|
"EXPRESSION_SLICE_LOOKUP": generateSliceLookupCode,
|
|
852
853
|
"EXPRESSION_SET_OPERATION_UPDATE": generateSetOperationUpdateCode,
|
|
853
854
|
"EXPRESSION_SIDE_EFFECTS": generateSideEffectsCode,
|
|
@@ -911,6 +912,7 @@ addExpressionDispatchDict(
|
|
|
911
912
|
"EXPRESSION_OS_PATH_DIRNAME_REF": generateImportModuleNameHardCode,
|
|
912
913
|
"EXPRESSION_OS_PATH_BASENAME_REF": generateImportModuleNameHardCode,
|
|
913
914
|
"EXPRESSION_OS_PATH_ABSPATH_REF": generateImportModuleNameHardCode,
|
|
915
|
+
"EXPRESSION_OS_PATH_NORMPATH_REF": generateImportModuleNameHardCode,
|
|
914
916
|
"EXPRESSION_BUILTINS_OPEN_REF": generateImportModuleNameHardCode,
|
|
915
917
|
"EXPRESSION_CTYPES_CDLL_REF": generateImportModuleNameHardCode,
|
|
916
918
|
"EXPRESSION_CTYPES_CDLL_SINCE38_CALL": generateCtypesCdllCallCode,
|
|
@@ -940,6 +942,7 @@ addExpressionDispatchDict(
|
|
|
940
942
|
"EXPRESSION_OS_PATH_BASENAME_CALL": generateOsPathBasenameCallCode,
|
|
941
943
|
"EXPRESSION_OS_PATH_DIRNAME_CALL": generateOsPathDirnameCallCode,
|
|
942
944
|
"EXPRESSION_OS_PATH_ABSPATH_CALL": generateOsPathAbspathCallCode,
|
|
945
|
+
"EXPRESSION_OS_PATH_NORMPATH_CALL": generateOsPathNormpathCallCode,
|
|
943
946
|
"EXPRESSION_OS_PATH_ISABS_CALL": generateOsPathIsabsCallCode,
|
|
944
947
|
"EXPRESSION_OS_LISTDIR_CALL": generateOsListdirCallCode,
|
|
945
948
|
"EXPRESSION_MATCH_ARGS": generateMatchArgsCode,
|
|
@@ -19,7 +19,7 @@ import sys
|
|
|
19
19
|
from nuitka import Options
|
|
20
20
|
from nuitka.ModuleRegistry import getRootTopModule
|
|
21
21
|
from nuitka.PythonVersions import python_version
|
|
22
|
-
from nuitka.Serialization import
|
|
22
|
+
from nuitka.Serialization import GlobalConstantAccessor
|
|
23
23
|
from nuitka.utils.CStrings import encodePythonStringToC
|
|
24
24
|
from nuitka.utils.Distributions import getDistributionTopLevelPackageNames
|
|
25
25
|
from nuitka.Version import getNuitkaVersionTuple
|
|
@@ -86,7 +86,7 @@ def getConstantsDefinitionCode():
|
|
|
86
86
|
"""
|
|
87
87
|
# Somewhat detail rich, pylint: disable=too-many-locals
|
|
88
88
|
|
|
89
|
-
constant_accessor =
|
|
89
|
+
constant_accessor = GlobalConstantAccessor(
|
|
90
90
|
data_filename="__constants.const", top_level_name="global_constants"
|
|
91
91
|
)
|
|
92
92
|
|
|
@@ -272,7 +272,7 @@ if (%(value_name)s == NULL) {
|
|
|
272
272
|
if (%(value_name)s == NULL && !HAS_ERROR_OCCURRED(tstate)) {
|
|
273
273
|
{% endif %}
|
|
274
274
|
%(value_name)s = Py_None;
|
|
275
|
-
|
|
275
|
+
Py_INCREF_IMMORTAL(%(value_name)s);
|
|
276
276
|
}
|
|
277
277
|
""",
|
|
278
278
|
expression=expression,
|
|
@@ -541,7 +541,7 @@ def generateDictOperationCopyCode(to_name, expression, emit, context):
|
|
|
541
541
|
generateCAPIObjectCode(
|
|
542
542
|
to_name=to_name,
|
|
543
543
|
capi="DICT_COPY",
|
|
544
|
-
tstate=
|
|
544
|
+
tstate=True,
|
|
545
545
|
arg_desc=(("dict_arg", expression.subnode_dict_arg),),
|
|
546
546
|
may_raise=False,
|
|
547
547
|
conversion_check=decideConversionCheckNeeded(to_name, expression),
|