Nuitka-winsvc 2.6__cp311-cp311-win_amd64.whl → 2.6.5__cp311-cp311-win_amd64.whl

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

Potentially problematic release.


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

Files changed (65) hide show
  1. {Nuitka_winsvc-2.6.dist-info → Nuitka_winsvc-2.6.5.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-2.6.dist-info → Nuitka_winsvc-2.6.5.dist-info}/RECORD +65 -61
  3. nuitka/BytecodeCaching.py +14 -3
  4. nuitka/ModuleRegistry.py +18 -3
  5. nuitka/Options.py +92 -66
  6. nuitka/PythonFlavors.py +15 -0
  7. nuitka/Version.py +1 -1
  8. nuitka/build/SconsCompilerSettings.py +3 -4
  9. nuitka/build/SconsInterface.py +2 -2
  10. nuitka/build/include/nuitka/compiled_frame.h +1 -1
  11. nuitka/build/include/nuitka/exceptions.h +1 -1
  12. nuitka/build/include/nuitka/type_aliases.h +1 -1
  13. nuitka/build/inline_copy/pefile/ordlookup/__init__.py +41 -0
  14. nuitka/build/inline_copy/pefile/ordlookup/oleaut32.py +400 -0
  15. nuitka/build/inline_copy/pefile/ordlookup/ws2_32.py +120 -0
  16. nuitka/build/static_src/CompiledAsyncgenType.c +2 -11
  17. nuitka/build/static_src/CompiledCodeHelpers.c +4 -2
  18. nuitka/build/static_src/CompiledCoroutineType.c +5 -13
  19. nuitka/build/static_src/CompiledGeneratorType.c +0 -10
  20. nuitka/build/static_src/HelpersConsole.c +1 -1
  21. nuitka/build/static_src/HelpersTypes.c +4 -4
  22. nuitka/build/static_src/MainProgram.c +24 -0
  23. nuitka/build/static_src/MetaPathBasedLoader.c +17 -10
  24. nuitka/build/static_src/OnefileBootstrap.c +3 -1
  25. nuitka/code_generation/TypeAliasCodes.py +3 -2
  26. nuitka/freezer/DllDependenciesMacOS.py +7 -2
  27. nuitka/freezer/DllDependenciesPosix.py +22 -3
  28. nuitka/freezer/DllDependenciesWin32.py +1 -0
  29. nuitka/freezer/IncludedDataFiles.py +1 -1
  30. nuitka/freezer/IncludedEntryPoints.py +8 -0
  31. nuitka/freezer/Standalone.py +11 -2
  32. nuitka/importing/Importing.py +2 -1
  33. nuitka/nodes/ChildrenHavingMixins.py +13 -13
  34. nuitka/nodes/FunctionNodes.py +7 -0
  35. nuitka/nodes/ModuleNodes.py +21 -7
  36. nuitka/nodes/PackageMetadataNodes.py +3 -1
  37. nuitka/nodes/TypeNodes.py +3 -3
  38. nuitka/plugins/PluginBase.py +67 -13
  39. nuitka/plugins/Plugins.py +1 -1
  40. nuitka/plugins/standard/AntiBloatPlugin.py +136 -65
  41. nuitka/plugins/standard/ImplicitImports.py +3 -2
  42. nuitka/plugins/standard/PySidePyQtPlugin.py +13 -0
  43. nuitka/plugins/standard/standard.nuitka-package.config.yml +151 -53
  44. nuitka/reports/Reports.py +25 -2
  45. nuitka/tools/general/find_module/FindModuleCode.py +4 -1
  46. nuitka/tools/scanning/DisplayPackageDLLs.py +5 -6
  47. nuitka/tools/watch/__main__.py +7 -2
  48. nuitka/tree/Building.py +4 -6
  49. nuitka/tree/FutureSpecState.py +71 -0
  50. nuitka/tree/ReformulationAssignmentStatements.py +2 -2
  51. nuitka/tree/ReformulationDictionaryCreation.py +2 -2
  52. nuitka/tree/ReformulationFunctionStatements.py +1 -1
  53. nuitka/tree/ReformulationImportStatements.py +4 -51
  54. nuitka/tree/ReformulationMultidist.py +1 -1
  55. nuitka/tree/ReformulationNamespacePackages.py +27 -5
  56. nuitka/tree/SourceHandling.py +56 -17
  57. nuitka/utils/Distributions.py +26 -6
  58. nuitka/utils/FileOperations.py +18 -6
  59. nuitka/utils/StaticLibraries.py +4 -0
  60. {Nuitka_winsvc-2.6.data → Nuitka_winsvc-2.6.5.data}/scripts/nuitka-run.cmd +0 -0
  61. {Nuitka_winsvc-2.6.data → Nuitka_winsvc-2.6.5.data}/scripts/nuitka.cmd +0 -0
  62. {Nuitka_winsvc-2.6.dist-info → Nuitka_winsvc-2.6.5.dist-info}/LICENSE.txt +0 -0
  63. {Nuitka_winsvc-2.6.dist-info → Nuitka_winsvc-2.6.5.dist-info}/WHEEL +0 -0
  64. {Nuitka_winsvc-2.6.dist-info → Nuitka_winsvc-2.6.5.dist-info}/entry_points.txt +0 -0
  65. {Nuitka_winsvc-2.6.dist-info → Nuitka_winsvc-2.6.5.dist-info}/top_level.txt +0 -0
