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.
Files changed (84) hide show
  1. {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/RECORD +84 -81
  3. nuitka/Builtins.py +7 -1
  4. nuitka/MainControl.py +4 -0
  5. nuitka/OptionParsing.py +5 -3
  6. nuitka/Options.py +17 -2
  7. nuitka/Serialization.py +28 -5
  8. nuitka/Version.py +2 -2
  9. nuitka/build/Backend.scons +16 -3
  10. nuitka/build/CCompilerVersion.scons +1 -1
  11. nuitka/build/DataComposerInterface.py +15 -9
  12. nuitka/build/Onefile.scons +1 -1
  13. nuitka/build/SconsCompilerSettings.py +1 -0
  14. nuitka/build/SconsProgress.py +11 -2
  15. nuitka/build/SconsSpawn.py +15 -15
  16. nuitka/build/include/nuitka/builtins.h +2 -0
  17. nuitka/build/include/nuitka/filesystem_paths.h +4 -0
  18. nuitka/build/include/nuitka/helper/attributes.h +3 -0
  19. nuitka/build/include/nuitka/helper/import_hard.h +6 -0
  20. nuitka/build/include/nuitka/helpers.h +1 -1
  21. nuitka/build/include/nuitka/safe_string_ops.h +10 -3
  22. nuitka/build/static_src/CompiledCodeHelpers.c +0 -200
  23. nuitka/build/static_src/HelpersAttributes.c +185 -8
  24. nuitka/build/static_src/HelpersFilesystemPaths.c +528 -7
  25. nuitka/build/static_src/HelpersImportHard.c +38 -0
  26. nuitka/build/static_src/HelpersSafeStrings.c +6 -278
  27. nuitka/build/static_src/MainProgram.c +273 -73
  28. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +6 -0
  29. nuitka/build/static_src/OnefileBootstrap.c +19 -36
  30. nuitka/build/static_src/OnefileSplashScreen.cpp +1 -0
  31. nuitka/code_generation/AttributeCodes.py +42 -23
  32. nuitka/code_generation/CodeGeneration.py +4 -0
  33. nuitka/code_generation/FunctionCodes.py +18 -3
  34. nuitka/code_generation/GlobalConstants.py +8 -1
  35. nuitka/code_generation/PackageResourceCodes.py +40 -0
  36. nuitka/code_generation/templates/CodeTemplatesModules.py +1 -7
  37. nuitka/freezer/DllDependenciesMacOS.py +18 -1
  38. nuitka/freezer/IncludedDataFiles.py +6 -10
  39. nuitka/importing/ImportResolving.py +6 -0
  40. nuitka/importing/Recursion.py +24 -68
  41. nuitka/nodes/AttributeNodes.py +72 -19
  42. nuitka/nodes/ChildrenHavingMixins.py +203 -234
  43. nuitka/nodes/ExpressionBasesGenerated.py +136 -0
  44. nuitka/nodes/HardImportNodesGenerated.py +94 -0
  45. nuitka/nodes/ImportHardNodes.py +3 -3
  46. nuitka/nodes/ImportNodes.py +14 -4
  47. nuitka/nodes/ModuleNodes.py +4 -2
  48. nuitka/nodes/PackageMetadataNodes.py +12 -10
  49. nuitka/nodes/PackageResourceNodes.py +115 -0
  50. nuitka/nodes/TypeNodes.py +5 -1
  51. nuitka/plugins/PluginBase.py +32 -8
  52. nuitka/plugins/Plugins.py +44 -7
  53. nuitka/plugins/standard/AntiBloatPlugin.py +166 -72
  54. nuitka/plugins/standard/DataFilesPlugin.py +10 -0
  55. nuitka/plugins/standard/DllFilesPlugin.py +1 -2
  56. nuitka/plugins/standard/MatplotlibPlugin.py +24 -22
  57. nuitka/plugins/standard/MultiprocessingPlugin.py +5 -12
  58. nuitka/plugins/standard/OptionsNannyPlugin.py +2 -2
  59. nuitka/plugins/standard/PySidePyQtPlugin.py +18 -6
  60. nuitka/plugins/standard/PywebViewPlugin.py +4 -2
  61. nuitka/plugins/standard/TkinterPlugin.py +3 -0
  62. nuitka/plugins/standard/TransformersPlugin.py +11 -1
  63. nuitka/plugins/standard/TrioPlugin.py +6 -66
  64. nuitka/plugins/standard/standard.nuitka-package.config.yml +367 -21
  65. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +16 -4
  66. nuitka/specs/HardImportSpecs.py +6 -0
  67. nuitka/tools/data_composer/DataComposer.py +25 -27
  68. nuitka/tools/general/find_module/FindModuleCode.py +5 -2
  69. nuitka/tools/podman/Podman.py +53 -0
  70. nuitka/tools/podman/__init__.py +18 -0
  71. nuitka/tools/podman/__main__.py +255 -0
  72. nuitka/tools/specialize/SpecializePython.py +37 -3
  73. nuitka/tools/testing/RuntimeTracing.py +4 -0
  74. nuitka/tree/Building.py +1 -1
  75. nuitka/tree/ReformulationFunctionStatements.py +137 -10
  76. nuitka/utils/Execution.py +11 -1
  77. nuitka/utils/ModuleNames.py +1 -1
  78. nuitka/utils/SharedLibraries.py +7 -7
  79. {Nuitka_winsvc-1.6.6.data → Nuitka_winsvc-1.7.5.data}/scripts/nuitka-run.bat +0 -0
  80. {Nuitka_winsvc-1.6.6.data → Nuitka_winsvc-1.7.5.data}/scripts/nuitka.bat +0 -0
  81. {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/LICENSE.txt +0 -0
  82. {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/WHEEL +0 -0
  83. {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/entry_points.txt +0 -0
  84. {Nuitka_winsvc-1.6.6.dist-info → Nuitka_winsvc-1.7.5.dist-info}/top_level.txt +0 -0
@@ -744,6 +744,142 @@ ExpressionAttributeLookupBase = ChildHavingExpressionAttributeNameMixin
744
744
  ExpressionAttributeLookupSpecialBase = ChildHavingExpressionAttributeNameMixin
745
745
 
746
746
 
747
+ class ChildrenHavingExpressionNameRaiseWaitConstantNameMixin(ExpressionBase):
748
+ # Mixins are not allowed to specify slots, pylint: disable=assigning-non-slot
749
+ __slots__ = ()
750
+
751
+ # This is generated for use in
752
+ # ExpressionBuiltinHasattr
753
+
754
+ def __init__(self, expression, name, source_ref):
755
+ expression.parent = self
756
+
757
+ self.subnode_expression = expression
758
+
759
+ name.parent = self
760
+
761
+ self.subnode_name = name
762
+
763
+ ExpressionBase.__init__(self, source_ref)
764
+
765
+ def getVisitableNodes(self):
766
+ """The visitable nodes, with tuple values flattened."""
767
+
768
+ return (
769
+ self.subnode_expression,
770
+ self.subnode_name,
771
+ )
772
+
773
+ def getVisitableNodesNamed(self):
774
+ """Named children dictionary.
775
+
776
+ For use in cloning nodes, debugging and XML output.
777
+ """
778
+
779
+ return (
780
+ ("expression", self.subnode_expression),
781
+ ("name", self.subnode_name),
782
+ )
783
+
784
+ def replaceChild(self, old_node, new_node):
785
+ value = self.subnode_expression
786
+ if old_node is value:
787
+ new_node.parent = self
788
+
789
+ self.subnode_expression = new_node
790
+
791
+ return
792
+
793
+ value = self.subnode_name
794
+ if old_node is value:
795
+ new_node.parent = self
796
+
797
+ self.subnode_name = new_node
798
+
799
+ return
800
+
801
+ raise AssertionError("Didn't find child", old_node, "in", self)
802
+
803
+ def getCloneArgs(self):
804
+ """Get clones of all children to pass for a new node.
805
+
806
+ Needs to make clones of child nodes too.
807
+ """
808
+
809
+ values = {
810
+ "expression": self.subnode_expression.makeClone(),
811
+ "name": self.subnode_name.makeClone(),
812
+ }
813
+
814
+ values.update(self.getDetails())
815
+
816
+ return values
817
+
818
+ def finalize(self):
819
+ del self.parent
820
+
821
+ self.subnode_expression.finalize()
822
+ del self.subnode_expression
823
+ self.subnode_name.finalize()
824
+ del self.subnode_name
825
+
826
+ def computeExpressionRaw(self, trace_collection):
827
+ """Compute an expression.
828
+
829
+ Default behavior is to just visit the child expressions first, and
830
+ then the node "computeExpression". For a few cases this needs to
831
+ be overloaded, e.g. conditional expressions.
832
+ """
833
+
834
+ # First apply the sub-expressions, as they are evaluated before
835
+ # the actual operation.
836
+ for count, sub_expression in enumerate(self.getVisitableNodes()):
837
+ expression = trace_collection.onExpression(sub_expression)
838
+
839
+ if expression.willRaiseAnyException():
840
+ sub_expressions = self.getVisitableNodes()
841
+
842
+ wrapped_expression = wrapExpressionWithSideEffects(
843
+ side_effects=sub_expressions[:count],
844
+ old_node=sub_expression,
845
+ new_node=expression,
846
+ )
847
+
848
+ return (
849
+ wrapped_expression,
850
+ "new_raise",
851
+ lambda: "For '%s' the child expression '%s' will raise."
852
+ % (self.getChildNameNice(), expression.getChildNameNice()),
853
+ )
854
+
855
+ if self.subnode_name.isCompileTimeConstant():
856
+ try:
857
+ return self.computeExpressionConstantName(trace_collection)
858
+ finally:
859
+ trace_collection.onExceptionRaiseExit(BaseException)
860
+
861
+ # Then ask ourselves to work on it.
862
+ return self.computeExpression(trace_collection)
863
+
864
+ @abstractmethod
865
+ def computeExpression(self, trace_collection):
866
+ """Must be overloaded for non-final node."""
867
+
868
+ def collectVariableAccesses(self, emit_read, emit_write):
869
+ """Collect variable reads and writes of child nodes."""
870
+
871
+ self.subnode_expression.collectVariableAccesses(emit_read, emit_write)
872
+ self.subnode_name.collectVariableAccesses(emit_read, emit_write)
873
+
874
+ @abstractmethod
875
+ def computeExpressionConstantName(self, trace_collection):
876
+ """Called when attribute name is constant."""
877
+
878
+
879
+ # Assign the names that are easier to import with a stable name.
880
+ ExpressionBuiltinHasattrBase = ChildrenHavingExpressionNameRaiseWaitConstantNameMixin
881
+
882
+
747
883
  class ChildrenHavingLeftRightFinalNoRaiseMixin(ExpressionBase):
748
884
  # Mixins are not allowed to specify slots, pylint: disable=assigning-non-slot
749
885
  __slots__ = ()
@@ -47,6 +47,7 @@ from nuitka.specs.HardImportSpecs import (
47
47
  importlib_metadata_entry_points_since_310_spec,
48
48
  importlib_metadata_metadata_spec,
49
49
  importlib_metadata_version_spec,
50
+ importlib_resources_files_spec,
50
51
  importlib_resources_read_binary_spec,
51
52
  importlib_resources_read_text_spec,
52
53
  os_listdir_spec,
@@ -68,6 +69,7 @@ from nuitka.specs.HardImportSpecs import (
68
69
  from .ChildrenHavingMixins import (
69
70
  ChildHavingDistMixin,
70
71
  ChildHavingDistributionNameMixin,
72
+ ChildHavingPackageMixin,
71
73
  ChildHavingParamsTupleMixin,
72
74
  ChildHavingPathMixin,
73
75
  ChildHavingPathOptionalMixin,
@@ -1101,6 +1103,98 @@ class ExpressionImportlibMetadataVersionCallBase(
1101
1103
  return True
1102
1104
 
1103
1105
 
1106
+ class ExpressionImportlibResourcesFilesRef(
1107
+ ExpressionImportModuleNameHardExistsSpecificBase
1108
+ ):
1109
+ """Function reference importlib.resources.files"""
1110
+
1111
+ kind = "EXPRESSION_IMPORTLIB_RESOURCES_FILES_REF"
1112
+
1113
+ def __init__(self, source_ref):
1114
+ ExpressionImportModuleNameHardExistsSpecificBase.__init__(
1115
+ self,
1116
+ module_name="importlib.resources",
1117
+ import_name="files",
1118
+ module_guaranteed=True,
1119
+ source_ref=source_ref,
1120
+ )
1121
+
1122
+ def computeExpressionCall(self, call_node, call_args, call_kw, trace_collection):
1123
+ # Anything may happen on call trace before this. On next pass, if
1124
+ # replaced, we might be better but not now.
1125
+ trace_collection.onExceptionRaiseExit(BaseException)
1126
+
1127
+ from .PackageResourceNodes import ExpressionImportlibResourcesFilesCall
1128
+
1129
+ result = extractBuiltinArgs(
1130
+ node=call_node,
1131
+ builtin_class=ExpressionImportlibResourcesFilesCall,
1132
+ builtin_spec=importlib_resources_files_spec,
1133
+ )
1134
+
1135
+ return (
1136
+ result,
1137
+ "new_expression",
1138
+ "Call to 'importlib.resources.files' recognized.",
1139
+ )
1140
+
1141
+
1142
+ hard_import_node_classes[
1143
+ ExpressionImportlibResourcesFilesRef
1144
+ ] = importlib_resources_files_spec
1145
+
1146
+
1147
+ class ExpressionImportlibResourcesFilesCallBase(
1148
+ ChildHavingPackageMixin, ExpressionBase
1149
+ ):
1150
+ """Base class for ImportlibResourcesFilesCall
1151
+
1152
+ Generated boiler plate code.
1153
+ """
1154
+
1155
+ named_children = ("package",)
1156
+
1157
+ __slots__ = ("attempted",)
1158
+
1159
+ spec = importlib_resources_files_spec
1160
+
1161
+ def __init__(self, package, source_ref):
1162
+
1163
+ ChildHavingPackageMixin.__init__(
1164
+ self,
1165
+ package=package,
1166
+ )
1167
+
1168
+ ExpressionBase.__init__(self, source_ref)
1169
+
1170
+ # In module mode, we expect a changing environment, cannot optimize this
1171
+ self.attempted = shallMakeModule()
1172
+
1173
+ def computeExpression(self, trace_collection):
1174
+ if (
1175
+ self.attempted
1176
+ or not importlib_resources_files_spec.isCompileTimeComputable(
1177
+ (self.subnode_package,)
1178
+ )
1179
+ ):
1180
+ trace_collection.onExceptionRaiseExit(BaseException)
1181
+
1182
+ return self, None, None
1183
+
1184
+ try:
1185
+ return self.replaceWithCompileTimeValue(trace_collection)
1186
+ finally:
1187
+ self.attempted = True
1188
+
1189
+ @abstractmethod
1190
+ def replaceWithCompileTimeValue(self, trace_collection):
1191
+ pass
1192
+
1193
+ @staticmethod
1194
+ def mayRaiseExceptionOperation():
1195
+ return True
1196
+
1197
+
1104
1198
  class ExpressionImportlibResourcesReadBinaryRef(
1105
1199
  ExpressionImportModuleNameHardExistsSpecificBase
1106
1200
  ):
@@ -51,7 +51,7 @@ class ExpressionImportHardBase(ExpressionBase):
51
51
  assert self.finding != "not-found", self.module_name
52
52
  assert _module_name == self.module_name, (self.module_name, _module_name)
53
53
 
54
- def getModulesUsageAttempt(self):
54
+ def getModuleUsageAttempt(self):
55
55
  return makeModuleUsageAttempt(
56
56
  module_name=self.module_name,
57
57
  filename=self.module_filename,
@@ -117,7 +117,7 @@ class ExpressionImportModuleNameHardMaybeExists(ExpressionImportModuleNameHardBa
117
117
  trace_collection.onExceptionRaiseExit(AttributeError)
118
118
 
119
119
  # Trace the module usage attempt.
120
- trace_collection.onModuleUsageAttempt(self.getModulesUsageAttempt())
120
+ trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
121
121
 
122
122
  return self, None, None
123
123
 
@@ -143,7 +143,7 @@ class ExpressionImportModuleNameHardExists(ExpressionImportModuleNameHardBase):
143
143
  trace_collection.onExceptionRaiseExit(ImportError)
144
144
 
145
145
  # Trace the module usage attempt.
146
- trace_collection.onModuleUsageAttempt(self.getModulesUsageAttempt())
146
+ trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
147
147
 
148
148
  # As good as it gets.
149
149
  return self, None, None
@@ -98,6 +98,8 @@ hard_modules = frozenset(
98
98
  "pkgutil",
99
99
  "functools",
100
100
  "sysconfig",
101
+ "unittest",
102
+ "unittest.mock",
101
103
  # "cStringIO",
102
104
  "io",
103
105
  "ctypes",
@@ -263,6 +265,9 @@ hard_modules_trust = {
263
265
  "pkgutil": {"get_data": trust_node},
264
266
  "functools": {"partial": trust_exist},
265
267
  "sysconfig": {},
268
+ # TODO: We should have trust_module too.
269
+ "unittest": {"mock": trust_exist},
270
+ "unittest.mock": {},
266
271
  "io": {"BytesIO": trust_exist},
267
272
  # "cStringIO": {"StringIO": trust_exist},
268
273
  "pkg_resources": {
@@ -272,7 +277,11 @@ hard_modules_trust = {
272
277
  "resource_string": trust_node,
273
278
  "resource_stream": trust_node,
274
279
  },
275
- "importlib.resources": {"read_binary": trust_node, "read_text": trust_node},
280
+ "importlib.resources": {
281
+ "read_binary": trust_node,
282
+ "read_text": trust_node,
283
+ "files": trust_node,
284
+ },
276
285
  "ctypes": module_ctypes_trust,
277
286
  "site": {},
278
287
  "ctypes.wintypes": {},
@@ -369,6 +378,7 @@ class ExpressionImportAllowanceMixin(object):
369
378
  self.allowed = True
370
379
  else:
371
380
  self.allowed, _reason = decideRecursion(
381
+ using_module_name=None,
372
382
  module_filename=self.module_filename,
373
383
  module_name=self.module_name,
374
384
  module_kind=self.module_kind,
@@ -573,7 +583,7 @@ class ExpressionImportModuleHard(
573
583
  trace_collection.onExceptionRaiseExit(BaseException)
574
584
 
575
585
  # Trace the module usage attempt.
576
- trace_collection.onModuleUsageAttempt(self.getModulesUsageAttempt())
586
+ trace_collection.onModuleUsageAttempt(self.getModuleUsageAttempt())
577
587
 
578
588
  return self, None, None
579
589
 
@@ -1070,7 +1080,7 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1070
1080
  break
1071
1081
 
1072
1082
  (
1073
- _module_name_found,
1083
+ found_module_name,
1074
1084
  module_filename,
1075
1085
  module_kind,
1076
1086
  finding,
@@ -1082,7 +1092,7 @@ class ExpressionBuiltinImport(ChildrenExpressionBuiltinImportMixin, ExpressionBa
1082
1092
 
1083
1093
  self.used_modules.append(
1084
1094
  makeModuleUsageAttempt(
1085
- module_name=module_name,
1095
+ module_name=found_module_name,
1086
1096
  filename=module_filename,
1087
1097
  module_kind=module_kind,
1088
1098
  finding=finding,
@@ -29,6 +29,7 @@ from nuitka.importing.Importing import locateModule
29
29
  from nuitka.importing.Recursion import decideRecursion, recurseTo
30
30
  from nuitka.ModuleRegistry import getModuleByName, getOwnerFromCodeName
31
31
  from nuitka.optimizations.TraceCollections import TraceCollectionModule
32
+ from nuitka.Options import hasPythonFlagIsolated
32
33
  from nuitka.PythonVersions import python_version
33
34
  from nuitka.SourceCodeReferences import fromFilename
34
35
  from nuitka.tree.SourceHandling import parsePyIFile, readSourceCodeFromFilename
@@ -110,6 +111,7 @@ class PythonModuleBase(NodeBase):
110
111
  # assert _package_name == self.package_name, (package_filename, _package_name, self.package_name)
111
112
 
112
113
  decision, _reason = decideRecursion(
114
+ using_module_name=self.getFullName(),
113
115
  module_filename=package_filename,
114
116
  module_name=package_name,
115
117
  module_kind=package_module_kind,
@@ -123,7 +125,7 @@ class PythonModuleBase(NodeBase):
123
125
  module_name=package_name,
124
126
  module_filename=package_filename,
125
127
  module_kind=package_module_kind,
126
- using_module=self,
128
+ using_module_name=self.module_name,
127
129
  source_ref=self.source_ref,
128
130
  reason="Containing package of '%s'." % self.getFullName(),
129
131
  )
@@ -712,7 +714,7 @@ class CompiledPythonPackage(CompiledPythonModule):
712
714
 
713
715
  @staticmethod
714
716
  def canHaveExternalImports():
715
- return True
717
+ return not hasPythonFlagIsolated()
716
718
 
717
719
 
718
720
  def makeUncompiledPythonModule(
@@ -292,10 +292,12 @@ class ExpressionPkgResourcesDistributionValueRef(
292
292
  def computeExpressionAttribute(self, lookup_node, attribute_name, trace_collection):
293
293
  # If it raises, or the attribute itself is a compile time constant,
294
294
  # then do execute it.
295
- if not self.isKnownToHaveAttribute(
296
- attribute_name
297
- ) or isCompileTimeConstantValue(
298
- getattr(self.distribution, attribute_name, None)
295
+ if (
296
+ self.isKnownToHaveAttribute(attribute_name)
297
+ and isCompileTimeConstantValue(
298
+ getattr(self.distribution, attribute_name, None)
299
+ )
300
+ and (attribute_name != "location" or not isStandaloneMode())
299
301
  ):
300
302
  return trace_collection.getCompileTimeComputationResult(
301
303
  node=lookup_node,
@@ -453,9 +455,7 @@ class ExpressionPkgResourcesEntryPointValueRef(
453
455
  def computeExpressionAttribute(self, lookup_node, attribute_name, trace_collection):
454
456
  # If it raises, or the attribute itself is a compile time constant,
455
457
  # then do execute it.
456
- if not self.isKnownToHaveAttribute(
457
- attribute_name
458
- ) or isCompileTimeConstantValue(
458
+ if self.isKnownToHaveAttribute(attribute_name) and isCompileTimeConstantValue(
459
459
  getattr(self.entry_point, attribute_name, None)
460
460
  ):
461
461
  return trace_collection.getCompileTimeComputationResult(
@@ -513,6 +513,8 @@ class ExpressionImportlibMetadataDistributionCall(
513
513
  ImportlibMetadataDistributionCallMixin,
514
514
  ExpressionImportlibMetadataDistributionCallBase,
515
515
  ):
516
+ """Represents call to importlib.metadata.distribution(distribution_name)"""
517
+
516
518
  kind = "EXPRESSION_IMPORTLIB_METADATA_DISTRIBUTION_CALL"
517
519
 
518
520
  python_version_spec = ">= 0x380"
@@ -524,6 +526,8 @@ class ExpressionImportlibMetadataBackportDistributionCall(
524
526
  ImportlibMetadataDistributionCallMixin,
525
527
  ExpressionImportlibMetadataDistributionCallBase,
526
528
  ):
529
+ """Represents call to importlib_metadata.distribution(distribution_name)"""
530
+
527
531
  kind = "EXPRESSION_IMPORTLIB_METADATA_BACKPORT_DISTRIBUTION_CALL"
528
532
  importlib_metadata_name = "importlib_metadata"
529
533
 
@@ -586,9 +590,7 @@ class ExpressionImportlibMetadataEntryPointValueMixin(object):
586
590
  def computeExpressionAttribute(self, lookup_node, attribute_name, trace_collection):
587
591
  # If it raises, or the attribute itself is a compile time constant,
588
592
  # then do execute it.
589
- if not self.isKnownToHaveAttribute(
590
- attribute_name
591
- ) or isCompileTimeConstantValue(
593
+ if self.isKnownToHaveAttribute(attribute_name) and isCompileTimeConstantValue(
592
594
  getattr(self.entry_point, attribute_name, None)
593
595
  ):
594
596
  return trace_collection.getCompileTimeComputationResult(
@@ -17,12 +17,17 @@
17
17
  #
18
18
  """ Nodes the represent ways to access package data for pkglib, pkg_resources, etc. """
19
19
 
20
+ from nuitka.importing.Importing import locateModule, makeModuleUsageAttempt
21
+ from nuitka.importing.ImportResolving import resolveModuleName
22
+
20
23
  from .ConstantRefNodes import makeConstantRefNode
24
+ from .ExpressionBases import ExpressionBase
21
25
  from .ExpressionShapeMixins import (
22
26
  ExpressionBytesShapeExactMixin,
23
27
  ExpressionStrShapeExactMixin,
24
28
  )
25
29
  from .HardImportNodesGenerated import (
30
+ ExpressionImportlibResourcesFilesCallBase,
26
31
  ExpressionImportlibResourcesReadBinaryCallBase,
27
32
  ExpressionImportlibResourcesReadTextCallBase,
28
33
  ExpressionPkgResourcesResourceStreamCallBase,
@@ -136,3 +141,113 @@ class ExpressionImportlibResourcesReadTextCall(
136
141
  trace_collection.onExceptionRaiseExit(BaseException)
137
142
 
138
143
  return self, None, None
144
+
145
+
146
+ class ExpressionImportlibResourcesFilesCallMixin:
147
+ __slots__ = ()
148
+
149
+ # TODO: Looks as if this could be a convenience function of more general use.
150
+ def makeModuleUsageAttempt(self, package_name):
151
+ _package_name, module_filename, module_kind, finding = locateModule(
152
+ module_name=package_name,
153
+ parent_package=None,
154
+ level=0,
155
+ )
156
+
157
+ return makeModuleUsageAttempt(
158
+ module_name=package_name,
159
+ filename=module_filename,
160
+ module_kind=module_kind,
161
+ finding=finding,
162
+ level=0,
163
+ source_ref=self.source_ref,
164
+ )
165
+
166
+ # TODO: In standalone mode we could know a lot better.
167
+ @staticmethod
168
+ def mayRaiseExceptionOperation():
169
+ return True
170
+
171
+
172
+ class ExpressionImportlibResourcesFilesCallFixed(
173
+ ExpressionImportlibResourcesFilesCallMixin, ExpressionBase
174
+ ):
175
+ kind = "EXPRESSION_IMPORTLIB_RESOURCES_FILES_CALL_FIXED"
176
+
177
+ python_version_spec = ">= 0x370"
178
+
179
+ __slots__ = (
180
+ "package_name",
181
+ "module_usage_attempt",
182
+ )
183
+
184
+ def __init__(self, package_name, source_ref):
185
+ ExpressionBase.__init__(self, source_ref)
186
+
187
+ self.package_name = resolveModuleName(package_name)
188
+
189
+ self.module_usage_attempt = self.makeModuleUsageAttempt(
190
+ package_name=package_name
191
+ )
192
+
193
+ def finalize(self):
194
+ del self.module_usage_attempt
195
+
196
+ def getPackageNameUsed(self):
197
+ return makeConstantRefNode(
198
+ constant=self.package_name.asString(), source_ref=self.source_ref
199
+ )
200
+
201
+ def computeExpressionRaw(self, trace_collection):
202
+ trace_collection.onExceptionRaiseExit(BaseException)
203
+
204
+ trace_collection.onModuleUsageAttempt(self.module_usage_attempt)
205
+
206
+ return self, None, None
207
+
208
+
209
+ class ExpressionImportlibResourcesFilesCall(
210
+ ExpressionImportlibResourcesFilesCallMixin,
211
+ ExpressionImportlibResourcesFilesCallBase,
212
+ ):
213
+ kind = "EXPRESSION_IMPORTLIB_RESOURCES_FILES_CALL"
214
+
215
+ python_version_spec = ">= 0x370"
216
+
217
+ named_children = ("package",)
218
+
219
+ __slots__ = ("module_usage_attempt",)
220
+
221
+ def __init__(self, package, source_ref):
222
+ ExpressionImportlibResourcesFilesCallBase.__init__(
223
+ self, package=package, source_ref=source_ref
224
+ )
225
+
226
+ self.module_usage_attempt = None
227
+
228
+ def getPackageNameUsed(self):
229
+ return self.subnode_package
230
+
231
+ def replaceWithCompileTimeValue(self, trace_collection):
232
+ trace_collection.onExceptionRaiseExit(BaseException)
233
+
234
+ package_name = self.subnode_package.getCompileTimeConstant()
235
+
236
+ if type(package_name) is str:
237
+ package_name = resolveModuleName(package_name)
238
+ trace_collection.onModuleUsageAttempt(
239
+ self.makeModuleUsageAttempt(package_name)
240
+ )
241
+
242
+ result = ExpressionImportlibResourcesFilesCallFixed(
243
+ package_name=package_name, source_ref=self.source_ref
244
+ )
245
+
246
+ return (
247
+ result,
248
+ "new_expression",
249
+ "Detected 'importlib.resources.files' with constant package name '%s'."
250
+ % package_name,
251
+ )
252
+
253
+ return self, None, None
nuitka/nodes/TypeNodes.py CHANGED
@@ -22,6 +22,7 @@ them, their relationship or check for them in re-formulations.
22
22
 
23
23
  """
24
24
 
25
+ from nuitka.__past__ import GenericAlias
25
26
  from nuitka.Builtins import builtin_names
26
27
  from nuitka.Options import isExperimental
27
28
 
@@ -93,7 +94,10 @@ class ExpressionBuiltinType1(ExpressionBuiltinSingleArgBase):
93
94
  # The above code is supposed to catch these in a better way.
94
95
  value = value.getCompileTimeConstant()
95
96
 
96
- type_name = value.__class__.__name__
97
+ if type(value) is GenericAlias:
98
+ type_name = "GenericAlias"
99
+ else:
100
+ type_name = value.__class__.__name__
97
101
 
98
102
  if type_name in builtin_names:
99
103
  new_node = makeExpressionBuiltinRef(