Nuitka-winsvc 1.6.6__cp310-cp310-win_amd64.whl → 1.7.5__cp310-cp310-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-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/METADATA +1 -1
- {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/RECORD +84 -81
- nuitka/Builtins.py +7 -1
- nuitka/MainControl.py +4 -0
- nuitka/OptionParsing.py +5 -3
- nuitka/Options.py +17 -2
- nuitka/Serialization.py +28 -5
- nuitka/Version.py +2 -2
- nuitka/build/Backend.scons +16 -3
- nuitka/build/CCompilerVersion.scons +1 -1
- nuitka/build/DataComposerInterface.py +15 -9
- nuitka/build/Onefile.scons +1 -1
- nuitka/build/SconsCompilerSettings.py +1 -0
- nuitka/build/SconsProgress.py +11 -2
- nuitka/build/SconsSpawn.py +15 -15
- nuitka/build/include/nuitka/builtins.h +2 -0
- nuitka/build/include/nuitka/filesystem_paths.h +4 -0
- nuitka/build/include/nuitka/helper/attributes.h +3 -0
- nuitka/build/include/nuitka/helper/import_hard.h +6 -0
- nuitka/build/include/nuitka/helpers.h +1 -1
- nuitka/build/include/nuitka/safe_string_ops.h +10 -3
- nuitka/build/static_src/CompiledCodeHelpers.c +0 -200
- nuitka/build/static_src/HelpersAttributes.c +185 -8
- nuitka/build/static_src/HelpersFilesystemPaths.c +528 -7
- nuitka/build/static_src/HelpersImportHard.c +38 -0
- nuitka/build/static_src/HelpersSafeStrings.c +6 -278
- nuitka/build/static_src/MainProgram.c +273 -73
- nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +6 -0
- nuitka/build/static_src/OnefileBootstrap.c +19 -36
- nuitka/build/static_src/OnefileSplashScreen.cpp +1 -0
- nuitka/code_generation/AttributeCodes.py +42 -23
- nuitka/code_generation/CodeGeneration.py +4 -0
- nuitka/code_generation/FunctionCodes.py +18 -3
- nuitka/code_generation/GlobalConstants.py +8 -1
- nuitka/code_generation/PackageResourceCodes.py +40 -0
- nuitka/code_generation/templates/CodeTemplatesModules.py +1 -7
- nuitka/freezer/DllDependenciesMacOS.py +18 -1
- nuitka/freezer/IncludedDataFiles.py +6 -10
- nuitka/importing/ImportResolving.py +6 -0
- nuitka/importing/Recursion.py +24 -68
- nuitka/nodes/AttributeNodes.py +72 -19
- nuitka/nodes/ChildrenHavingMixins.py +203 -234
- nuitka/nodes/ExpressionBasesGenerated.py +136 -0
- nuitka/nodes/HardImportNodesGenerated.py +94 -0
- nuitka/nodes/ImportHardNodes.py +3 -3
- nuitka/nodes/ImportNodes.py +14 -4
- nuitka/nodes/ModuleNodes.py +4 -2
- nuitka/nodes/PackageMetadataNodes.py +12 -10
- nuitka/nodes/PackageResourceNodes.py +115 -0
- nuitka/nodes/TypeNodes.py +5 -1
- nuitka/plugins/PluginBase.py +32 -8
- nuitka/plugins/Plugins.py +44 -7
- nuitka/plugins/standard/AntiBloatPlugin.py +166 -72
- nuitka/plugins/standard/DataFilesPlugin.py +10 -0
- nuitka/plugins/standard/DllFilesPlugin.py +1 -2
- nuitka/plugins/standard/MatplotlibPlugin.py +24 -22
- nuitka/plugins/standard/MultiprocessingPlugin.py +5 -12
- nuitka/plugins/standard/OptionsNannyPlugin.py +2 -2
- nuitka/plugins/standard/PySidePyQtPlugin.py +18 -6
- nuitka/plugins/standard/PywebViewPlugin.py +4 -2
- nuitka/plugins/standard/TkinterPlugin.py +3 -0
- nuitka/plugins/standard/TransformersPlugin.py +11 -1
- nuitka/plugins/standard/TrioPlugin.py +6 -66
- nuitka/plugins/standard/standard.nuitka-package.config.yml +367 -21
- nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +16 -4
- nuitka/specs/HardImportSpecs.py +6 -0
- nuitka/tools/data_composer/DataComposer.py +25 -27
- nuitka/tools/general/find_module/FindModuleCode.py +5 -2
- nuitka/tools/podman/Podman.py +53 -0
- nuitka/tools/podman/__init__.py +18 -0
- nuitka/tools/podman/__main__.py +255 -0
- nuitka/tools/specialize/SpecializePython.py +37 -3
- nuitka/tools/testing/RuntimeTracing.py +4 -0
- nuitka/tree/Building.py +1 -1
- nuitka/tree/ReformulationFunctionStatements.py +137 -10
- nuitka/utils/Execution.py +11 -1
- nuitka/utils/ModuleNames.py +1 -1
- nuitka/utils/SharedLibraries.py +7 -7
- {Nuitka_winsvc-1.6.6.data → Nuitka_winsvc-1.7.5.data}/scripts/nuitka-run.bat +0 -0
- {Nuitka_winsvc-1.6.6.data → Nuitka_winsvc-1.7.5.data}/scripts/nuitka.bat +0 -0
- {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/WHEEL +0 -0
- {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/top_level.txt +0 -0
|
@@ -48,6 +48,18 @@
|
|
|
48
48
|
#define NUITKA_MAIN_MODULE_NAME "__main__"
|
|
49
49
|
#endif
|
|
50
50
|
|
|
51
|
+
// It doesn't work for MinGW64 to update the standard output handles early on,
|
|
52
|
+
// so make a difference here.
|
|
53
|
+
#if defined(NUITKA_FORCED_STDOUT_PATH) || defined(NUITKA_FORCED_STDERR_PATH)
|
|
54
|
+
#if defined(__MINGW64__) || defined(__MINGW32__)
|
|
55
|
+
#define NUITKA_STANDARD_HANDLES_EARLY 0
|
|
56
|
+
#else
|
|
57
|
+
#define NUITKA_STANDARD_HANDLES_EARLY 1
|
|
58
|
+
#endif
|
|
59
|
+
#else
|
|
60
|
+
#define NUITKA_STANDARD_HANDLES_EARLY 0
|
|
61
|
+
#endif
|
|
62
|
+
|
|
51
63
|
extern PyCodeObject *codeobj_main;
|
|
52
64
|
|
|
53
65
|
/* For later use in "Py_GetArgcArgv" we expose the needed value */
|
|
@@ -388,25 +400,21 @@ static PyObject *EXECUTE_MAIN_MODULE(char const *module_name) {
|
|
|
388
400
|
}
|
|
389
401
|
|
|
390
402
|
#ifdef _NUITKA_PLUGIN_WINDOWS_SERVICE_ENABLED
|
|
391
|
-
|
|
392
|
-
extern void SvcLaunchService();
|
|
403
|
+
#include "nuitka_windows_service.h"
|
|
393
404
|
|
|
394
405
|
// Callback from Windows Service logic.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
EXECUTE_MAIN_MODULE(NUITKA_MAIN_MODULE_NAME);
|
|
406
|
+
bool SvcStartPython(void) {
|
|
407
|
+
EXECUTE_MAIN_MODULE(NUITKA_MAIN_MODULE_NAME);
|
|
398
408
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return 1;
|
|
402
|
-
} else {
|
|
403
|
-
return 0;
|
|
404
|
-
}
|
|
409
|
+
if (ERROR_OCCURRED()) {
|
|
410
|
+
return true;
|
|
405
411
|
} else {
|
|
406
|
-
|
|
407
|
-
return 0;
|
|
412
|
+
return false;
|
|
408
413
|
}
|
|
409
414
|
}
|
|
415
|
+
|
|
416
|
+
void SvcStopPython(void) { PyErr_SetInterrupt(); }
|
|
417
|
+
|
|
410
418
|
#endif
|
|
411
419
|
|
|
412
420
|
// This is a multiprocessing fork
|
|
@@ -718,34 +726,6 @@ static char **getCommandLineToArgvA(char *lpCmdline) {
|
|
|
718
726
|
int _dowildcard = 0;
|
|
719
727
|
#endif
|
|
720
728
|
|
|
721
|
-
#if defined(NUITKA_FORCED_STDOUT_PATH) || defined(NUITKA_FORCED_STDERR_PATH)
|
|
722
|
-
#ifdef _WIN32
|
|
723
|
-
static PyObject *getExpandedTemplatePath(wchar_t const *template_path) {
|
|
724
|
-
wchar_t filename_buffer[1024];
|
|
725
|
-
bool res = expandTemplatePathW(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(wchar_t));
|
|
726
|
-
|
|
727
|
-
if (res == false) {
|
|
728
|
-
puts("Error, couldn't expand pattern:");
|
|
729
|
-
abort();
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
return NuitkaUnicode_FromWideChar(filename_buffer, -1);
|
|
733
|
-
}
|
|
734
|
-
#else
|
|
735
|
-
static PyObject *getExpandedTemplatePath(char const *template) {
|
|
736
|
-
char filename_buffer[1024];
|
|
737
|
-
bool res = expandTemplatePath(filename_buffer, template, sizeof(filename_buffer));
|
|
738
|
-
|
|
739
|
-
if (res == false) {
|
|
740
|
-
printf("Error, couldn't expand pattern: %s\n", template);
|
|
741
|
-
abort();
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
return Nuitka_String_FromString(filename_buffer);
|
|
745
|
-
}
|
|
746
|
-
#endif
|
|
747
|
-
#endif
|
|
748
|
-
|
|
749
729
|
#ifdef _WIN32
|
|
750
730
|
static void setStdFileHandleNumber(DWORD std_handle_id, PyObject *file_handle) {
|
|
751
731
|
PyObject *file_no_value = CALL_METHOD_NO_ARGS(file_handle, const_str_plain_fileno);
|
|
@@ -822,6 +802,36 @@ static void setStderrHandle(PyObject *stderr_file) {
|
|
|
822
802
|
#endif
|
|
823
803
|
}
|
|
824
804
|
|
|
805
|
+
#if NUITKA_STANDARD_HANDLES_EARLY == 0
|
|
806
|
+
#if defined(NUITKA_FORCED_STDOUT_PATH) || defined(NUITKA_FORCED_STDERR_PATH)
|
|
807
|
+
#ifdef _WIN32
|
|
808
|
+
static PyObject *getExpandedTemplatePath(wchar_t const *template_path) {
|
|
809
|
+
wchar_t filename_buffer[1024];
|
|
810
|
+
bool res = expandTemplatePathW(filename_buffer, template_path, sizeof(filename_buffer) / sizeof(wchar_t));
|
|
811
|
+
|
|
812
|
+
if (res == false) {
|
|
813
|
+
puts("Error, couldn't expand pattern:");
|
|
814
|
+
abort();
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
return NuitkaUnicode_FromWideChar(filename_buffer, -1);
|
|
818
|
+
}
|
|
819
|
+
#else
|
|
820
|
+
static PyObject *getExpandedTemplatePath(char const *template) {
|
|
821
|
+
char filename_buffer[1024];
|
|
822
|
+
bool res = expandTemplatePath(filename_buffer, template, sizeof(filename_buffer));
|
|
823
|
+
|
|
824
|
+
if (res == false) {
|
|
825
|
+
printf("Error, couldn't expand pattern: %s\n", template);
|
|
826
|
+
abort();
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return Nuitka_String_FromString(filename_buffer);
|
|
830
|
+
}
|
|
831
|
+
#endif
|
|
832
|
+
#endif
|
|
833
|
+
#endif
|
|
834
|
+
|
|
825
835
|
static void setInputOutputHandles(void) {
|
|
826
836
|
// We support disabling the stdout/stderr through options as well as
|
|
827
837
|
// building for GUI on Windows, which has inputs disabled by default, this
|
|
@@ -832,36 +842,45 @@ static void setInputOutputHandles(void) {
|
|
|
832
842
|
// platform ones in the future.
|
|
833
843
|
PyObject *encoding = NULL;
|
|
834
844
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
#
|
|
839
|
-
|
|
840
|
-
|
|
845
|
+
// Reconfigure stdout for line buffering, for mixing traces and Python IO
|
|
846
|
+
// better, and force it to utf-8, it often becomes platform IO for no good
|
|
847
|
+
// reason.
|
|
848
|
+
#if NUITKA_STANDARD_HANDLES_EARLY == 1 && PYTHON_VERSION >= 0x370
|
|
849
|
+
#if defined(NUITKA_FORCED_STDOUT_PATH) || defined(NUITKA_FORCED_STDERR_PATH)
|
|
850
|
+
PyObject *args = MAKE_DICT_EMPTY();
|
|
841
851
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
// here much.
|
|
845
|
-
PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(devnull_filename, "r", true, encoding);
|
|
852
|
+
DICT_SET_ITEM(args, const_str_plain_encoding, Nuitka_String_FromString("utf-8"));
|
|
853
|
+
DICT_SET_ITEM(args, const_str_plain_line_buffering, Py_True);
|
|
846
854
|
|
|
847
|
-
|
|
848
|
-
|
|
855
|
+
#if defined(NUITKA_FORCED_STDOUT_PATH)
|
|
856
|
+
{
|
|
857
|
+
PyObject *sys_stdout = Nuitka_SysGetObject("stdout");
|
|
849
858
|
|
|
850
|
-
|
|
851
|
-
|
|
859
|
+
PyObject *method = LOOKUP_ATTRIBUTE(sys_stdout, const_str_plain_reconfigure);
|
|
860
|
+
CHECK_OBJECT(method);
|
|
852
861
|
|
|
853
|
-
|
|
854
|
-
|
|
862
|
+
PyObject *result = CALL_FUNCTION_WITH_KEYARGS(method, args);
|
|
863
|
+
CHECK_OBJECT(result);
|
|
864
|
+
}
|
|
865
|
+
#endif
|
|
855
866
|
|
|
856
|
-
|
|
857
|
-
|
|
867
|
+
#if defined(NUITKA_FORCED_STDERR_PATH)
|
|
868
|
+
{
|
|
869
|
+
PyObject *sys_stderr = Nuitka_SysGetObject("stderr");
|
|
858
870
|
|
|
859
|
-
|
|
860
|
-
|
|
871
|
+
PyObject *method = LOOKUP_ATTRIBUTE(sys_stderr, const_str_plain_reconfigure);
|
|
872
|
+
CHECK_OBJECT(method);
|
|
861
873
|
|
|
862
|
-
|
|
874
|
+
PyObject *result = CALL_FUNCTION_WITH_KEYARGS(method, args);
|
|
875
|
+
CHECK_OBJECT(result);
|
|
863
876
|
}
|
|
877
|
+
#endif
|
|
878
|
+
|
|
879
|
+
Py_DECREF(args);
|
|
880
|
+
#endif
|
|
881
|
+
#endif
|
|
864
882
|
|
|
883
|
+
#if NUITKA_STANDARD_HANDLES_EARLY == 0
|
|
865
884
|
#if defined(NUITKA_FORCED_STDOUT_PATH)
|
|
866
885
|
{
|
|
867
886
|
#ifdef _WIN32
|
|
@@ -879,14 +898,6 @@ static void setInputOutputHandles(void) {
|
|
|
879
898
|
}
|
|
880
899
|
#endif
|
|
881
900
|
|
|
882
|
-
#if NUITKA_FORCED_STDOUT_NONE_BOOL
|
|
883
|
-
setStdoutHandle(Py_None);
|
|
884
|
-
#endif
|
|
885
|
-
|
|
886
|
-
#if NUITKA_FORCED_STDERR_NONE_BOOL
|
|
887
|
-
setStderrHandle(Py_None);
|
|
888
|
-
#endif
|
|
889
|
-
|
|
890
901
|
#if defined(NUITKA_FORCED_STDERR_PATH)
|
|
891
902
|
{
|
|
892
903
|
#ifdef _WIN32
|
|
@@ -903,6 +914,45 @@ static void setInputOutputHandles(void) {
|
|
|
903
914
|
setStderrHandle(stderr_file);
|
|
904
915
|
}
|
|
905
916
|
#endif
|
|
917
|
+
#endif
|
|
918
|
+
|
|
919
|
+
{
|
|
920
|
+
#if defined(_WIN32)
|
|
921
|
+
PyObject *devnull_filename = Nuitka_String_FromString("NUL:");
|
|
922
|
+
#else
|
|
923
|
+
PyObject *devnull_filename = Nuitka_String_FromString("/dev/null");
|
|
924
|
+
#endif
|
|
925
|
+
|
|
926
|
+
if (shallSetOutputHandleToNull("stdin")) {
|
|
927
|
+
// CPython core requires stdin to be buffered due to methods usage, and it won't matter
|
|
928
|
+
// here much.
|
|
929
|
+
PyObject *stdin_file = BUILTIN_OPEN_SIMPLE(devnull_filename, "r", true, encoding);
|
|
930
|
+
|
|
931
|
+
setStdinHandle(stdin_file);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (shallSetOutputHandleToNull("stdout")) {
|
|
935
|
+
PyObject *stdout_file = BUILTIN_OPEN_SIMPLE(devnull_filename, "w", false, encoding);
|
|
936
|
+
|
|
937
|
+
setStdoutHandle(stdout_file);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
if (shallSetOutputHandleToNull("stderr")) {
|
|
941
|
+
PyObject *stderr_file = BUILTIN_OPEN_SIMPLE(devnull_filename, "w", false, encoding);
|
|
942
|
+
|
|
943
|
+
setStderrHandle(stderr_file);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
Py_DECREF(devnull_filename);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
#if NUITKA_FORCED_STDOUT_NONE_BOOL
|
|
950
|
+
setStdoutHandle(Py_None);
|
|
951
|
+
#endif
|
|
952
|
+
|
|
953
|
+
#if NUITKA_FORCED_STDERR_NONE_BOOL
|
|
954
|
+
setStderrHandle(Py_None);
|
|
955
|
+
#endif
|
|
906
956
|
|
|
907
957
|
Py_XDECREF(encoding);
|
|
908
958
|
}
|
|
@@ -957,11 +1007,131 @@ static void Nuitka_Py_Initialize(void) {
|
|
|
957
1007
|
|
|
958
1008
|
#ifdef _NUITKA_STANDALONE
|
|
959
1009
|
assert(wcscmp(config.exec_prefix, binary_directory) == 0);
|
|
1010
|
+
|
|
1011
|
+
// Empty "sys.path" first time, will be revived, but keep it
|
|
1012
|
+
// short lived.
|
|
1013
|
+
#if SYSFLAG_ISOLATED
|
|
1014
|
+
Nuitka_SysSetObject("path", PyList_New(0));
|
|
1015
|
+
#endif
|
|
960
1016
|
#endif
|
|
961
1017
|
|
|
962
1018
|
#endif
|
|
963
1019
|
}
|
|
964
1020
|
|
|
1021
|
+
#include <fcntl.h>
|
|
1022
|
+
|
|
1023
|
+
#if NUITKA_STANDARD_HANDLES_EARLY == 1
|
|
1024
|
+
#if defined(_WIN32)
|
|
1025
|
+
|
|
1026
|
+
static void changeStandardHandleTarget(int std_handle_id, FILE *std_handle, filename_char_t const *template) {
|
|
1027
|
+
filename_char_t filename_buffer[1024];
|
|
1028
|
+
|
|
1029
|
+
// TODO: We should only have one that works with filename_char_t rather than having
|
|
1030
|
+
// to make a difference here.
|
|
1031
|
+
#ifdef _WIN32
|
|
1032
|
+
bool res = expandTemplatePathW(filename_buffer, template, sizeof(filename_buffer) / sizeof(filename_char_t));
|
|
1033
|
+
|
|
1034
|
+
if (res == false) {
|
|
1035
|
+
wprintf(L"Error, couldn't expand pattern '%lS'\n", template);
|
|
1036
|
+
abort();
|
|
1037
|
+
}
|
|
1038
|
+
#else
|
|
1039
|
+
bool res = expandTemplatePath(filename_buffer, template, sizeof(filename_buffer) / sizeof(filename_char_t));
|
|
1040
|
+
|
|
1041
|
+
if (res == false) {
|
|
1042
|
+
printf("Error, couldn't expand pattern: '%s'\n", template);
|
|
1043
|
+
abort();
|
|
1044
|
+
}
|
|
1045
|
+
#endif
|
|
1046
|
+
|
|
1047
|
+
if (GetStdHandle(std_handle_id) == 0) {
|
|
1048
|
+
FILE *file_handle;
|
|
1049
|
+
|
|
1050
|
+
if (std_handle_id == STD_INPUT_HANDLE) {
|
|
1051
|
+
file_handle = _wfreopen(filename_buffer, L"rb", std_handle);
|
|
1052
|
+
} else {
|
|
1053
|
+
file_handle = _wfreopen(filename_buffer, L"wb", std_handle);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
if (file_handle == NULL) {
|
|
1057
|
+
perror("_wfreopen");
|
|
1058
|
+
abort();
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
BOOL r = SetStdHandle(std_handle_id, (HANDLE)_get_osfhandle(fileno(file_handle)));
|
|
1062
|
+
assert(r);
|
|
1063
|
+
|
|
1064
|
+
*std_handle = *file_handle;
|
|
1065
|
+
|
|
1066
|
+
assert(fileno(file_handle) == fileno(std_handle));
|
|
1067
|
+
|
|
1068
|
+
int stdout_dup = dup(fileno(std_handle));
|
|
1069
|
+
if (stdout_dup >= 0) {
|
|
1070
|
+
close(stdout_dup);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
DWORD mode = 0;
|
|
1074
|
+
if (GetConsoleMode((HANDLE)_get_osfhandle(fileno(std_handle)), &mode)) {
|
|
1075
|
+
exit(66);
|
|
1076
|
+
}
|
|
1077
|
+
} else {
|
|
1078
|
+
HANDLE w = CreateFileW(filename_buffer, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
|
1079
|
+
CREATE_ALWAYS, 0, NULL);
|
|
1080
|
+
|
|
1081
|
+
if (w == INVALID_HANDLE_VALUE) {
|
|
1082
|
+
printOSErrorMessage("standard handle failed to create", GetLastError());
|
|
1083
|
+
abort();
|
|
1084
|
+
}
|
|
1085
|
+
BOOL r = SetStdHandle(std_handle_id, w);
|
|
1086
|
+
assert(r);
|
|
1087
|
+
|
|
1088
|
+
int os_handle = _open_osfhandle((intptr_t)GetStdHandle(std_handle_id), O_WRONLY | O_TEXT);
|
|
1089
|
+
if (os_handle == -1) {
|
|
1090
|
+
perror("_open_osfhandle");
|
|
1091
|
+
abort();
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
int int_res = dup2(os_handle, fileno(std_handle));
|
|
1095
|
+
|
|
1096
|
+
// Without a console, this is normal.
|
|
1097
|
+
if (int_res == -1) {
|
|
1098
|
+
perror("_open_osfhandle");
|
|
1099
|
+
abort();
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
close(os_handle);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
setvbuf(std_handle, NULL, _IOLBF, 4096);
|
|
1106
|
+
}
|
|
1107
|
+
#else
|
|
1108
|
+
static void changeStandardHandleTarget(FILE *std_handle, filename_char_t const *template) {
|
|
1109
|
+
filename_char_t filename_buffer[1024];
|
|
1110
|
+
|
|
1111
|
+
bool res = expandTemplatePath(filename_buffer, template, sizeof(filename_buffer) / sizeof(filename_char_t));
|
|
1112
|
+
|
|
1113
|
+
if (res == false) {
|
|
1114
|
+
printf("Error, couldn't expand pattern: '%s'\n", template);
|
|
1115
|
+
abort();
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
int os_handle = open(filename_buffer, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
|
1119
|
+
if (os_handle == -1) {
|
|
1120
|
+
perror("open");
|
|
1121
|
+
abort();
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
int int_res = dup2(os_handle, fileno(std_handle));
|
|
1125
|
+
if (int_res == -1) {
|
|
1126
|
+
perror("dup2");
|
|
1127
|
+
abort();
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
close(os_handle);
|
|
1131
|
+
}
|
|
1132
|
+
#endif
|
|
1133
|
+
#endif
|
|
1134
|
+
|
|
965
1135
|
#ifdef _NUITKA_WINMAIN_ENTRY_POINT
|
|
966
1136
|
int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpCmdLine, int nCmdShow) {
|
|
967
1137
|
/* MSVC, MINGW64 */
|
|
@@ -974,8 +1144,31 @@ int wmain(int argc, wchar_t **argv) {
|
|
|
974
1144
|
int main(int argc, char **argv) {
|
|
975
1145
|
#endif
|
|
976
1146
|
#endif
|
|
977
|
-
|
|
978
|
-
|
|
1147
|
+
|
|
1148
|
+
// First things, set up stdout/stderr according to user specification.
|
|
1149
|
+
#if NUITKA_STANDARD_HANDLES_EARLY == 1
|
|
1150
|
+
#if defined(NUITKA_FORCED_STDOUT_PATH)
|
|
1151
|
+
#ifdef _WIN32
|
|
1152
|
+
changeStandardHandleTarget(STD_OUTPUT_HANDLE, stdout, L"" NUITKA_FORCED_STDOUT_PATH);
|
|
1153
|
+
#else
|
|
1154
|
+
changeStandardHandleTarget(stdout, NUITKA_FORCED_STDOUT_PATH);
|
|
1155
|
+
#endif
|
|
1156
|
+
#endif
|
|
1157
|
+
#if defined(NUITKA_FORCED_STDERR_PATH)
|
|
1158
|
+
#ifdef _WIN32
|
|
1159
|
+
changeStandardHandleTarget(STD_ERROR_HANDLE, stderr, L"" NUITKA_FORCED_STDERR_PATH);
|
|
1160
|
+
#else
|
|
1161
|
+
changeStandardHandleTarget(stderr, NUITKA_FORCED_STDERR_PATH);
|
|
1162
|
+
#endif
|
|
1163
|
+
#endif
|
|
1164
|
+
#if defined(NUITKA_FORCED_STDIN_PATH)
|
|
1165
|
+
#ifdef _WIN32
|
|
1166
|
+
changeStandardHandleTarget(STD_INPUT_HANDLE, stdin, L"" NUITKA_FORCED_STDIN_PATH);
|
|
1167
|
+
#else
|
|
1168
|
+
changeStandardHandleTarget(stdin, NUITKA_FORCED_STDIN_PATH);
|
|
1169
|
+
#endif
|
|
1170
|
+
#endif
|
|
1171
|
+
#endif
|
|
979
1172
|
|
|
980
1173
|
#if SYSFLAG_UNBUFFERED == 1
|
|
981
1174
|
setbuf(stdin, (char *)NULL);
|
|
@@ -988,6 +1181,9 @@ int main(int argc, char **argv) {
|
|
|
988
1181
|
#endif
|
|
989
1182
|
#endif
|
|
990
1183
|
|
|
1184
|
+
NUITKA_PRINT_TIMING("main(): Entered.");
|
|
1185
|
+
NUITKA_INIT_PROGRAM_EARLY(argc, argv);
|
|
1186
|
+
|
|
991
1187
|
#ifdef __FreeBSD__
|
|
992
1188
|
/* FP exceptions run in "no stop" mode by default */
|
|
993
1189
|
|
|
@@ -1149,6 +1345,10 @@ orig_argv = argv;
|
|
|
1149
1345
|
setCommandLineParameters(argc, argv, false);
|
|
1150
1346
|
|
|
1151
1347
|
PySys_SetArgv(argc, orig_argv);
|
|
1348
|
+
// Empty "sys.path" again, the above adds program directory to it.
|
|
1349
|
+
#if SYSFLAG_ISOLATED
|
|
1350
|
+
Nuitka_SysSetObject("path", PyList_New(0));
|
|
1351
|
+
#endif
|
|
1152
1352
|
|
|
1153
1353
|
/* Initialize the built-in module tricks used and builtin-type methods */
|
|
1154
1354
|
NUITKA_PRINT_TRACE("main(): Calling _initBuiltinModule().");
|
|
@@ -1213,7 +1413,7 @@ orig_argv = argv;
|
|
|
1213
1413
|
}
|
|
1214
1414
|
#endif
|
|
1215
1415
|
|
|
1216
|
-
NUITKA_PRINT_TRACE("main(): Setting input/output handles.");
|
|
1416
|
+
NUITKA_PRINT_TRACE("main(): Setting Python input/output handles.");
|
|
1217
1417
|
setInputOutputHandles();
|
|
1218
1418
|
|
|
1219
1419
|
#ifdef _NUITKA_STANDALONE
|
|
@@ -95,6 +95,12 @@ static PyObject *Nuitka_ResourceReaderFiles_iterdir(struct Nuitka_ResourceReader
|
|
|
95
95
|
PyObject *file_names = OS_LISTDIR(file_path);
|
|
96
96
|
Py_DECREF(file_path);
|
|
97
97
|
|
|
98
|
+
// TODO: Actually we ought to behave like a generator and delay this error,
|
|
99
|
+
// but we currently spare us the effort and raise this immediately.
|
|
100
|
+
if (unlikely(file_names == NULL)) {
|
|
101
|
+
return NULL;
|
|
102
|
+
}
|
|
103
|
+
|
|
98
104
|
PyObject *files_objects = MAKE_LIST_EMPTY(0);
|
|
99
105
|
|
|
100
106
|
Py_ssize_t n = PyList_GET_SIZE(file_names);
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
|
|
30
30
|
#if !defined(_WIN32)
|
|
31
31
|
#define _POSIX_C_SOURCE 200809L
|
|
32
|
+
#ifndef _GNU_SOURCE
|
|
33
|
+
#define _GNU_SOURCE
|
|
34
|
+
#endif
|
|
32
35
|
#endif
|
|
33
36
|
|
|
34
37
|
#ifdef __NUITKA_NO_ASSERT__
|
|
@@ -120,35 +123,13 @@
|
|
|
120
123
|
// For tracing outputs if enabled at compile time.
|
|
121
124
|
#include "nuitka/tracing.h"
|
|
122
125
|
|
|
123
|
-
#ifdef _WIN32
|
|
124
|
-
typedef DWORD error_code_t;
|
|
125
|
-
static inline error_code_t getCurrentErrorCode(void) { return GetLastError(); }
|
|
126
|
-
#else
|
|
127
|
-
typedef int error_code_t;
|
|
128
|
-
static inline error_code_t getCurrentErrorCode(void) { return errno; }
|
|
129
|
-
#endif
|
|
130
|
-
|
|
131
|
-
static void printError(char const *message, error_code_t error_code) {
|
|
132
|
-
#if defined(_WIN32)
|
|
133
|
-
LPCTSTR err_buffer;
|
|
134
|
-
|
|
135
|
-
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
|
136
|
-
error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&err_buffer, 0, NULL);
|
|
137
|
-
|
|
138
|
-
printf("%s ([Error %d] %s)\n", message, error_code, err_buffer);
|
|
139
|
-
#else
|
|
140
|
-
printf("%s: %s\n", message, strerror(error_code));
|
|
141
|
-
perror(message);
|
|
142
|
-
#endif
|
|
143
|
-
}
|
|
144
|
-
|
|
145
126
|
static void fatalError(char const *message) {
|
|
146
127
|
puts(message);
|
|
147
128
|
exit(2);
|
|
148
129
|
}
|
|
149
130
|
|
|
150
131
|
static void fatalIOError(char const *message, error_code_t error_code) {
|
|
151
|
-
|
|
132
|
+
printOSErrorMessage(message, error_code);
|
|
152
133
|
exit(2);
|
|
153
134
|
}
|
|
154
135
|
|
|
@@ -159,13 +140,6 @@ static void fatalErrorTempFiles(void) { fatalError("Error, couldn't runtime expa
|
|
|
159
140
|
static void fatalErrorAttachedData(void) { fatalError("Error, couldn't decode attached data."); }
|
|
160
141
|
#endif
|
|
161
142
|
|
|
162
|
-
static void fatalErrorFindAttachedData(char const *erroring_function, error_code_t error_code) {
|
|
163
|
-
char buffer[1024] = "Error, couldn't find attached data:";
|
|
164
|
-
appendStringSafe(buffer, erroring_function, sizeof(buffer));
|
|
165
|
-
|
|
166
|
-
fatalIOError(buffer, error_code);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
143
|
static void fatalErrorHeaderAttachedData(void) { fatalError("Error, could find attached data header."); }
|
|
170
144
|
|
|
171
145
|
// Left over data in attached payload should not happen.
|
|
@@ -269,6 +243,13 @@ static void closePayloadData(void) {}
|
|
|
269
243
|
|
|
270
244
|
#else
|
|
271
245
|
|
|
246
|
+
static void fatalErrorFindAttachedData(char const *erroring_function, error_code_t error_code) {
|
|
247
|
+
char buffer[1024] = "Error, couldn't find attached data:";
|
|
248
|
+
appendStringSafe(buffer, erroring_function, sizeof(buffer));
|
|
249
|
+
|
|
250
|
+
fatalIOError(buffer, error_code);
|
|
251
|
+
}
|
|
252
|
+
|
|
272
253
|
static struct MapFileToMemoryInfo exe_file_mapped;
|
|
273
254
|
|
|
274
255
|
static void initPayloadData(void) {
|
|
@@ -567,6 +548,7 @@ static bool createContainingDirectory(filename_char_t const *path) {
|
|
|
567
548
|
return true;
|
|
568
549
|
}
|
|
569
550
|
|
|
551
|
+
#if _NUITKA_ONEFILE_TEMP_BOOL == 1
|
|
570
552
|
#if defined(_WIN32)
|
|
571
553
|
|
|
572
554
|
static bool isDirectory(wchar_t const *path) {
|
|
@@ -647,6 +629,7 @@ static int removeDirectory(char const *path) {
|
|
|
647
629
|
return r;
|
|
648
630
|
}
|
|
649
631
|
#endif
|
|
632
|
+
#endif
|
|
650
633
|
|
|
651
634
|
#if !defined(_WIN32)
|
|
652
635
|
static int waitpid_retried(pid_t pid, int *status, bool async) {
|
|
@@ -729,7 +712,7 @@ static void cleanupChildProcess(bool send_sigint) {
|
|
|
729
712
|
FreeConsole();
|
|
730
713
|
|
|
731
714
|
if (res == false) {
|
|
732
|
-
|
|
715
|
+
printOSErrorMessage("Failed to send CTRL-C to child process.", GetLastError());
|
|
733
716
|
// No error exit is done, we still want to cleanup when it does exit
|
|
734
717
|
}
|
|
735
718
|
#else
|
|
@@ -859,7 +842,7 @@ DWORD PrintError(const wchar_t* fnName)
|
|
|
859
842
|
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
|
|
860
843
|
(LPWSTR)&errorMessage,
|
|
861
844
|
0, NULL);
|
|
862
|
-
wprintf(L"%
|
|
845
|
+
wprintf(L"%LS failed (%d): %LS", fnName, errorCode, errorMessage);
|
|
863
846
|
LocalFree(errorMessage);
|
|
864
847
|
return errorCode;
|
|
865
848
|
}
|
|
@@ -1142,11 +1125,11 @@ int main(int argc, char **argv) {
|
|
|
1142
1125
|
needs_write = false;
|
|
1143
1126
|
|
|
1144
1127
|
#ifdef _NUITKA_EXPERIMENTAL_DEBUG_ONEFILE_CACHING
|
|
1145
|
-
|
|
1128
|
+
fprintf(stderr, "CACHE HIT for '" FILENAME_FORMAT_STR "'.\n", target_path);
|
|
1146
1129
|
#endif
|
|
1147
1130
|
} else {
|
|
1148
1131
|
#ifdef _NUITKA_EXPERIMENTAL_DEBUG_ONEFILE_CACHING
|
|
1149
|
-
|
|
1132
|
+
fprintf(stderr, "CACHE MISS for '" FILENAME_FORMAT_STR "'.\n", target_path);
|
|
1150
1133
|
#endif
|
|
1151
1134
|
}
|
|
1152
1135
|
#endif
|
|
@@ -1195,7 +1178,7 @@ int main(int argc, char **argv) {
|
|
|
1195
1178
|
int res = fstat(fd, &stat_buffer);
|
|
1196
1179
|
|
|
1197
1180
|
if (res == -1) {
|
|
1198
|
-
|
|
1181
|
+
printOSErrorMessage("fstat", errno);
|
|
1199
1182
|
}
|
|
1200
1183
|
|
|
1201
1184
|
// User shall be able to execute if at least.
|
|
@@ -1213,7 +1196,7 @@ int main(int argc, char **argv) {
|
|
|
1213
1196
|
res = fchmod(fd, stat_buffer.st_mode);
|
|
1214
1197
|
|
|
1215
1198
|
if (res == -1) {
|
|
1216
|
-
|
|
1199
|
+
printOSErrorMessage("fchmod", errno);
|
|
1217
1200
|
}
|
|
1218
1201
|
}
|
|
1219
1202
|
#endif
|
|
@@ -29,7 +29,11 @@ from .CodeHelpers import (
|
|
|
29
29
|
withObjectCodeTemporaryAssignment,
|
|
30
30
|
)
|
|
31
31
|
from .ErrorCodes import getErrorExitBoolCode, getErrorExitCode, getReleaseCode
|
|
32
|
-
from .PythonAPICodes import
|
|
32
|
+
from .PythonAPICodes import (
|
|
33
|
+
generateCAPIObjectCode,
|
|
34
|
+
generateCAPIObjectCode0,
|
|
35
|
+
makeArgDescFromExpression,
|
|
36
|
+
)
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
def generateAssignmentAttributeCode(statement, emit, context):
|
|
@@ -270,33 +274,52 @@ def generateAttributeCheckCode(to_name, expression, emit, context):
|
|
|
270
274
|
expression=expression, emit=emit, context=context
|
|
271
275
|
)
|
|
272
276
|
|
|
273
|
-
|
|
277
|
+
if expression.mayRaiseExceptionOperation():
|
|
278
|
+
res_name = context.getIntResName()
|
|
274
279
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
emit(
|
|
281
|
+
"%s = HAS_ATTR_BOOL2(%s, %s);"
|
|
282
|
+
% (
|
|
283
|
+
res_name,
|
|
284
|
+
source_name,
|
|
285
|
+
context.getConstantCode(constant=expression.getAttributeName()),
|
|
286
|
+
)
|
|
281
287
|
)
|
|
282
|
-
)
|
|
283
288
|
|
|
284
|
-
|
|
289
|
+
getErrorExitBoolCode(
|
|
290
|
+
condition="%s == -1" % res_name,
|
|
291
|
+
release_name=source_name,
|
|
292
|
+
emit=emit,
|
|
293
|
+
context=context,
|
|
294
|
+
)
|
|
285
295
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
296
|
+
to_name.getCType().emitAssignmentCodeFromBoolCondition(
|
|
297
|
+
to_name=to_name, condition="%s != 0" % res_name, emit=emit
|
|
298
|
+
)
|
|
299
|
+
else:
|
|
300
|
+
res_name = context.getBoolResName()
|
|
301
|
+
|
|
302
|
+
emit(
|
|
303
|
+
"%s = HAS_ATTR_BOOL(%s, %s);"
|
|
304
|
+
% (
|
|
305
|
+
res_name,
|
|
306
|
+
source_name,
|
|
307
|
+
context.getConstantCode(constant=expression.getAttributeName()),
|
|
308
|
+
)
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
getReleaseCode(release_name=source_name, emit=emit, context=context)
|
|
312
|
+
|
|
313
|
+
to_name.getCType().emitAssignmentCodeFromBoolCondition(
|
|
314
|
+
to_name=to_name, condition=res_name, emit=emit
|
|
315
|
+
)
|
|
289
316
|
|
|
290
317
|
|
|
291
318
|
def generateBuiltinGetattrCode(to_name, expression, emit, context):
|
|
292
319
|
generateCAPIObjectCode(
|
|
293
320
|
to_name=to_name,
|
|
294
321
|
capi="BUILTIN_GETATTR",
|
|
295
|
-
arg_desc=(
|
|
296
|
-
("getattr_target", expression.subnode_expression),
|
|
297
|
-
("getattr_attr", expression.subnode_name),
|
|
298
|
-
("getattr_default", expression.subnode_default),
|
|
299
|
-
),
|
|
322
|
+
arg_desc=makeArgDescFromExpression(expression),
|
|
300
323
|
may_raise=expression.mayRaiseException(BaseException),
|
|
301
324
|
conversion_check=decideConversionCheckNeeded(to_name, expression),
|
|
302
325
|
source_ref=expression.getCompatibleSourceReference(),
|
|
@@ -310,11 +333,7 @@ def generateBuiltinSetattrCode(to_name, expression, emit, context):
|
|
|
310
333
|
generateCAPIObjectCode0(
|
|
311
334
|
to_name=to_name,
|
|
312
335
|
capi="BUILTIN_SETATTR",
|
|
313
|
-
arg_desc=(
|
|
314
|
-
("setattr_target", expression.subnode_expression),
|
|
315
|
-
("setattr_attr", expression.subnode_attribute),
|
|
316
|
-
("setattr_value", expression.subnode_value),
|
|
317
|
-
),
|
|
336
|
+
arg_desc=makeArgDescFromExpression(expression),
|
|
318
337
|
may_raise=expression.mayRaiseException(BaseException),
|
|
319
338
|
conversion_check=decideConversionCheckNeeded(to_name, expression),
|
|
320
339
|
source_ref=expression.getCompatibleSourceReference(),
|