@@ -58,6 +58,26 @@
58
58
  #include "HelpersConsole.c"
59
59
  #endif
60
60
 
61
+ // We are open to having this defined otherwise, this is a default only.
62
+ #if defined(_WIN32) && defined(NUITKA_COMPANY_NAME) && defined(NUITKA_PRODUCT_NAME) && \
63
+ !defined(NUITKA_APP_MODEL_USER_ID)
64
+ #define NUITKA_APP_MODEL_USER_ID L"" NUITKA_COMPANY_NAME L"." NUITKA_PRODUCT_NAME
65
+ #endif
66
+
67
+ #if defined(_WIN32) && defined(NUITKA_APP_MODEL_USER_ID)
68
+ typedef HRESULT(WINAPI *pfnSetCurrentProcessExplicitAppUserModelID)(PCWSTR AppID);
69
+
70
+ static void setCurrentProcessExplicitAppUserModelID(wchar_t const *app_user_model_id) {
71
+ pfnSetCurrentProcessExplicitAppUserModelID fnSetCurrentProcessExplicitAppUserModelID =
72
+ (pfnSetCurrentProcessExplicitAppUserModelID)GetProcAddress(GetModuleHandleA("Shell32.dll"),
73
+ "SetCurrentProcessExplicitAppUserModelID");
74
+
75
+ if (fnSetCurrentProcessExplicitAppUserModelID != NULL) {
76
+ fnSetCurrentProcessExplicitAppUserModelID(app_user_model_id);
77
+ }
78
+ }
79
+ #endif
80
+
61
81
  extern PyCodeObject *code_objects_main;
62
82
 
63
83
  /* For later use in "Py_GetArgcArgv" we expose the needed value */
