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
nuitka/Serialization.py
CHANGED
|
@@ -25,7 +25,13 @@ import sys
|
|
|
25
25
|
|
|
26
26
|
from nuitka import OutputDirectories
|
|
27
27
|
from nuitka.__past__ import ExceptionGroup # pylint: disable=I0021,redefined-builtin
|
|
28
|
-
from nuitka.__past__ import
|
|
28
|
+
from nuitka.__past__ import (
|
|
29
|
+
GenericAlias,
|
|
30
|
+
UnionType,
|
|
31
|
+
basestring,
|
|
32
|
+
to_byte,
|
|
33
|
+
xrange,
|
|
34
|
+
)
|
|
29
35
|
from nuitka.Builtins import (
|
|
30
36
|
builtin_anon_codes,
|
|
31
37
|
builtin_anon_values,
|
|
@@ -54,7 +60,17 @@ class BuiltinAnonValue(object):
|
|
|
54
60
|
return to_byte(self.anon_values.index(self.anon_name))
|
|
55
61
|
|
|
56
62
|
|
|
63
|
+
class BuiltinGenericAliasValue(object):
|
|
64
|
+
"""For transporting GenericAlias values through pickler."""
|
|
65
|
+
|
|
66
|
+
def __init__(self, origin, args):
|
|
67
|
+
self.origin = origin
|
|
68
|
+
self.args = args
|
|
69
|
+
|
|
70
|
+
|
|
57
71
|
class BuiltinUnionTypeValue(object):
|
|
72
|
+
"""For transporting UnionType values through pickler."""
|
|
73
|
+
|
|
58
74
|
def __init__(self, args):
|
|
59
75
|
self.args = args
|
|
60
76
|
|
|
@@ -68,7 +84,7 @@ class BuiltinSpecialValue(object):
|
|
|
68
84
|
def getStreamValueByte(self):
|
|
69
85
|
"""Return byte value, encoding the special built-in value."""
|
|
70
86
|
|
|
71
|
-
# Currently the only
|
|
87
|
+
# Currently the only ones.
|
|
72
88
|
if self.value == "Ellipsis":
|
|
73
89
|
return to_byte(0)
|
|
74
90
|
elif self.value == "NotImplemented":
|
|
@@ -108,8 +124,12 @@ def _pickleAnonValues(pickler, value):
|
|
|
108
124
|
pickler.save_global(value)
|
|
109
125
|
|
|
110
126
|
|
|
111
|
-
def
|
|
112
|
-
|
|
127
|
+
def _pickleGenericAlias(pickler, value):
|
|
128
|
+
pickler.save(BuiltinGenericAliasValue(origin=value.__origin__, args=value.__args__))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _pickleUnionType(pickler, value):
|
|
132
|
+
pickler.save(BuiltinUnionTypeValue(args=value.__args__))
|
|
113
133
|
|
|
114
134
|
|
|
115
135
|
class ConstantStreamWriter(object):
|
|
@@ -135,8 +155,11 @@ class ConstantStreamWriter(object):
|
|
|
135
155
|
self.pickle.dispatch[type(sys.version_info)] = _pickleAnonValues
|
|
136
156
|
|
|
137
157
|
# Standard pickling doesn't work with our necessary wrappers.
|
|
158
|
+
if python_version >= 0x390:
|
|
159
|
+
self.pickle.dispatch[GenericAlias] = _pickleGenericAlias
|
|
160
|
+
|
|
138
161
|
if python_version >= 0x3A0:
|
|
139
|
-
self.pickle.dispatch[UnionType] =
|
|
162
|
+
self.pickle.dispatch[UnionType] = _pickleUnionType
|
|
140
163
|
|
|
141
164
|
def addConstantValue(self, constant_value):
|
|
142
165
|
self.pickle.dump(constant_value)
|
nuitka/Version.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2023, Kay Hayen, mailto:kay.hayen@gmail.com
|
|
2
2
|
#
|
|
3
3
|
# Part of "Nuitka", an optimizing Python compiler that is compatible and
|
|
4
4
|
# integrates with CPython, but also works on its own.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
version_string = """\
|
|
23
|
-
Nuitka V1.
|
|
23
|
+
Nuitka V1.7.5
|
|
24
24
|
Copyright (C) 2023 Kay Hayen."""
|
|
25
25
|
|
|
26
26
|
|
nuitka/build/Backend.scons
CHANGED
|
@@ -263,6 +263,10 @@ python_sysflag_no_randomization = getArgumentBool(
|
|
|
263
263
|
# python_sysflag_unbuffered
|
|
264
264
|
python_sysflag_unbuffered = getArgumentBool("python_sysflag_unbuffered", False)
|
|
265
265
|
|
|
266
|
+
# python_sysflag_isolated
|
|
267
|
+
python_sysflag_isolated = getArgumentBool("python_sysflag_isolated", False)
|
|
268
|
+
|
|
269
|
+
|
|
266
270
|
# Preprocessor defines from plugins
|
|
267
271
|
cpp_defines = getArgumentList("cpp_defines", "")
|
|
268
272
|
cpp_include_dirs = getArgumentList("cpp_include_dirs", "")
|
|
@@ -337,7 +341,7 @@ env.the_compiler = env["CC"]
|
|
|
337
341
|
env.the_cc_name = os.path.normcase(os.path.basename(env.the_compiler))
|
|
338
342
|
env.standalone_mode = standalone_mode
|
|
339
343
|
env.debug_mode = debug_mode
|
|
340
|
-
env.unstripped_mode =
|
|
344
|
+
env.unstripped_mode = unstripped_mode
|
|
341
345
|
env.disable_console = disable_console
|
|
342
346
|
env.source_dir = source_dir
|
|
343
347
|
env.low_memory = low_memory
|
|
@@ -795,8 +799,15 @@ if module_mode:
|
|
|
795
799
|
assert False, env.the_cc_name
|
|
796
800
|
else:
|
|
797
801
|
if env.msvc_mode:
|
|
798
|
-
|
|
799
|
-
|
|
802
|
+
# For complete outputs, we have to match the C runtime of the Python DLL, if any,
|
|
803
|
+
# for Nuitka-Python there is of course none.
|
|
804
|
+
if not env.nuitka_python and (
|
|
805
|
+
forced_stdout_path not in ("%NONE%", "%NULL%", None)
|
|
806
|
+
or forced_stderr_path not in ("%NONE%", "%NULL%", None)
|
|
807
|
+
):
|
|
808
|
+
env.Append(CCFLAGS=["/MD"]) # Multithreaded, dynamic version of C run time.
|
|
809
|
+
else:
|
|
810
|
+
env.Append(CCFLAGS=["/MT"]) # Multithreaded, static version of C run time.
|
|
800
811
|
|
|
801
812
|
if module_mode:
|
|
802
813
|
env.Append(CPPDEFINES=["_NUITKA_MODULE"])
|
|
@@ -923,6 +934,8 @@ def createBuildDefinitionsFile():
|
|
|
923
934
|
|
|
924
935
|
build_definitions["SYSFLAG_UNBUFFERED"] = 1 if python_sysflag_unbuffered else 0
|
|
925
936
|
|
|
937
|
+
build_definitions["SYSFLAG_ISOLATED"] = 1 if python_sysflag_isolated else 0
|
|
938
|
+
|
|
926
939
|
if forced_stdout_path:
|
|
927
940
|
if forced_stdout_path == "%NONE%":
|
|
928
941
|
build_definitions["NUITKA_FORCED_STDOUT_NONE_BOOL"] = 1
|
|
@@ -218,7 +218,7 @@ env = checkWindowsCompilerFound(
|
|
|
218
218
|
env.the_compiler = env["CC"] or env["CXX"]
|
|
219
219
|
env.the_cc_name = os.path.normcase(os.path.basename(env.the_compiler))
|
|
220
220
|
env.debug_mode = debug_mode
|
|
221
|
-
env.unstripped_mode =
|
|
221
|
+
env.unstripped_mode = unstripped_mode
|
|
222
222
|
env.disable_console = disable_console
|
|
223
223
|
env.low_memory = False
|
|
224
224
|
env.macos_min_version = macos_min_version
|
|
@@ -23,6 +23,7 @@ import subprocess
|
|
|
23
23
|
import sys
|
|
24
24
|
|
|
25
25
|
from nuitka.Options import isExperimental
|
|
26
|
+
from nuitka.Tracing import data_composer_logger
|
|
26
27
|
from nuitka.utils.Execution import withEnvironmentVarsOverridden
|
|
27
28
|
|
|
28
29
|
|
|
@@ -51,15 +52,20 @@ def _runDataComposer(source_dir):
|
|
|
51
52
|
blob_filename = getConstantBlobFilename(source_dir)
|
|
52
53
|
|
|
53
54
|
with withEnvironmentVarsOverridden(mapping):
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
try:
|
|
56
|
+
subprocess.check_call(
|
|
57
|
+
[
|
|
58
|
+
sys.executable,
|
|
59
|
+
data_composer_path,
|
|
60
|
+
source_dir,
|
|
61
|
+
blob_filename,
|
|
62
|
+
],
|
|
63
|
+
shell=False,
|
|
64
|
+
)
|
|
65
|
+
except subprocess.CalledProcessError:
|
|
66
|
+
data_composer_logger.sysexit(
|
|
67
|
+
"Error executing data composer, please report the above exception."
|
|
68
|
+
)
|
|
63
69
|
|
|
64
70
|
return blob_filename
|
|
65
71
|
|
nuitka/build/Onefile.scons
CHANGED
|
@@ -272,7 +272,7 @@ env.the_compiler = env["CC"] or env["CXX"]
|
|
|
272
272
|
env.the_cc_name = os.path.normcase(os.path.basename(env.the_compiler))
|
|
273
273
|
env.standalone_mode = True # We are only used in this case.
|
|
274
274
|
env.debug_mode = debug_mode
|
|
275
|
-
env.unstripped_mode =
|
|
275
|
+
env.unstripped_mode = unstripped_mode
|
|
276
276
|
env.disable_console = disable_console
|
|
277
277
|
env.source_dir = source_dir
|
|
278
278
|
env.low_memory = False # Never a concern in this case.
|
nuitka/build/SconsProgress.py
CHANGED
|
@@ -73,11 +73,20 @@ def closeSconsProgressBar():
|
|
|
73
73
|
closeProgressBar()
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def reportSlowCompilation(cmd, delta_time):
|
|
76
|
+
def reportSlowCompilation(env, cmd, delta_time):
|
|
77
77
|
# TODO: for linking, we ought to apply a different timer maybe and attempt to extra
|
|
78
78
|
# the source file that is causing the issues: pylint: disable=unused-argument
|
|
79
79
|
if _current != _total:
|
|
80
80
|
scons_logger.info(
|
|
81
|
-
"
|
|
81
|
+
"""\
|
|
82
|
+
Slow C compilation detected, used %.0fs so far, scalability problem."""
|
|
82
83
|
% delta_time
|
|
83
84
|
)
|
|
85
|
+
else:
|
|
86
|
+
if env.orig_lto_mode == "auto" and env.lto_mode:
|
|
87
|
+
scons_logger.info(
|
|
88
|
+
"""\
|
|
89
|
+
Slow C linking detected, used %.0fs so far, consider using '--lto=no' \
|
|
90
|
+
for faster linking, or '--lto=yes"' to disable this message. """
|
|
91
|
+
% delta_time
|
|
92
|
+
)
|
nuitka/build/SconsSpawn.py
CHANGED
|
@@ -54,7 +54,7 @@ class SubprocessThread(threading.Thread):
|
|
|
54
54
|
self.timer_report = TimerReport(
|
|
55
55
|
message="Running %s took %%.2f seconds"
|
|
56
56
|
% repr(self.cmdline).replace("%", "%%"),
|
|
57
|
-
min_report_time=
|
|
57
|
+
min_report_time=360,
|
|
58
58
|
logger=scons_logger,
|
|
59
59
|
)
|
|
60
60
|
|
|
@@ -73,15 +73,15 @@ class SubprocessThread(threading.Thread):
|
|
|
73
73
|
return self.data, self.err, self.exit_code, self.exception
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
def
|
|
77
|
-
thread = SubprocessThread(cmdline,
|
|
76
|
+
def _runProcessMonitored(env, cmdline, os_env):
|
|
77
|
+
thread = SubprocessThread(cmdline, os_env)
|
|
78
78
|
thread.start()
|
|
79
79
|
|
|
80
|
-
# Allow
|
|
80
|
+
# Allow 6 minutes before warning for long compile time.
|
|
81
81
|
thread.join(360)
|
|
82
82
|
|
|
83
83
|
if thread.is_alive():
|
|
84
|
-
reportSlowCompilation(cmdline, thread.timer_report.getTimer().getDelta())
|
|
84
|
+
reportSlowCompilation(env, cmdline, thread.timer_report.getTimer().getDelta())
|
|
85
85
|
|
|
86
86
|
thread.join()
|
|
87
87
|
|
|
@@ -160,7 +160,7 @@ def _getWindowsSpawnFunction(env, module_mode, source_files):
|
|
|
160
160
|
if cmd == "<clcache>":
|
|
161
161
|
data, err, rv = runClCache(args, os_env)
|
|
162
162
|
else:
|
|
163
|
-
data, err, rv, exception =
|
|
163
|
+
data, err, rv, exception = _runProcessMonitored(env, cmdline, os_env)
|
|
164
164
|
|
|
165
165
|
if exception:
|
|
166
166
|
closeSconsProgressBar()
|
|
@@ -323,7 +323,7 @@ class SpawnThread(threading.Thread):
|
|
|
323
323
|
self.timer_report = TimerReport(
|
|
324
324
|
message="Running %s took %%.2f seconds"
|
|
325
325
|
% (" ".join(_unescape(arg) for arg in self.args[2]).replace("%", "%%"),),
|
|
326
|
-
min_report_time=
|
|
326
|
+
min_report_time=360,
|
|
327
327
|
logger=scons_logger,
|
|
328
328
|
)
|
|
329
329
|
|
|
@@ -342,15 +342,15 @@ class SpawnThread(threading.Thread):
|
|
|
342
342
|
return self.result, self.exception
|
|
343
343
|
|
|
344
344
|
|
|
345
|
-
def
|
|
346
|
-
thread = SpawnThread(sh, cmd, args,
|
|
345
|
+
def _runSpawnMonitored(env, sh, cmd, args, os_env):
|
|
346
|
+
thread = SpawnThread(sh, cmd, args, os_env)
|
|
347
347
|
thread.start()
|
|
348
348
|
|
|
349
|
-
# Allow
|
|
349
|
+
# Allow 6 minutes before warning for long compile time.
|
|
350
350
|
thread.join(360)
|
|
351
351
|
|
|
352
352
|
if thread.is_alive():
|
|
353
|
-
reportSlowCompilation(cmd, thread.timer_report.getTimer().getDelta())
|
|
353
|
+
reportSlowCompilation(env, cmd, thread.timer_report.getTimer().getDelta())
|
|
354
354
|
|
|
355
355
|
thread.join()
|
|
356
356
|
|
|
@@ -360,16 +360,16 @@ def runSpawnMonitored(sh, cmd, args, env):
|
|
|
360
360
|
|
|
361
361
|
|
|
362
362
|
def _getWrappedSpawnFunction(env):
|
|
363
|
-
def spawnCommand(sh, escape, cmd, args,
|
|
363
|
+
def spawnCommand(sh, escape, cmd, args, os_env):
|
|
364
364
|
# signature needed towards Scons core, pylint: disable=unused-argument
|
|
365
365
|
|
|
366
366
|
# Avoid using ccache on binary constants blob, not useful and not working
|
|
367
367
|
# with old ccache.
|
|
368
368
|
if '"__constants_data.o"' in args or '"__constants_data.os"' in args:
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
os_env = dict(os_env)
|
|
370
|
+
os_env["CCACHE_DISABLE"] = "1"
|
|
371
371
|
|
|
372
|
-
result, exception =
|
|
372
|
+
result, exception = _runSpawnMonitored(env, sh, cmd, args, os_env)
|
|
373
373
|
|
|
374
374
|
if exception:
|
|
375
375
|
closeSconsProgressBar()
|
|
@@ -41,6 +41,7 @@ NUITKA_MAY_BE_UNUSED static PyObject *LOOKUP_BUILTIN(PyObject *name) {
|
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Returns a reference.
|
|
44
45
|
NUITKA_MAY_BE_UNUSED static PyObject *LOOKUP_BUILTIN_STR(char const *name) {
|
|
45
46
|
CHECK_OBJECT(dict_builtin);
|
|
46
47
|
|
|
@@ -54,6 +55,7 @@ NUITKA_MAY_BE_UNUSED static PyObject *LOOKUP_BUILTIN_STR(char const *name) {
|
|
|
54
55
|
|
|
55
56
|
CHECK_OBJECT(result);
|
|
56
57
|
|
|
58
|
+
Py_INCREF(result);
|
|
57
59
|
return result;
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -89,4 +89,8 @@ extern bool renameFile(filename_char_t const *source, filename_char_t const *des
|
|
|
89
89
|
|
|
90
90
|
extern uint32_t getFileCRC32(filename_char_t const *filename);
|
|
91
91
|
|
|
92
|
+
// Expand symbolic paths, containing %TEMP%, %PID% without overflowing.
|
|
93
|
+
extern bool expandTemplatePathW(wchar_t *target, wchar_t const *source, size_t buffer_size);
|
|
94
|
+
extern bool expandTemplatePath(char *target, char const *source, size_t buffer_size);
|
|
95
|
+
|
|
92
96
|
#endif
|
|
@@ -33,6 +33,9 @@ extern int BUILTIN_HASATTR_BOOL(PyObject *source, PyObject *attr_name);
|
|
|
33
33
|
// Check for an attribute, cannot raise an exception.
|
|
34
34
|
extern bool HAS_ATTR_BOOL(PyObject *source, PyObject *attr_name);
|
|
35
35
|
|
|
36
|
+
// Check for an attribute, can raise an exception.
|
|
37
|
+
extern int HAS_ATTR_BOOL2(PyObject *source, PyObject *attr_name);
|
|
38
|
+
|
|
36
39
|
// Set an attribute except for attribute slots below.
|
|
37
40
|
extern bool SET_ATTRIBUTE(PyObject *target, PyObject *attr_name, PyObject *value);
|
|
38
41
|
|
|
@@ -99,3 +99,9 @@ extern PyObject *IMPORT_HARD_TYPES(void);
|
|
|
99
99
|
#if PYTHON_VERSION >= 0x350
|
|
100
100
|
extern PyObject *IMPORT_HARD_TYPING(void);
|
|
101
101
|
#endif
|
|
102
|
+
|
|
103
|
+
/* C helper for hard import of module "unittest" import. */
|
|
104
|
+
extern PyObject *IMPORT_HARD_UNITTEST(void);
|
|
105
|
+
|
|
106
|
+
/* C helper for hard import of module "unittest.mock" import. */
|
|
107
|
+
extern PyObject *IMPORT_HARD_UNITTEST__MOCK(void);
|
|
@@ -361,7 +361,7 @@ NUITKA_MAY_BE_UNUSED static PyObject *MODULE_NAME0(PyObject *module) {
|
|
|
361
361
|
return DICT_GET_ITEM0(module_dict, const_str_plain___name__);
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
// Get the binary directory
|
|
364
|
+
// Get the binary directory as wide characters.
|
|
365
365
|
extern wchar_t const *getBinaryDirectoryWideChars(bool resolve_symlinks);
|
|
366
366
|
|
|
367
367
|
// Get the binary directory, translated to ANSI/native path
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
#ifndef __NUITKA_SAFE_STRING_OPS_H__
|
|
19
19
|
#define __NUITKA_SAFE_STRING_OPS_H__
|
|
20
20
|
|
|
21
|
+
#include <errno.h>
|
|
21
22
|
#include <stdbool.h>
|
|
22
23
|
#include <stddef.h>
|
|
23
24
|
#include <stdint.h>
|
|
@@ -36,8 +37,14 @@ extern void appendCharSafeW(wchar_t *target, char c, size_t buffer_size);
|
|
|
36
37
|
extern void appendStringSafeW(wchar_t *target, char const *source, size_t buffer_size);
|
|
37
38
|
extern void appendWStringSafeW(wchar_t *target, wchar_t const *source, size_t buffer_size);
|
|
38
39
|
|
|
39
|
-
/*
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
/* Get OS error code and print it to stderr. */
|
|
41
|
+
#ifdef _WIN32
|
|
42
|
+
typedef DWORD error_code_t;
|
|
43
|
+
static inline error_code_t getCurrentErrorCode(void) { return GetLastError(); }
|
|
44
|
+
#else
|
|
45
|
+
typedef int error_code_t;
|
|
46
|
+
static inline error_code_t getCurrentErrorCode(void) { return errno; }
|
|
47
|
+
#endif
|
|
48
|
+
extern void printOSErrorMessage(char const *message, error_code_t error_code);
|
|
42
49
|
|
|
43
50
|
#endif
|
|
@@ -1530,17 +1530,6 @@ int Nuitka_BuiltinModule_SetAttr(PyModuleObject *module, PyObject *name, PyObjec
|
|
|
1530
1530
|
return PyObject_GenericSetAttr((PyObject *)module, name, value);
|
|
1531
1531
|
}
|
|
1532
1532
|
|
|
1533
|
-
#if defined(_WIN32)
|
|
1534
|
-
#include <Shlwapi.h>
|
|
1535
|
-
#elif defined(__APPLE__)
|
|
1536
|
-
#include <dlfcn.h>
|
|
1537
|
-
#include <libgen.h>
|
|
1538
|
-
#include <mach-o/dyld.h>
|
|
1539
|
-
#else
|
|
1540
|
-
#include <dlfcn.h>
|
|
1541
|
-
#include <libgen.h>
|
|
1542
|
-
#endif
|
|
1543
|
-
|
|
1544
1533
|
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
1545
1534
|
#include <sys/sysctl.h>
|
|
1546
1535
|
#endif
|
|
@@ -1594,195 +1583,6 @@ NUITKA_MAY_BE_UNUSED static void stripFilenameW(wchar_t *path) {
|
|
|
1594
1583
|
|
|
1595
1584
|
#if defined(_NUITKA_EXE)
|
|
1596
1585
|
|
|
1597
|
-
#ifdef _WIN32
|
|
1598
|
-
static void resolveFileSymbolicLink(wchar_t *resolved_filename, wchar_t const *filename, DWORD resolved_filename_size,
|
|
1599
|
-
bool resolve_symlinks) {
|
|
1600
|
-
// Resolve any symbolic links in the filename.
|
|
1601
|
-
// Copies the resolved path over the top of the parameter.
|
|
1602
|
-
|
|
1603
|
-
// There are no symlinks before Windows Vista. TODO: This effectively disables this code
|
|
1604
|
-
// for MinGW64.
|
|
1605
|
-
#if _WIN32_WINNT >= 0x0600
|
|
1606
|
-
if (resolve_symlinks) {
|
|
1607
|
-
// Open the file in the most non-exclusive way possible
|
|
1608
|
-
HANDLE file_handle = CreateFileW(filename, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
|
|
1609
|
-
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
1610
|
-
|
|
1611
|
-
if (unlikely(file_handle == INVALID_HANDLE_VALUE)) {
|
|
1612
|
-
abort();
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
// Resolve the path, get the result with a drive letter
|
|
1616
|
-
DWORD len = GetFinalPathNameByHandleW(file_handle, resolved_filename, resolved_filename_size,
|
|
1617
|
-
FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
|
|
1618
|
-
|
|
1619
|
-
CloseHandle(file_handle);
|
|
1620
|
-
|
|
1621
|
-
if (unlikely(len >= resolved_filename_size)) {
|
|
1622
|
-
abort();
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
// Avoid network filenames added by just the resolution, revert it if
|
|
1626
|
-
// they are pointing to local drive.
|
|
1627
|
-
if (wcsncmp(resolved_filename, L"\\\\?\\", 4) == 0) {
|
|
1628
|
-
if (wcscmp(resolved_filename + 4, filename) == 0) {
|
|
1629
|
-
copyStringSafeW(resolved_filename, filename, resolved_filename_size);
|
|
1630
|
-
} else if (resolved_filename[5] == L':') {
|
|
1631
|
-
copyStringSafeW(resolved_filename, resolved_filename + 4, resolved_filename_size);
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
} else
|
|
1635
|
-
#endif
|
|
1636
|
-
{
|
|
1637
|
-
copyStringSafeW(resolved_filename, filename, resolved_filename_size);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
#else
|
|
1642
|
-
|
|
1643
|
-
static void resolveFileSymbolicLink(char *resolved_filename, char const *filename, size_t resolved_filename_size,
|
|
1644
|
-
bool resolve_symlinks) {
|
|
1645
|
-
if (resolve_symlinks) {
|
|
1646
|
-
// At least on macOS, realpath cannot allocate a buffer, itself, so lets
|
|
1647
|
-
// use a local one, only on Linux we could use NULL argument and have a
|
|
1648
|
-
// malloc of the resulting value.
|
|
1649
|
-
char buffer[PATH_MAX];
|
|
1650
|
-
|
|
1651
|
-
char *result = realpath(filename, buffer);
|
|
1652
|
-
|
|
1653
|
-
if (unlikely(result == NULL)) {
|
|
1654
|
-
abort();
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
copyStringSafe(resolved_filename, buffer, resolved_filename_size);
|
|
1658
|
-
} else {
|
|
1659
|
-
copyStringSafe(resolved_filename, filename, resolved_filename_size);
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
#endif
|
|
1663
|
-
|
|
1664
|
-
#ifdef _WIN32
|
|
1665
|
-
extern wchar_t const *getBinaryFilenameWideChars(bool resolve_symlinks);
|
|
1666
|
-
|
|
1667
|
-
char const *getBinaryFilenameHostEncoded(bool resolve_symlinks) {
|
|
1668
|
-
static char *binary_filename = NULL;
|
|
1669
|
-
static char *binary_filename_resolved = NULL;
|
|
1670
|
-
|
|
1671
|
-
char *binary_filename_target;
|
|
1672
|
-
|
|
1673
|
-
if (resolve_symlinks) {
|
|
1674
|
-
binary_filename_target = binary_filename_resolved;
|
|
1675
|
-
} else {
|
|
1676
|
-
binary_filename_target = binary_filename;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
if (binary_filename_target != NULL) {
|
|
1680
|
-
return binary_filename_target;
|
|
1681
|
-
}
|
|
1682
|
-
wchar_t const *w = getBinaryFilenameWideChars(resolve_symlinks);
|
|
1683
|
-
|
|
1684
|
-
DWORD bufsize = WideCharToMultiByte(CP_ACP, 0, w, -1, NULL, 0, NULL, NULL);
|
|
1685
|
-
assert(bufsize != 0);
|
|
1686
|
-
|
|
1687
|
-
binary_filename_target = (char *)malloc(bufsize + 1);
|
|
1688
|
-
assert(binary_filename_target);
|
|
1689
|
-
|
|
1690
|
-
DWORD res2 = WideCharToMultiByte(CP_ACP, 0, w, -1, binary_filename_target, bufsize, NULL, NULL);
|
|
1691
|
-
assert(res2 != 0);
|
|
1692
|
-
|
|
1693
|
-
if (unlikely(res2 > bufsize)) {
|
|
1694
|
-
abort();
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
return (char const *)binary_filename_target;
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
#else
|
|
1701
|
-
char const *getBinaryFilenameHostEncoded(bool resolve_symlinks) {
|
|
1702
|
-
const int buffer_size = MAXPATHLEN + 1;
|
|
1703
|
-
|
|
1704
|
-
static char binary_filename[MAXPATHLEN + 1] = {0};
|
|
1705
|
-
static char binary_filename_resolved[MAXPATHLEN + 1] = {0};
|
|
1706
|
-
|
|
1707
|
-
char *binary_filename_target;
|
|
1708
|
-
|
|
1709
|
-
if (resolve_symlinks) {
|
|
1710
|
-
binary_filename_target = binary_filename_resolved;
|
|
1711
|
-
} else {
|
|
1712
|
-
binary_filename_target = binary_filename;
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
if (*binary_filename_target != 0) {
|
|
1716
|
-
return binary_filename_target;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
#if defined(__APPLE__)
|
|
1720
|
-
uint32_t bufsize = buffer_size;
|
|
1721
|
-
int res = _NSGetExecutablePath(binary_filename_target, &bufsize);
|
|
1722
|
-
|
|
1723
|
-
if (unlikely(res != 0)) {
|
|
1724
|
-
abort();
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
// Resolve any symlinks we were invoked via
|
|
1728
|
-
resolveFileSymbolicLink(binary_filename_target, binary_filename_target, buffer_size, resolve_symlinks);
|
|
1729
|
-
|
|
1730
|
-
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
1731
|
-
/* Not all of FreeBSD has /proc file system, so use the appropriate
|
|
1732
|
-
* "sysctl" instead.
|
|
1733
|
-
*/
|
|
1734
|
-
int mib[4];
|
|
1735
|
-
mib[0] = CTL_KERN;
|
|
1736
|
-
mib[1] = KERN_PROC;
|
|
1737
|
-
mib[2] = KERN_PROC_PATHNAME;
|
|
1738
|
-
mib[3] = -1;
|
|
1739
|
-
size_t cb = buffer_size;
|
|
1740
|
-
int res = sysctl(mib, 4, binary_filename_target, &cb, NULL, 0);
|
|
1741
|
-
|
|
1742
|
-
if (unlikely(res != 0)) {
|
|
1743
|
-
abort();
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
// Resolve any symlinks we were invoked via
|
|
1747
|
-
resolveFileSymbolicLink(binary_filename_target, binary_filename_target, buffer_size, resolve_symlinks);
|
|
1748
|
-
#else
|
|
1749
|
-
/* The remaining platforms, mostly Linux or compatible. */
|
|
1750
|
-
|
|
1751
|
-
/* The "readlink" call does not terminate result, so fill zeros there, then
|
|
1752
|
-
* it is a proper C string right away. */
|
|
1753
|
-
memset(binary_filename_target, 0, buffer_size);
|
|
1754
|
-
ssize_t res = readlink("/proc/self/exe", binary_filename_target, buffer_size - 1);
|
|
1755
|
-
|
|
1756
|
-
if (unlikely(res == -1)) {
|
|
1757
|
-
abort();
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
// Resolve any symlinks we were invoked via
|
|
1761
|
-
resolveFileSymbolicLink(binary_filename_target, binary_filename_target, buffer_size, resolve_symlinks);
|
|
1762
|
-
#endif
|
|
1763
|
-
|
|
1764
|
-
return binary_filename_target;
|
|
1765
|
-
}
|
|
1766
|
-
#endif
|
|
1767
|
-
|
|
1768
|
-
#ifdef _WIN32
|
|
1769
|
-
wchar_t const *getBinaryFilenameWideChars(bool resolve_symlinks) {
|
|
1770
|
-
static wchar_t binary_filename[MAXPATHLEN + 1];
|
|
1771
|
-
static bool init_done = false;
|
|
1772
|
-
|
|
1773
|
-
if (init_done == false) {
|
|
1774
|
-
DWORD res = GetModuleFileNameW(NULL, binary_filename, sizeof(binary_filename) / sizeof(wchar_t));
|
|
1775
|
-
assert(res != 0);
|
|
1776
|
-
|
|
1777
|
-
// Resolve any symlinks we were invoked via
|
|
1778
|
-
resolveFileSymbolicLink(binary_filename, binary_filename, sizeof(binary_filename) / sizeof(wchar_t),
|
|
1779
|
-
resolve_symlinks);
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
return binary_filename;
|
|
1783
|
-
}
|
|
1784
|
-
#endif
|
|
1785
|
-
|
|
1786
1586
|
wchar_t const *getBinaryDirectoryWideChars(bool resolve_symlinks) {
|
|
1787
1587
|
static wchar_t binary_directory[MAXPATHLEN + 1];
|
|
1788
1588
|
static bool init_done = false;
|