@@ -1223,6 +1243,10 @@ int main(int argc, char **argv) {
1223
1243
  inheritAttachedConsole();
1224
1244
  #endif
1225
1245
 
1246
+ #if defined(_WIN32) && defined(NUITKA_APP_MODEL_USER_ID)
1247
+ setCurrentProcessExplicitAppUserModelID(NUITKA_APP_MODEL_USER_ID);
1248
+ #endif
1249
+
1226
1250
  #ifdef _NUITKA_MACOS_BUNDLE
1227
1251
  {
1228
1252
  char *current_dir = getcwd(NULL, -1);
@@ -1437,14 +1437,19 @@ static PyObject *getModuleFileValue(PyThreadState *tstate, struct Nuitka_MetaPat
1437
1437
 
1438
1438
  char filename_buffer[1024];
1439
1439
 
1440
- char const *basename = strrchr(entry->name, '.');
1441
- if (basename == NULL) {
1442
- basename = entry->name;
1440
+ if ((entry->flags & NUITKA_PACKAGE_FLAG) != 0) {
1441
+ copyStringSafe(filename_buffer, "__init__", sizeof(filename_buffer));
1443
1442
  } else {
1444
- basename += 1;
1445
- }
1443
+ char const *basename = strrchr(entry->name, '.');
1444
+
1445
+ if (basename == NULL) {
1446
+ basename = entry->name;
1447
+ } else {
1448
+ basename += 1;
1449
+ }
1446
1450
 
1447
- copyStringSafe(filename_buffer, basename, sizeof(filename_buffer));
1451
+ copyStringSafe(filename_buffer, basename, sizeof(filename_buffer));
1452
+ }
1448
1453
 
1449
1454
  if ((entry->flags & NUITKA_EXTENSION_MODULE_FLAG) != 0) {
1450
1455
  #if defined(_WIN32)
@@ -1452,9 +1457,6 @@ static PyObject *getModuleFileValue(PyThreadState *tstate, struct Nuitka_MetaPat
1452
1457
  #else
1453
1458
  appendStringSafe(filename_buffer, ".so", sizeof(filename_buffer));
1454
1459
  #endif
1455
- } else if ((entry->flags & NUITKA_PACKAGE_FLAG) != 0) {
1456
- appendCharSafe(filename_buffer, SEP, sizeof(filename_buffer));
1457
- appendStringSafe(filename_buffer, "__init__.py", sizeof(filename_buffer));
1458
1460
  } else {
1459
1461
  appendStringSafe(filename_buffer, ".py", sizeof(filename_buffer));
1460
1462
  }
@@ -2047,8 +2049,13 @@ void registerMetaPathBasedLoader(struct Nuitka_MetaPathBasedLoaderEntry *_loader
2047
2049
 
2048
2050
  global_loader);
2049
2051
 
2052
+ // Our "sys.path_hooks" entry uses "os.path" to compare filenames, so we need
2053
+ // to load it without.
2054
+ PyThreadState *tstate = PyThreadState_GET();
2055
+ IMPORT_HARD_OS_PATH(tstate);
2056
+
2050
2057
  // Register it as a sys.path_hook
2051
- LIST_APPEND1(Nuitka_SysGetObject("path_hooks"), PyObject_GetAttrString(global_loader, "sys_path_hook"));
2058
+ LIST_INSERT_CONST(Nuitka_SysGetObject("path_hooks"), 0, PyObject_GetAttrString(global_loader, "sys_path_hook"));
2052
2059
  }
2053
2060
 
2054
2061
  #if defined(_NUITKA_STANDALONE)
@@ -1147,7 +1147,9 @@ int main(int argc, char **argv) {
1147
1147
 
1148
1148
  input.src = payload_current;
1149
1149
  input.pos = 0;
1150
- input.size = payload_size;
1150
+
1151
+ // TODO: Ought to assert that this doesn't truncate anything.
1152
+ input.size = (size_t)payload_size;
1151
1153
 
1152
1154
  assert(payload_size > 0);
1153
1155
  #else
@@ -23,7 +23,7 @@ def generateTypeAliasCode(to_name, expression, emit, context):
23
23
  )
24
24
 
25
25
  compute_value_name = generateChildExpressionCode(
26
- expression=expression.subnode_compute_value, emit=emit, context=context
26
+ expression=expression.subnode_value, emit=emit, context=context
27
27
  )
28
28
 
29
29
  assert (
@@ -35,12 +35,13 @@ def generateTypeAliasCode(to_name, expression, emit, context):
35
35
  to_name, "type_alias_value", expression, emit, context
36
36
  ) as value_name:
37
37
  emit(
38
- "%s = MAKE_TYPE_ALIAS(%s, %s, %s);"
38
+ "%s = MAKE_TYPE_ALIAS(%s, %s, %s, %s);"
39
39
  % (
40
40
  value_name,
41
41
  context.getConstantCode(constant=type_alias_name),
42
42
  type_params_name,
43
43
  compute_value_name,
44
+ context.getConstantCode(constant=context.getModuleName().asString()),
44
45
  )
45
46
  )
46
47
 
@@ -148,8 +148,11 @@ def _parseOtoolListingOutput(output):
148
148
  def _getNonVersionedDllFilenames2(filename):
149
149
  yield filename
150
150
 
151
- if getArchitecture() == "arm64" and filename.endswith(".dylib"):
152
- yield filename[:-6] + "_arm64.dylib"
151
+ if filename.endswith(".dylib"):
152
+ if getArchitecture() == "arm64":
153
+ yield filename[:-6] + "_arm64.dylib"
154
+ else:
155
+ yield filename[:-6] + "_x86_64.dylib"
153
156
 
154
157
  match = re.match(r"^(.*?)(\.\d+)+\.dylib$", filename)
155
158
 
@@ -161,6 +164,8 @@ def _getNonVersionedDllFilenames2(filename):
161
164
  # examples to be sure they are covered with tests.
162
165
  if getArchitecture() == "arm64":
163
166
  yield match.group(1) + "_arm64.dylib"
167
+ else:
168
+ yield match.group(1) + "_x86_64.dylib"
164
169
 
165
170
  if filename.endswith(".so"):
166
171
  yield changeFilenameExtension(filename, ".dylib")
@@ -12,6 +12,7 @@ from nuitka.containers.OrderedSets import OrderedSet
12
12
  from nuitka.PythonFlavors import isAnacondaPython
13
13
  from nuitka.Tracing import inclusion_logger
14
14
  from nuitka.utils.Execution import executeProcess, withEnvironmentPathAdded
15
+ from nuitka.utils.FileOperations import resolveSymlink
15
16
  from nuitka.utils.SharedLibraries import getSharedLibraryRPATH
16
17
  from nuitka.utils.Utils import (
17
18
  isAlpineLinux,
@@ -30,7 +31,7 @@ ldd_result_cache = {}
30
31
 
31
32
  def detectBinaryPathDLLsPosix(dll_filename, package_name, original_dir):
32
33
  # This is complex, as it also includes the caching mechanism
33
- # pylint: disable=too-many-branches
34
+ # pylint: disable=too-many-branches,too-many-locals
34
35
 
35
36
  if ldd_result_cache.get(dll_filename):
36
37
  return ldd_result_cache[dll_filename]
@@ -46,13 +47,31 @@ def detectBinaryPathDLLsPosix(dll_filename, package_name, original_dir):
46
47
  _detected_python_rpath = getSharedLibraryRPATH(sys.executable) or False
47
48
 
48
49
  if _detected_python_rpath:
50
+ # Need to resolve a potential symlink.
51
+ if os.path.islink(sys.executable):
52
+ sys_executable = os.readlink(sys.executable)
53
+ else:
54
+ sys_executable = sys.executable
55
+
49
56
  _detected_python_rpath = _detected_python_rpath.replace(
50
- "$ORIGIN", os.path.dirname(sys.executable)
57
+ "$ORIGIN", os.path.dirname(sys_executable)
58
+ )
59
+
60
+ _detected_python_rpath = os.path.normpath(
61
+ os.path.join(os.path.dirname(sys.executable), _detected_python_rpath)
51
62
  )
52
63
 
53
64
  # Single one, might be wrong for Anaconda, which uses multiple ones on at least
54
65
  # macOS.
55
- python_rpaths = (_detected_python_rpath,) if _detected_python_rpath else ()
66
+ python_rpaths = []
67
+ if _detected_python_rpath:
68
+ python_rpaths.append(_detected_python_rpath)
69
+
70
+ if os.path.islink(dll_filename):
71
+ link_target_path = os.path.dirname(
72
+ os.path.abspath(resolveSymlink(dll_filename))
73
+ )
74
+ python_rpaths.append(link_target_path)
56
75
 
57
76
  # TODO: Actually would be better to pass it as env to the created process instead.
58
77
  with withEnvironmentPathAdded(
@@ -90,6 +90,7 @@ def detectBinaryPathDLLsWin32(
90
90
  use_cache,
91
91
  update_cache,
92
92
  ):
93
+ # For ARM64 and on user request, we can use "pefile" for dependency detection.
93
94
  dependency_tool = (
94
95
  "pefile"
95
96
  if (getArchitecture() == "arm64" or isExperimental("force-dependencies-pefile"))
@@ -312,8 +312,8 @@ def addIncludedDataFile(included_datafile):
312
312
  ) or isFilenameBelowPath(
313
313
  path=external_datafile_pattern, filename=included_datafile.dest_path
314
314
  ):
315
+ included_datafile.tags.clear()
315
316
  included_datafile.tags.add("inhibit")
316
- included_datafile.tags.remove("copy")
317
317
 
318
318
  return
319
319
 
@@ -352,6 +352,14 @@ def getStandaloneEntryPoints():
352
352
  return tuple(standalone_entry_points)
353
353
 
354
354
 
355
+ def getStandaloneEntryPointForSourceFile(source_path, package_name):
356
+ for standalone_entry_point in standalone_entry_points:
357
+ if standalone_entry_point.package_name == package_name and areSamePaths(
358
+ standalone_entry_point.source_path, source_path
359
+ ):
360
+ return standalone_entry_point
361
+
362
+
355
363
  # Part of "Nuitka", an optimizing Python compiler that is compatible and
356
364
  # integrates with CPython, but also works on its own.
357
365
  #
@@ -58,6 +58,7 @@ from .DllDependenciesWin32 import detectBinaryPathDLLsWin32
58
58
  from .IncludedEntryPoints import (
59
59
  addIncludedEntryPoint,
60
60
  getIncludedExtensionModule,
61
+ getStandaloneEntryPointForSourceFile,
61
62
  makeDllEntryPoint,
62
63
  )
63
64
 
@@ -127,7 +128,7 @@ def _detectBinaryDLLs(
127
128
  "otool" (macOS) the list of used DLLs is retrieved.
128
129
  """
129
130
 
130
- if isNuitkaPython():
131
+ if is_main_executable and isNuitkaPython():
131
132
  return OrderedSet()
132
133
  elif getOS() in ("Linux", "NetBSD", "FreeBSD", "OpenBSD") or isPosixWindows():
133
134
  return detectBinaryPathDLLsPosix(
@@ -384,7 +385,15 @@ Error, cannot detect used DLLs for DLL '%s' in package '%s' due to: %s"""
384
385
  )
385
386
  )
386
387
  else:
387
- dest_path = os.path.basename(used_dll_path)
388
+ existing_entry_point = getStandaloneEntryPointForSourceFile(
389
+ source_path=used_dll_path,
390
+ package_name=standalone_entry_point.package_name,
391
+ )
392
+
393
+ if existing_entry_point is None:
394
+ dest_path = os.path.basename(used_dll_path)
395
+ else:
396
+ dest_path = existing_entry_point.dest_path
388
397
 
389
398
  dll_entry_point = makeDllEntryPoint(
390
399
  logger=inclusion_logger,
@@ -439,7 +439,8 @@ ImportScanFinding = collections.namedtuple(
439
439
  # We put here things that are not worth it (Cython is not really used by
440
440
  # anything really, or where it's know to not have a big # impact, e.g. lxml.
441
441
 
442
- unworthy_namespaces = ("Cython", "lxml")
442
+ # TODO: Do we really want this warning to persist?
443
+ unworthy_namespaces = ("Cython", "lxml", "black", "tomli")
443
444
 
444
445
 
445
446
  def _reportCandidates(package_name, module_name, candidate, candidates):
@@ -20544,7 +20544,7 @@ class ChildHavingTypeParamsMixin(object):
20544
20544
  ChildrenExpressionTypeMakeGenericMixin = ChildHavingTypeParamsMixin
20545
20545
 
20546
20546
 
20547
- class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20547
+ class ChildrenHavingTypeParamsTupleValueMixin(object):
20548
20548
  # Mixins are not allowed to specify slots, pylint: disable=assigning-non-slot
20549
20549
  __slots__ = ()
20550
20550
 
@@ -20554,7 +20554,7 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20554
20554
  def __init__(
20555
20555
  self,
20556
20556
  type_params,
20557
- compute_value,
20557
+ value,
20558
20558
  ):
20559
20559
  assert type(type_params) is tuple
20560
20560
 
@@ -20563,16 +20563,16 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20563
20563
 
20564
20564
  self.subnode_type_params = type_params
20565
20565
 
20566
- compute_value.parent = self
20566
+ value.parent = self
20567
20567
 
20568
- self.subnode_compute_value = compute_value
20568
+ self.subnode_value = value
20569
20569
 
20570
20570
  def getVisitableNodes(self):
20571
20571
  """The visitable nodes, with tuple values flattened."""
20572
20572
 
20573
20573
  result = []
20574
20574
  result.extend(self.subnode_type_params)
20575
- result.append(self.subnode_compute_value)
20575
+ result.append(self.subnode_value)
20576
20576
  return tuple(result)
20577
20577
 
20578
20578
  def getVisitableNodesNamed(self):
@@ -20583,7 +20583,7 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20583
20583
 
20584
20584
  return (
20585
20585
  ("type_params", self.subnode_type_params),
20586
- ("compute_value", self.subnode_compute_value),
20586
+ ("value", self.subnode_value),
20587
20587
  )
20588
20588
 
20589
20589
  def replaceChild(self, old_node, new_node):
@@ -20602,11 +20602,11 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20602
20602
 
20603
20603
  return
20604
20604
 
20605
- value = self.subnode_compute_value
20605
+ value = self.subnode_value
20606
20606
  if old_node is value:
20607
20607
  new_node.parent = self
20608
20608
 
20609
- self.subnode_compute_value = new_node
20609
+ self.subnode_value = new_node
20610
20610
 
20611
20611
  return
20612
20612
 
@@ -20620,7 +20620,7 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20620
20620
 
20621
20621
  values = {
20622
20622
  "type_params": tuple(v.makeClone() for v in self.subnode_type_params),
20623
- "compute_value": self.subnode_compute_value.makeClone(),
20623
+ "value": self.subnode_value.makeClone(),
20624
20624
  }
20625
20625
 
20626
20626
  values.update(self.getDetails())
@@ -20633,8 +20633,8 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20633
20633
  for c in self.subnode_type_params:
20634
20634
  c.finalize()
20635
20635
  del self.subnode_type_params
20636
- self.subnode_compute_value.finalize()
20637
- del self.subnode_compute_value
20636
+ self.subnode_value.finalize()
20637
+ del self.subnode_value
20638
20638
 
20639
20639
  def computeExpressionRaw(self, trace_collection):
20640
20640
  """Compute an expression.
@@ -20673,11 +20673,11 @@ class ChildrenHavingTypeParamsTupleComputeValueMixin(object):
20673
20673
 
20674
20674
  for element in self.subnode_type_params:
20675
20675
  element.collectVariableAccesses(emit_read, emit_write)
20676
- self.subnode_compute_value.collectVariableAccesses(emit_read, emit_write)
20676
+ self.subnode_value.collectVariableAccesses(emit_read, emit_write)
20677
20677
 
20678
20678
 
20679
20679
  # Assign the names that are easier to import with a stable name.
20680
- ChildrenExpressionTypeAliasMixin = ChildrenHavingTypeParamsTupleComputeValueMixin
20680
+ ChildrenExpressionTypeAliasMixin = ChildrenHavingTypeParamsTupleValueMixin
20681
20681
 
20682
20682
 
20683
20683
  class ChildHavingValueMixin(object):
@@ -1229,6 +1229,9 @@ class ExpressionFunctionCall(ChildrenHavingFunctionValuesTupleMixin, ExpressionB
1229
1229
 
1230
1230
  values = self.subnode_values
1231
1231
 
1232
+ for value in values:
1233
+ value.onContentEscapes(trace_collection)
1234
+
1232
1235
  # Ask for function for its cost.
1233
1236
  cost = function_body.getFunctionInlineCost(values)
1234
1237
 
@@ -1279,6 +1282,10 @@ class ExpressionFunctionCall(ChildrenHavingFunctionValuesTupleMixin, ExpressionB
1279
1282
  def getClosureVariableVersions(self):
1280
1283
  return self.variable_closure_traces
1281
1284
 
1285
+ def onContentEscapes(self, trace_collection):
1286
+ for value in self.subnode_values:
1287
+ value.onContentEscapes(trace_collection)
1288
+
1282
1289
 
1283
1290
  # Part of "Nuitka", an optimizing Python compiler that is compatible and
1284
1291
  # integrates with CPython, but also works on its own.
@@ -20,7 +20,11 @@ from nuitka.PythonVersions import python_version
20
20
  from nuitka.SourceCodeReferences import fromFilename
21
21
  from nuitka.tree.SourceHandling import parsePyIFile, readSourceCodeFromFilename
22
22
  from nuitka.utils.CStrings import encodePythonIdentifierToC
23
- from nuitka.utils.Importing import getPackageDirFilename
23
+ from nuitka.utils.FileOperations import switchFilenameExtension
24
+ from nuitka.utils.Importing import (
25
+ getPackageDirFilename,
26
+ getSharedLibrarySuffixes,
27
+ )
24
28
  from nuitka.utils.ModuleNames import ModuleName
25
29
 
26
30
  from .ChildrenHavingMixins import (
@@ -1040,14 +1044,18 @@ class PythonExtensionModule(PythonModuleBase):
1040
1044
  """Get Python type description filename."""
1041
1045
 
1042
1046
  path = self.getFilename()
1043
- filename = os.path.basename(path)
1044
- dirname = os.path.dirname(path)
1045
1047
 
1046
- for suffix in (".pyi", ".py"):
1047
- candidate = os.path.join(dirname, filename.split(".")[0]) + suffix
1048
+ for extension_module_suffix in getSharedLibrarySuffixes():
1049
+ if path.endswith(extension_module_suffix):
1050
+ for pyi_suffix in (".pyi", ".py"):
1051
+ candidate = switchFilenameExtension(
1052
+ path=path,
1053
+ old_extension=extension_module_suffix,
1054
+ new_extension=pyi_suffix,
1055
+ )
1048
1056
 
1049
- if os.path.exists(candidate):
1050
- return candidate
1057
+ if os.path.exists(candidate):
1058
+ return candidate
1051
1059
 
1052
1060
  return None
1053
1061
 
@@ -1055,11 +1063,17 @@ class PythonExtensionModule(PythonModuleBase):
1055
1063
  """Read the .pyi file if present and scan for dependencies."""
1056
1064
 
1057
1065
  if self.used_modules is None:
1066
+ # TODO: Make this a locatePyIFilename function instead.
1058
1067
  pyi_filename = self._getPyIFilename()
1059
1068
 
1060
1069
  if pyi_filename is not None:
1061
1070
  pyi_deps = parsePyIFile(
1062
1071
  module_name=self.getFullName(),
1072
+ package_name=(
1073
+ self.getFullName()
1074
+ if self.is_package
1075
+ else self.getFullName().getPackageName()
1076
+ ),
1063
1077
  pyi_filename=pyi_filename,
1064
1078
  )
1065
1079
 
@@ -481,7 +481,9 @@ class ImportlibMetadataDistributionCallMixin(object):
481
481
  # In module mode, we cannot predict if the distribution is the same or not
482
482
  # so lets not optimize this further and treat it as an unknown.
483
483
  if shallMakeModule():
484
- return
484
+ trace_collection.onExceptionRaiseExit(BaseException)
485
+
486
+ return self, None, None
485
487
 
486
488
  distribution_func = self._getImportlibMetadataModule().distribution
487
489
  PackageNotFoundError = self._getImportlibMetadataModule().PackageNotFoundError
nuitka/nodes/TypeNodes.py CHANGED
@@ -334,11 +334,11 @@ class ExpressionSubtypeCheck(
334
334
  class ExpressionTypeAlias(ChildrenExpressionTypeAliasMixin, ExpressionBase):
335
335
  kind = "EXPRESSION_TYPE_ALIAS"
336
336
 
337
- named_children = ("type_params|tuple", "compute_value")
337
+ named_children = ("type_params|tuple", "value")
338
338
 
339
- def __init__(self, type_params, compute_value, source_ref):
339
+ def __init__(self, type_params, value, source_ref):
340
340
  ChildrenExpressionTypeAliasMixin.__init__(
341
- self, type_params=type_params, compute_value=compute_value
341
+ self, type_params=type_params, value=value
342
342
  )
343
343
 
344
344
  ExpressionBase.__init__(self, source_ref)
@@ -1301,7 +1301,8 @@ import sys
1301
1301
 
1302
1302
  try:
1303
1303
  %(setup_codes)s
1304
- except ImportError:
1304
+ except ImportError as e:
1305
+ sys.stderr.write("\n%%s" %% repr(e))
1305
1306
  sys.exit(38)
1306
1307
  try:
1307
1308
  %(query_codes)s
@@ -1323,6 +1324,11 @@ except Exception as e:
1323
1324
  feedback = check_output([sys.executable, "-c", cmd], env=env)
1324
1325
  except NuitkaCalledProcessError as e:
1325
1326
  if e.returncode == 38:
1327
+ self.warning(
1328
+ "Import error (not installed?) during compile time command execution: %s"
1329
+ % e.stderr.splitlines()[-1]
1330
+ )
1331
+
1326
1332
  return None
1327
1333
 
1328
1334
  if Options.is_debug:
@@ -1435,7 +1441,8 @@ except Exception as e:
1435
1441
  ):
1436
1442
  if self.isValueForEvaluation(expression):
1437
1443
  return self.evaluateExpression(
1438
- full_name=full_name,
1444
+ config_module_name=full_name,
1445
+ module_name=full_name,
1439
1446
  expression=expression,
1440
1447
  config_name=config_name,
1441
1448
  extra_context=extra_context,
@@ -1456,6 +1463,8 @@ except Exception as e:
1456
1463
  if declarations and self.evaluateCondition(
1457
1464
  full_name=full_name,
1458
1465
  condition=constant_config.get("when", "True"),
1466
+ allow_constants=False,
1467
+ allow_variables=False,
1459
1468
  ):
1460
1469
  for constant_name, constant_value in declarations.items():
1461
1470
  constants[constant_name] = self.evaluateExpressionOrConstant(
@@ -1492,6 +1501,8 @@ except Exception as e:
1492
1501
  if self.evaluateCondition(
1493
1502
  full_name=full_name,
1494
1503
  condition=variable_config.get("when", "True"),
1504
+ allow_constants=True,
1505
+ allow_variables=False,
1495
1506
  ):
1496
1507
  setup_codes.extend(
1497
1508
  "%s=%r" % (constant_name, constant_value)
@@ -1534,19 +1545,28 @@ except Exception as e:
1534
1545
  return _module_config_variables[full_name]
1535
1546
 
1536
1547
  def evaluateExpression(
1537
- self, full_name, expression, config_name, extra_context, single_value
1548
+ self,
1549
+ config_module_name,
1550
+ module_name,
1551
+ expression,
1552
+ config_name,
1553
+ extra_context,
1554
+ single_value,
1538
1555
  ):
1539
1556
  context = _makeEvaluationContext(
1540
- logger=self, full_name=full_name, config_name=config_name
1557
+ logger=self, full_name=config_module_name, config_name=config_name
1541
1558
  )
1542
1559
 
1543
1560
  def get_variable(variable_name):
1544
1561
  assert type(variable_name) is str, variable_name
1545
1562
 
1546
- result = self.getExpressionVariables(full_name=full_name)[variable_name]
1563
+ result = self.getExpressionVariables(full_name=config_module_name)[
1564
+ variable_name
1565
+ ]
1547
1566
 
1548
1567
  addModuleInfluencingVariable(
1549
- module_name=full_name,
1568
+ module_name=module_name,
1569
+ config_module_name=config_module_name,
1550
1570
  plugin_name=self.plugin_name,
1551
1571
  variable_name=variable_name,
1552
1572
  control_tags=context.used_tags,
@@ -1558,7 +1578,9 @@ except Exception as e:
1558
1578
  def get_constant(constant_name):
1559
1579
  assert type(constant_name) is str, constant_name
1560
1580
 
1561
- result = self.getExpressionConstants(full_name=full_name)[constant_name]
1581
+ result = self.getExpressionConstants(full_name=config_module_name)[
1582
+ constant_name
1583
+ ]
1562
1584
 
1563
1585
  # TODO: Record the constant value in report.
1564
1586
 
@@ -1568,13 +1590,13 @@ except Exception as e:
1568
1590
  context["get_constant"] = get_constant
1569
1591
 
1570
1592
  def get_parameter(parameter_name, default):
1571
- result = Options.getModuleParameter(full_name, parameter_name)
1593
+ result = Options.getModuleParameter(config_module_name, parameter_name)
1572
1594
 
1573
1595
  if result is None:
1574
1596
  result = default
1575
1597
 
1576
1598
  self.addModuleInfluencingParameter(
1577
- module_name=full_name,
1599
+ module_name=config_module_name,
1578
1600
  parameter_name=parameter_name,
1579
1601
  condition_tags_used=context.used_tags,
1580
1602
  result=result,
@@ -1603,16 +1625,16 @@ except Exception as e:
1603
1625
  if type(result) not in (str, unicode):
1604
1626
  if single_value:
1605
1627
  self._checkStrResult(
1606
- value=result, expression=expression, full_name=full_name
1628
+ value=result, expression=expression, full_name=config_module_name
1607
1629
  )
1608
1630
  else:
1609
1631
  self._checkSequenceResult(
1610
- value=result, expression=expression, full_name=full_name
1632
+ value=result, expression=expression, full_name=config_module_name
1611
1633
  )
1612
1634
 
1613
1635
  for v in result:
1614
1636
  self._checkStrResult(
1615
- value=v, expression=expression, full_name=full_name
1637
+ value=v, expression=expression, full_name=config_module_name
1616
1638
  )
1617
1639
 
1618
1640
  # Make it immutable in case it's a list.
@@ -1636,7 +1658,9 @@ Error, expression '%s' for module '%s' did not evaluate to 'tuple[str]' or 'list
1636
1658
  % (expression, full_name)
1637
1659
  )
1638
1660
 
1639
- def evaluateCondition(self, full_name, condition):
1661
+ def evaluateCondition(
1662
+ self, full_name, condition, allow_constants=True, allow_variables=True
1663
+ ):
1640
1664
  # Note: Caching makes no sense yet, this should all be very fast and
1641
1665
  # cache themselves. TODO: Allow plugins to contribute their own control
1642
1666
  # tag values during creation and during certain actions.
@@ -1650,6 +1674,36 @@ Error, expression '%s' for module '%s' did not evaluate to 'tuple[str]' or 'list
1650
1674
  logger=self, full_name=full_name, config_name="'when' configuration"
1651
1675
  )
1652
1676
 
1677
+ def get_variable(variable_name):
1678
+ assert type(variable_name) is str, variable_name
1679
+
1680
+ result = self.getExpressionVariables(full_name=full_name)[variable_name]
1681
+
1682
+ addModuleInfluencingVariable(
1683
+ module_name=full_name,
1684
+ config_module_name=full_name,
1685
+ plugin_name=self.plugin_name,
1686
+ variable_name=variable_name,
1687
+ control_tags=context.used_tags,
1688
+ result=result,
1689
+ )
1690
+
1691
+ return result
1692
+
1693
+ def get_constant(constant_name):
1694
+ assert type(constant_name) is str, constant_name
1695
+
1696
+ result = self.getExpressionConstants(full_name=full_name)[constant_name]
1697
+
1698
+ # TODO: Record the constant value in report.
1699
+
1700
+ return result
1701
+
1702
+ if allow_constants:
1703
+ context["get_constant"] = get_constant
1704
+ if allow_variables:
1705
+ context["get_variable"] = get_variable
1706
+
1653
1707
  def get_parameter(parameter_name, default):
1654
1708
  result = Options.getModuleParameter(full_name, parameter_name)
1655
1709
 
nuitka/plugins/Plugins.py CHANGED
@@ -414,7 +414,7 @@ class Plugins(object):
414
414
  if not checkModuleName(v):
415
415
  plugin.sysexit(
416
416
  "Plugin '%s' returned an invalid module name, not %r (for module '%s')"
417
- % (plugin, v, module.getFullName())
417
+ % (plugin.plugin_name, v, module.getFullName())
418
418
  )
419
419
 
420
420
  yield ModuleName(v)