Nuitka-winsvc 2.3.11__cp311-cp311-win_amd64.whl → 2.4.1__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 (210) hide show
  1. Nuitka_winsvc-2.3.11.data/scripts/nuitka-run.bat → Nuitka_winsvc-2.4.1.data/scripts/nuitka-run.cmd +1 -1
  2. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/METADATA +1 -1
  3. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/RECORD +210 -207
  4. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/WHEEL +1 -1
  5. nuitka/CacheCleanup.py +6 -1
  6. nuitka/HardImportRegistry.py +29 -2
  7. nuitka/MainControl.py +62 -35
  8. nuitka/ModuleRegistry.py +11 -3
  9. nuitka/OptionParsing.py +78 -39
  10. nuitka/Options.py +142 -35
  11. nuitka/OutputDirectories.py +5 -0
  12. nuitka/PostProcessing.py +23 -14
  13. nuitka/PythonFlavors.py +22 -4
  14. nuitka/PythonVersions.py +18 -0
  15. nuitka/TreeXML.py +6 -3
  16. nuitka/Version.py +1 -1
  17. nuitka/__main__.py +55 -10
  18. nuitka/build/Backend.scons +6 -1
  19. nuitka/build/CCompilerVersion.scons +1 -0
  20. nuitka/build/Onefile.scons +4 -0
  21. nuitka/build/SconsCaching.py +1 -0
  22. nuitka/build/SconsCompilerSettings.py +1 -0
  23. nuitka/build/SconsHacks.py +5 -1
  24. nuitka/build/SconsInterface.py +2 -0
  25. nuitka/build/SconsUtils.py +4 -1
  26. nuitka/build/include/nuitka/allocator.h +27 -5
  27. nuitka/build/include/nuitka/calling.h +1 -1
  28. nuitka/build/include/nuitka/compiled_frame.h +23 -23
  29. nuitka/build/include/nuitka/compiled_method.h +1 -1
  30. nuitka/build/include/nuitka/exception_groups.h +0 -2
  31. nuitka/build/include/nuitka/helper/attributes.h +7 -1
  32. nuitka/build/include/nuitka/helper/subscripts.h +1 -1
  33. nuitka/build/include/nuitka/helpers.h +7 -4
  34. nuitka/build/include/nuitka/prelude.h +6 -10
  35. nuitka/build/include/nuitka/printing.h +2 -0
  36. nuitka/build/include/nuitka/unfreezing.h +5 -5
  37. nuitka/build/inline_copy/tqdm/tqdm/_monitor.py +4 -1
  38. nuitka/build/static_src/CompiledAsyncgenType.c +2 -4
  39. nuitka/build/static_src/CompiledCellType.c +7 -7
  40. nuitka/build/static_src/CompiledCodeHelpers.c +49 -36
  41. nuitka/build/static_src/CompiledCoroutineType.c +2 -4
  42. nuitka/build/static_src/CompiledFrameType.c +109 -82
  43. nuitka/build/static_src/CompiledFunctionType.c +36 -9
  44. nuitka/build/static_src/CompiledGeneratorType.c +12 -10
  45. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +2 -2
  46. nuitka/build/static_src/CompiledMethodType.c +14 -13
  47. nuitka/build/static_src/HelpersAttributes.c +13 -15
  48. nuitka/build/static_src/HelpersBuiltin.c +16 -7
  49. nuitka/build/static_src/HelpersCalling.c +13 -13
  50. nuitka/build/static_src/HelpersCallingGenerated.c +22 -22
  51. nuitka/build/static_src/HelpersComparisonEq.c +110 -110
  52. nuitka/build/static_src/HelpersComparisonEqUtils.c +1 -1
  53. nuitka/build/static_src/HelpersComparisonGe.c +110 -110
  54. nuitka/build/static_src/HelpersComparisonGt.c +110 -110
  55. nuitka/build/static_src/HelpersComparisonLe.c +110 -110
  56. nuitka/build/static_src/HelpersComparisonLt.c +110 -110
  57. nuitka/build/static_src/HelpersComparisonNe.c +110 -110
  58. nuitka/build/static_src/HelpersConstantsBlob.c +480 -481
  59. nuitka/build/static_src/HelpersDictionaries.c +9 -0
  60. nuitka/build/static_src/HelpersFiles.c +2 -2
  61. nuitka/build/static_src/HelpersFilesystemPaths.c +28 -13
  62. nuitka/build/static_src/HelpersImport.c +1 -1
  63. nuitka/build/static_src/HelpersLists.c +5 -1
  64. nuitka/build/static_src/HelpersMatching.c +95 -35
  65. nuitka/build/static_src/HelpersOperationInplaceAdd.c +23 -23
  66. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -0
  67. nuitka/build/static_src/HelpersOperationInplaceBitand.c +11 -11
  68. nuitka/build/static_src/HelpersOperationInplaceBitor.c +11 -11
  69. nuitka/build/static_src/HelpersOperationInplaceBitxor.c +11 -11
  70. nuitka/build/static_src/HelpersOperationInplaceFloordiv.c +17 -17
  71. nuitka/build/static_src/HelpersOperationInplaceLshift.c +9 -9
  72. nuitka/build/static_src/HelpersOperationInplaceMatmult.c +10 -10
  73. nuitka/build/static_src/HelpersOperationInplaceMod.c +47 -47
  74. nuitka/build/static_src/HelpersOperationInplaceMult.c +28 -28
  75. nuitka/build/static_src/HelpersOperationInplaceOlddiv.c +17 -17
  76. nuitka/build/static_src/HelpersOperationInplacePow.c +17 -17
  77. nuitka/build/static_src/HelpersOperationInplaceRshift.c +9 -9
  78. nuitka/build/static_src/HelpersOperationInplaceSub.c +17 -17
  79. nuitka/build/static_src/HelpersOperationInplaceTruediv.c +17 -17
  80. nuitka/build/static_src/HelpersSequences.c +1 -1
  81. nuitka/build/static_src/HelpersTypes.c +8 -4
  82. nuitka/build/static_src/MainProgram.c +28 -9
  83. nuitka/build/static_src/MetaPathBasedLoader.c +124 -108
  84. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +13 -4
  85. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +1 -1
  86. nuitka/build/static_src/OnefileBootstrap.c +34 -6
  87. nuitka/code_generation/AttributeCodes.py +12 -10
  88. nuitka/code_generation/CodeGeneration.py +6 -7
  89. nuitka/code_generation/ConstantCodes.py +53 -10
  90. nuitka/code_generation/GlobalConstants.py +6 -6
  91. nuitka/code_generation/Indentation.py +3 -4
  92. nuitka/code_generation/LoaderCodes.py +3 -0
  93. nuitka/code_generation/LocalsDictCodes.py +36 -14
  94. nuitka/code_generation/MatchCodes.py +23 -4
  95. nuitka/code_generation/ModuleCodes.py +0 -7
  96. nuitka/code_generation/Namify.py +2 -0
  97. nuitka/code_generation/PackageResourceCodes.py +5 -1
  98. nuitka/code_generation/templates/CodeTemplatesConstants.py +6 -4
  99. nuitka/code_generation/templates/CodeTemplatesLoader.py +1 -1
  100. nuitka/code_generation/templates/CodeTemplatesModules.py +3 -3
  101. nuitka/code_generation/templates/CodeTemplatesVariables.py +16 -2
  102. nuitka/code_generation/templates_c/CodeTemplateCallsMethodPositional.c.j2 +2 -2
  103. nuitka/code_generation/templates_c/HelperOperationBinary.c.j2 +1 -1
  104. nuitka/code_generation/templates_c/HelperOperationInplace.c.j2 +1 -1
  105. nuitka/code_generation/templates_c/HelperSlotsBinary.c.j2 +7 -7
  106. nuitka/freezer/DependsExe.py +3 -1
  107. nuitka/freezer/DllDependenciesMacOS.py +5 -12
  108. nuitka/freezer/IncludedDataFiles.py +12 -3
  109. nuitka/freezer/IncludedEntryPoints.py +8 -2
  110. nuitka/freezer/Onefile.py +6 -1
  111. nuitka/freezer/Standalone.py +9 -2
  112. nuitka/importing/Importing.py +14 -5
  113. nuitka/importing/Recursion.py +3 -0
  114. nuitka/nodes/AttributeNodesGenerated.py +21 -12
  115. nuitka/nodes/BuiltinOpenNodes.py +5 -0
  116. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +11 -11
  117. nuitka/nodes/BuiltinRefNodes.py +41 -1
  118. nuitka/nodes/ChildrenHavingMixins.py +143 -355
  119. nuitka/nodes/ClassNodes.py +30 -12
  120. nuitka/nodes/CodeObjectSpecs.py +9 -0
  121. nuitka/nodes/ExpressionBasesGenerated.py +11 -11
  122. nuitka/nodes/FunctionNodes.py +7 -11
  123. nuitka/nodes/FutureSpecs.py +16 -3
  124. nuitka/nodes/GeneratorNodes.py +2 -2
  125. nuitka/nodes/HardImportNodesGenerated.py +11 -134
  126. nuitka/nodes/LocalsScopes.py +19 -23
  127. nuitka/nodes/MatchNodes.py +18 -7
  128. nuitka/nodes/ModuleAttributeNodes.py +1 -20
  129. nuitka/nodes/ModuleNodes.py +23 -6
  130. nuitka/nodes/NodeBases.py +3 -2
  131. nuitka/nodes/NodeMetaClasses.py +26 -10
  132. nuitka/nodes/ReturnNodes.py +1 -1
  133. nuitka/nodes/StatementBasesGenerated.py +11 -11
  134. nuitka/nodes/SubscriptNodes.py +4 -4
  135. nuitka/nodes/VariableAssignNodes.py +1 -1
  136. nuitka/nodes/VariableRefNodes.py +28 -2
  137. nuitka/optimizations/FunctionInlining.py +3 -6
  138. nuitka/optimizations/Optimization.py +13 -12
  139. nuitka/optimizations/TraceCollections.py +19 -4
  140. nuitka/plugins/PluginBase.py +121 -133
  141. nuitka/plugins/Plugins.py +91 -3
  142. nuitka/plugins/YamlPluginBase.py +121 -0
  143. nuitka/plugins/standard/AntiBloatPlugin.py +87 -28
  144. nuitka/plugins/standard/DataFilesPlugin.py +15 -6
  145. nuitka/plugins/standard/DelvewheelPlugin.py +7 -3
  146. nuitka/plugins/standard/DllFilesPlugin.py +5 -3
  147. nuitka/plugins/standard/ImplicitImports.py +34 -20
  148. nuitka/plugins/standard/MatplotlibPlugin.py +3 -1
  149. nuitka/plugins/standard/MultiprocessingPlugin.py +2 -2
  150. nuitka/plugins/standard/OptionsNannyPlugin.py +1 -1
  151. nuitka/plugins/standard/PySidePyQtPlugin.py +11 -12
  152. nuitka/plugins/standard/SpacyPlugin.py +136 -0
  153. nuitka/plugins/standard/standard.nuitka-package.config.yml +462 -179
  154. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +6 -0
  155. nuitka/reports/Reports.py +53 -5
  156. nuitka/specs/BuiltinParameterSpecs.py +1 -1
  157. nuitka/specs/HardImportSpecs.py +0 -6
  158. nuitka/tools/data_composer/DataComposer.py +29 -27
  159. nuitka/tools/environments/CreateEnvironment.py +1 -0
  160. nuitka/tools/environments/Virtualenv.py +25 -11
  161. nuitka/tools/general/find_module/FindModuleCode.py +13 -3
  162. nuitka/tools/onefile_compressor/OnefileCompressor.py +21 -4
  163. nuitka/tools/scanning/DisplayPackageDLLs.py +17 -3
  164. nuitka/tools/specialize/CTypeDescriptions.py +13 -7
  165. nuitka/tools/specialize/SpecializePython.py +18 -1
  166. nuitka/tools/testing/Common.py +19 -6
  167. nuitka/tools/testing/check_reference_counts/__main__.py +1 -1
  168. nuitka/tools/testing/run_nuitka_tests/__main__.py +0 -20
  169. nuitka/tools/watch/AutoStage.py +144 -0
  170. nuitka/tools/watch/__main__.py +79 -32
  171. nuitka/tree/Building.py +105 -104
  172. nuitka/tree/ComplexCallHelperFunctions.py +16 -26
  173. nuitka/tree/InternalModule.py +8 -0
  174. nuitka/tree/ReformulationAssignmentStatements.py +29 -59
  175. nuitka/tree/ReformulationClasses.py +10 -17
  176. nuitka/tree/ReformulationClasses3.py +69 -43
  177. nuitka/tree/ReformulationComparisonExpressions.py +6 -16
  178. nuitka/tree/ReformulationContractionExpressions.py +14 -23
  179. nuitka/tree/ReformulationDictionaryCreation.py +6 -10
  180. nuitka/tree/ReformulationExecStatements.py +10 -10
  181. nuitka/tree/ReformulationForLoopStatements.py +6 -12
  182. nuitka/tree/ReformulationFunctionStatements.py +21 -28
  183. nuitka/tree/ReformulationImportStatements.py +8 -10
  184. nuitka/tree/ReformulationLambdaExpressions.py +3 -6
  185. nuitka/tree/ReformulationMatchStatements.py +166 -60
  186. nuitka/tree/ReformulationMultidist.py +3 -1
  187. nuitka/tree/ReformulationNamespacePackages.py +1 -1
  188. nuitka/tree/ReformulationPrintStatements.py +3 -6
  189. nuitka/tree/ReformulationSequenceCreation.py +13 -26
  190. nuitka/tree/ReformulationTryFinallyStatements.py +15 -0
  191. nuitka/tree/ReformulationWithStatements.py +12 -16
  192. nuitka/tree/SourceHandling.py +13 -8
  193. nuitka/tree/VariableClosure.py +5 -21
  194. nuitka/utils/Distributions.py +80 -11
  195. nuitka/utils/Download.py +38 -31
  196. nuitka/utils/Execution.py +13 -2
  197. nuitka/utils/FileOperations.py +55 -28
  198. nuitka/utils/Images.py +6 -1
  199. nuitka/utils/Importing.py +1 -1
  200. nuitka/utils/ModuleNames.py +11 -5
  201. nuitka/utils/ReExecute.py +17 -13
  202. nuitka/utils/SharedLibraries.py +32 -8
  203. nuitka/utils/Signing.py +3 -1
  204. nuitka/utils/StaticLibraries.py +51 -41
  205. nuitka/utils/Timing.py +1 -1
  206. nuitka/utils/Utils.py +29 -7
  207. /Nuitka_winsvc-2.3.11.data/scripts/nuitka.bat → /Nuitka_winsvc-2.4.1.data/scripts/nuitka.cmd +0 -0
  208. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/LICENSE.txt +0 -0
  209. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/entry_points.txt +0 -0
  210. {Nuitka_winsvc-2.3.11.dist-info → Nuitka_winsvc-2.4.1.dist-info}/top_level.txt +0 -0
nuitka/plugins/Plugins.py CHANGED
@@ -106,7 +106,7 @@ def _addActivePlugin(plugin_class, args, force=False):
106
106
  else:
107
107
  plugin_args = {}
108
108
 
109
- with withPluginProblemReporting(plugin_class, "Plugin initialization failed", ()):
109
+ with withPluginProblemReporting(plugin_class, "plugin initialization", ()):
110
110
  plugin_instance = plugin_class(**plugin_args)
111
111
 
112
112
  assert isinstance(plugin_instance, NuitkaPluginBase), plugin_instance
@@ -824,8 +824,9 @@ class Plugins(object):
824
824
 
825
825
  for desc in description:
826
826
  if desc is None:
827
- pass
828
- elif len(desc) == 2:
827
+ continue
828
+
829
+ if len(desc) == 2:
829
830
  code, reason = desc
830
831
  flags = ()
831
832
  else:
@@ -1394,6 +1395,93 @@ class Plugins(object):
1394
1395
  for value in plugin.getExtraConstantDefaultPopulation():
1395
1396
  yield value
1396
1397
 
1398
+ @classmethod
1399
+ def _decideWithoutDisagreement(
1400
+ cls,
1401
+ method_name,
1402
+ call_per_plugin,
1403
+ legal_values,
1404
+ abstain_values,
1405
+ get_default_value,
1406
+ ):
1407
+ result = abstain_values[0]
1408
+ plugin_name = None
1409
+
1410
+ for plugin in getActivePlugins():
1411
+ value = call_per_plugin(plugin)
1412
+
1413
+ if value not in legal_values:
1414
+ plugin.sysexit(
1415
+ "Error, can only return '%s' from '%s' not %r"
1416
+ % (legal_values, method_name, value)
1417
+ )
1418
+
1419
+ if value in abstain_values:
1420
+ continue
1421
+
1422
+ if value != result:
1423
+ if result in abstain_values:
1424
+ result = value
1425
+ plugin_name = plugin.plugin_name
1426
+ else:
1427
+ plugin.sysexit(
1428
+ "Error, conflicting value '%s' with plug-in '%s' value '%s'."
1429
+ % (value, plugin_name, result)
1430
+ )
1431
+ if result in abstain_values:
1432
+ result = get_default_value()
1433
+
1434
+ return result
1435
+
1436
+ decide_annotations_cache = {}
1437
+
1438
+ @classmethod
1439
+ def decideAnnotations(cls, module_name):
1440
+ # For Python2 it's not a thing.
1441
+ if str is bytes:
1442
+ return False
1443
+
1444
+ if module_name not in cls.decide_annotations_cache:
1445
+ cls.decide_annotations_cache[module_name] = cls._decideWithoutDisagreement(
1446
+ call_per_plugin=lambda plugin: plugin.decideAnnotations(module_name),
1447
+ legal_values=(None, True, False),
1448
+ abstain_values=(None,),
1449
+ method_name="decideAnnotations",
1450
+ get_default_value=lambda: not Options.hasPythonFlagNoAnnotations(),
1451
+ )
1452
+
1453
+ return cls.decide_annotations_cache[module_name]
1454
+
1455
+ decide_doc_strings_cache = {}
1456
+
1457
+ @classmethod
1458
+ def decideDocStrings(cls, module_name):
1459
+ if module_name not in cls.decide_doc_strings_cache:
1460
+ cls.decide_doc_strings_cache[module_name] = cls._decideWithoutDisagreement(
1461
+ call_per_plugin=lambda plugin: plugin.decideDocStrings(module_name),
1462
+ legal_values=(None, True, False),
1463
+ abstain_values=(None,),
1464
+ method_name="decideDocStrings",
1465
+ get_default_value=lambda: not Options.hasPythonFlagNoDocStrings(),
1466
+ )
1467
+
1468
+ return cls.decide_doc_strings_cache[module_name]
1469
+
1470
+ decide_assertions_cache = {}
1471
+
1472
+ @classmethod
1473
+ def decideAssertions(cls, module_name):
1474
+ if module_name not in cls.decide_assertions_cache:
1475
+ cls.decide_assertions_cache[module_name] = cls._decideWithoutDisagreement(
1476
+ call_per_plugin=lambda plugin: plugin.decideAssertions(module_name),
1477
+ legal_values=(None, True, False),
1478
+ abstain_values=(None,),
1479
+ method_name="decideAssertions",
1480
+ get_default_value=lambda: not Options.hasPythonFlagNoAsserts(),
1481
+ )
1482
+
1483
+ return cls.decide_assertions_cache[module_name]
1484
+
1397
1485
  @classmethod
1398
1486
  def decideAllowOutsideDependencies(cls, module_name):
1399
1487
  result = None
@@ -0,0 +1,121 @@
1
+ # Copyright 2024, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
+
3
+
4
+ """
5
+ Plugins: Welcome to Nuitka! This is your shortest way to become part of it.
6
+
7
+ This is to provide the base class for all Yaml plugins. These deal with the
8
+ configuration files of Nuitka.
9
+ """
10
+
11
+ from nuitka.utils.Yaml import getYamlPackageConfiguration
12
+
13
+ from .PluginBase import NuitkaPluginBase
14
+
15
+
16
+ class NuitkaYamlPluginBase(NuitkaPluginBase):
17
+ """Nuitka base class for all plugins that use yaml config"""
18
+
19
+ def __init__(self):
20
+ self.config = getYamlPackageConfiguration()
21
+
22
+ def getYamlConfigItem(
23
+ self, module_name, section, item_name, decide_relevant, default, recursive
24
+ ):
25
+ while True:
26
+ module_configs = self.config.get(module_name, section=section)
27
+
28
+ if module_configs is not None:
29
+ for module_config in module_configs:
30
+ config_item = module_config.get(item_name, default)
31
+
32
+ # Avoid condition, if the item is not relevant
33
+ if decide_relevant is not None and not decide_relevant(config_item):
34
+ continue
35
+
36
+ if not self.evaluateCondition(
37
+ full_name=module_name,
38
+ condition=module_config.get("when", "True"),
39
+ ):
40
+ continue
41
+
42
+ if recursive:
43
+ yield module_name, config_item
44
+ else:
45
+ yield config_item
46
+
47
+ if not recursive:
48
+ break
49
+
50
+ module_name = module_name.getPackageName()
51
+ if not module_name:
52
+ break
53
+
54
+ def getYamlConfigItemItems(
55
+ self, module_name, section, item_name, decide_relevant, recursive
56
+ ):
57
+ def dict_decide_relevant(item_dict):
58
+ if not item_dict:
59
+ return False
60
+
61
+ if decide_relevant is None:
62
+ return True
63
+
64
+ for key, value in item_dict.items():
65
+ if decide_relevant(key, value):
66
+ return True
67
+
68
+ return False
69
+
70
+ for item_config in self.getYamlConfigItem(
71
+ module_name=module_name,
72
+ section=section,
73
+ item_name=item_name,
74
+ decide_relevant=dict_decide_relevant,
75
+ default={},
76
+ recursive=recursive,
77
+ ):
78
+ if recursive:
79
+ for key, value in item_config[1].items():
80
+ if decide_relevant(key, value):
81
+ yield item_config[0], key, value
82
+ else:
83
+ for key, value in item_config.items():
84
+ if decide_relevant(key, value):
85
+ yield key, value
86
+
87
+ def getYamlConfigItemSet(
88
+ self, module_name, section, item_name, decide_relevant, recursive
89
+ ):
90
+ for item_config in self.getYamlConfigItem(
91
+ module_name=module_name,
92
+ section=section,
93
+ item_name=item_name,
94
+ decide_relevant=None,
95
+ default=(),
96
+ recursive=recursive,
97
+ ):
98
+ if recursive:
99
+ for value in item_config[1]:
100
+ if decide_relevant is None or decide_relevant(value):
101
+ yield item_config[0], value
102
+ else:
103
+ for value in item_config:
104
+ if decide_relevant is None or decide_relevant(value):
105
+ yield value
106
+
107
+
108
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
109
+ # integrates with CPython, but also works on its own.
110
+ #
111
+ # Licensed under the Apache License, Version 2.0 (the "License");
112
+ # you may not use this file except in compliance with the License.
113
+ # You may obtain a copy of the License at
114
+ #
115
+ # http://www.apache.org/licenses/LICENSE-2.0
116
+ #
117
+ # Unless required by applicable law or agreed to in writing, software
118
+ # distributed under the License is distributed on an "AS IS" BASIS,
119
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120
+ # See the License for the specific language governing permissions and
121
+ # limitations under the License.
@@ -14,7 +14,8 @@ import re
14
14
  from nuitka.containers.OrderedDicts import OrderedDict
15
15
  from nuitka.Errors import NuitkaForbiddenImportEncounter
16
16
  from nuitka.ModuleRegistry import getModuleByName
17
- from nuitka.plugins.PluginBase import NuitkaYamlPluginBase
17
+ from nuitka.Options import isExperimental
18
+ from nuitka.plugins.YamlPluginBase import NuitkaYamlPluginBase
18
19
  from nuitka.utils.ModuleNames import ModuleName
19
20
 
20
21
  # spell-checker: ignore dask,numba,statsmodels,matplotlib,sqlalchemy,ipykernel
@@ -40,6 +41,7 @@ class NuitkaPluginAntiBloat(NuitkaYamlPluginBase):
40
41
  noinclude_setuptools_mode,
41
42
  noinclude_pytest_mode,
42
43
  noinclude_unittest_mode,
44
+ noinclude_pydoc_mode,
43
45
  noinclude_ipython_mode,
44
46
  noinclude_dask_mode,
45
47
  noinclude_numba_mode,
@@ -47,7 +49,8 @@ class NuitkaPluginAntiBloat(NuitkaYamlPluginBase):
47
49
  custom_choices,
48
50
  show_changes,
49
51
  ):
50
- # Many details, due to many repetitive arguments, pylint: disable=too-many-branches,too-many-statements
52
+ # Many details, due to many repetitive arguments,
53
+ # pylint: disable=too-many-branches,too-many-locals,too-many-statements
51
54
 
52
55
  NuitkaYamlPluginBase.__init__(self)
53
56
 
@@ -60,6 +63,8 @@ class NuitkaPluginAntiBloat(NuitkaYamlPluginBase):
60
63
  noinclude_pytest_mode = noinclude_default_mode
61
64
  if noinclude_unittest_mode is None:
62
65
  noinclude_unittest_mode = noinclude_default_mode
66
+ if noinclude_pydoc_mode is None:
67
+ noinclude_pydoc_mode = noinclude_default_mode
63
68
  if noinclude_ipython_mode is None:
64
69
  noinclude_ipython_mode = noinclude_default_mode
65
70
  if noinclude_dask_mode is None:
@@ -102,6 +107,10 @@ class NuitkaPluginAntiBloat(NuitkaYamlPluginBase):
102
107
  noinclude_setuptools_mode,
103
108
  "setuptools",
104
109
  )
110
+ self.handled_modules["numpy.distutils"] = (
111
+ noinclude_setuptools_mode,
112
+ "setuptools",
113
+ )
105
114
  else:
106
115
  self.control_tags["use_setuptools"] = True
107
116
 
@@ -173,6 +182,11 @@ class NuitkaPluginAntiBloat(NuitkaYamlPluginBase):
173
182
  else:
174
183
  self.control_tags["use_dask"] = True
175
184
 
185
+ if noinclude_pydoc_mode != "allow":
186
+ self.handled_modules["pydoc"] = noinclude_pydoc_mode, "pydoc"
187
+ else:
188
+ self.control_tags["use_pydoc"] = True
189
+
176
190
  if noinclude_numba_mode != "allow":
177
191
  self.handled_modules["numba"] = noinclude_numba_mode, "numba"
178
192
  self.handled_modules["sparse"] = noinclude_numba_mode, "numba"
@@ -289,6 +303,17 @@ What to do if a unittest import is encountered. This package can be big with
289
303
  dependencies, and should definitely be avoided.""",
290
304
  )
291
305
 
306
+ group.add_option(
307
+ "--noinclude-pydoc-mode",
308
+ action="store",
309
+ dest="noinclude_pydoc_mode",
310
+ choices=_mode_choices,
311
+ default=None,
312
+ help="""\
313
+ What to do if a pydoc import is encountered. This package use is mark of useless
314
+ code for deployments and should be avoided.""",
315
+ )
316
+
292
317
  group.add_option(
293
318
  "--noinclude-IPython-mode",
294
319
  action="store",
@@ -375,8 +400,8 @@ Error, cannot exec module '%s', context code '%s' due to: %s"""
375
400
  # To allow detection if it did anything.
376
401
  change_count = 0
377
402
 
378
- for replace_src, replace_code in anti_bloat_config.get(
379
- "replacements", {}
403
+ for replace_src, replace_code in (
404
+ anti_bloat_config.get("replacements") or {}
380
405
  ).items():
381
406
  # Avoid the eval, if the replace doesn't hit.
382
407
  if replace_src not in source_code:
@@ -401,8 +426,8 @@ Error, cannot exec module '%s', context code '%s' due to: %s"""
401
426
  if old != source_code:
402
427
  change_count += 1
403
428
 
404
- for replace_src, replace_dst in anti_bloat_config.get(
405
- "replacements_plain", {}
429
+ for replace_src, replace_dst in (
430
+ anti_bloat_config.get("replacements_plain") or {}
406
431
  ).items():
407
432
  old = source_code
408
433
  source_code = source_code.replace(replace_src, replace_dst)
@@ -410,14 +435,16 @@ Error, cannot exec module '%s', context code '%s' due to: %s"""
410
435
  if old != source_code:
411
436
  change_count += 1
412
437
 
413
- for replace_src, replace_dst in anti_bloat_config.get(
414
- "replacements_re", {}
438
+ for replace_src, replace_dst in (
439
+ anti_bloat_config.get("replacements_re") or {}
415
440
  ).items():
416
441
  old = source_code
417
- source_code = re.sub(replace_src, replace_dst, source_code)
442
+ source_code = re.sub(replace_src, replace_dst, source_code, re.S)
418
443
 
419
444
  if old != source_code:
420
445
  change_count += 1
446
+ elif isExperimental("display-anti-bloat-mismatches"):
447
+ self.info("No match in %s no match %r" % (module_name, replace_src))
421
448
 
422
449
  append_code = anti_bloat_config.get("append_result", "")
423
450
  if type(append_code) in (tuple, list):
@@ -604,30 +631,62 @@ class %(class_name)s:
604
631
  return result
605
632
 
606
633
  def _getModuleBloatModeOverrides(self, using_module_name, intended_module_name):
607
- while 1:
608
- config = self.config.get(using_module_name, section="anti-bloat")
634
+ # Finding a matching configuration aborts the search, not finding one
635
+ # means default behavior should apply.
636
+ for _config_module_name, bloat_mode_overrides in self.getYamlConfigItem(
637
+ module_name=using_module_name,
638
+ section="anti-bloat",
639
+ item_name="bloat-mode-overrides",
640
+ default={},
641
+ decide_relevant=(lambda config_item: intended_module_name in config_item),
642
+ recursive=True,
643
+ ):
644
+ return bloat_mode_overrides[intended_module_name]
609
645
 
610
- if config:
611
- for anti_bloat_config in config:
612
- bloat_mode_overrides = anti_bloat_config.get(
613
- "bloat-mode-overrides", ()
614
- )
646
+ return None
615
647
 
616
- if not bloat_mode_overrides:
617
- continue
648
+ def decideAnnotations(self, module_name):
649
+ # Finding a matching configuration aborts the search, not finding one
650
+ # means default behavior should apply.
651
+ for _config_module_name, annotations_config_value in self.getYamlConfigItem(
652
+ module_name=module_name,
653
+ section="anti-bloat",
654
+ item_name="annotations",
655
+ default=None,
656
+ decide_relevant=(lambda config_item: config_item in ("yes", "no")),
657
+ recursive=True,
658
+ ):
659
+ return annotations_config_value == "yes"
618
660
 
619
- if self.evaluateCondition(
620
- full_name=intended_module_name,
621
- condition=anti_bloat_config.get("when", "True"),
622
- ):
623
- for module_name, mode in bloat_mode_overrides.items():
624
- if module_name == intended_module_name:
625
- return mode
661
+ return None
662
+
663
+ def decideDocStrings(self, module_name):
664
+ # Finding a matching configuration aborts the search, not finding one
665
+ # means default behavior should apply.
666
+ for _config_module_name, doc_strings_config_value in self.getYamlConfigItem(
667
+ module_name=module_name,
668
+ section="anti-bloat",
669
+ item_name="doc_strings",
670
+ default=None,
671
+ decide_relevant=(lambda config_item: config_item in ("yes", "no")),
672
+ recursive=True,
673
+ ):
674
+ return doc_strings_config_value == "yes"
626
675
 
627
- using_module_name = using_module_name.getPackageName()
676
+ return None
628
677
 
629
- if not using_module_name:
630
- break
678
+ def decideAsserts(self, module_name):
679
+ # Finding a matching configuration aborts the search, not finding one
680
+ # means default behavior should apply.
681
+ for _config_module_name, asserts_config_value in self.getYamlConfigItem(
682
+ module_name=module_name,
683
+ section="anti-bloat",
684
+ item_name="asserts",
685
+ default=None,
686
+ decide_relevant=(lambda config_item: config_item in ("yes", "no")),
687
+ recursive=True,
688
+ ):
689
+ return asserts_config_value == "yes"
631
690
 
632
691
  return None
633
692
 
@@ -11,7 +11,7 @@ import pkgutil
11
11
  from nuitka import Options
12
12
  from nuitka.code_generation.ConstantCodes import addDistributionMetadataValue
13
13
  from nuitka.containers.OrderedSets import OrderedSet
14
- from nuitka.plugins.PluginBase import NuitkaYamlPluginBase
14
+ from nuitka.plugins.YamlPluginBase import NuitkaYamlPluginBase
15
15
  from nuitka.PythonFlavors import isDebianPackagePython
16
16
  from nuitka.utils.Distributions import getDistribution
17
17
  from nuitka.utils.FileOperations import (
@@ -45,7 +45,11 @@ class NuitkaPluginDataFileCollector(NuitkaYamlPluginBase):
45
45
 
46
46
  # Default to near module or inside package folder.
47
47
  if target_dir is None:
48
- if module.isCompiledPythonPackage() or module.isUncompiledPythonPackage():
48
+ if (
49
+ module.isCompiledPythonPackage()
50
+ or module.isUncompiledPythonPackage()
51
+ or module.isExtensionModulePackage()
52
+ ):
49
53
  target_dir = module_name.asPath()
50
54
  else:
51
55
  package_name = module_name.getPackageName()
@@ -97,7 +101,7 @@ class NuitkaPluginDataFileCollector(NuitkaYamlPluginBase):
97
101
 
98
102
  for empty_dir in empty_dirs:
99
103
  yield self.makeIncludedEmptyDirectory(
100
- dest_path=os.path.join(target_dir, empty_dir),
104
+ dest_path=os.path.normpath(os.path.join(target_dir, empty_dir)),
101
105
  reason="empty dir needed for %r" % module_name.asString(),
102
106
  tags="config",
103
107
  )
@@ -130,7 +134,7 @@ class NuitkaPluginDataFileCollector(NuitkaYamlPluginBase):
130
134
  if os.path.isdir(source_path):
131
135
  yield self.makeIncludedDataDirectory(
132
136
  source_path=source_path,
133
- dest_path=os.path.join(target_dir, data_dir),
137
+ dest_path=os.path.normpath(os.path.join(target_dir, data_dir)),
134
138
  reason="package data directory '%s' for %r"
135
139
  % (data_dir, module_name.asString()),
136
140
  tags="config",
@@ -150,7 +154,7 @@ class NuitkaPluginDataFileCollector(NuitkaYamlPluginBase):
150
154
  if os.path.isdir(source_path):
151
155
  yield self.makeIncludedDataDirectory(
152
156
  source_path=source_path,
153
- dest_path=os.path.join(target_dir, raw_dir),
157
+ dest_path=os.path.normpath(os.path.join(target_dir, raw_dir)),
154
158
  reason="package raw directory '%s' for %r"
155
159
  % (raw_dir, module_name.asString()),
156
160
  tags="config",
@@ -187,7 +191,12 @@ class NuitkaPluginDataFileCollector(NuitkaYamlPluginBase):
187
191
  distribution = getDistribution(distribution_name)
188
192
 
189
193
  if distribution is not None:
190
- addDistributionMetadataValue(distribution_name, distribution)
194
+ addDistributionMetadataValue(
195
+ distribution_name=distribution_name,
196
+ distribution=distribution,
197
+ reason="According to Yaml configuration 'include-metadata' for '%s'"
198
+ % module_name.asString(),
199
+ )
191
200
 
192
201
  def considerDataFiles(self, module):
193
202
  full_name = module.getFullName()
@@ -8,7 +8,7 @@
8
8
  import os
9
9
  import re
10
10
 
11
- from nuitka import Options
11
+ from nuitka.Options import isStandaloneMode
12
12
  from nuitka.plugins.PluginBase import NuitkaPluginBase
13
13
  from nuitka.PythonFlavors import isAnacondaPython
14
14
  from nuitka.utils.FileOperations import listDllFilesFromDirectory
@@ -42,7 +42,7 @@ class NuitkaPluginDelvewheel(NuitkaPluginBase):
42
42
 
43
43
  @staticmethod
44
44
  def isRelevant():
45
- return Options.isStandaloneMode()
45
+ return isStandaloneMode()
46
46
 
47
47
  # This is used by our exec below, to capture the dll directory without using a free
48
48
  # variable.
@@ -75,7 +75,7 @@ class NuitkaPluginDelvewheel(NuitkaPluginBase):
75
75
 
76
76
  # Fake the "__file__" to the proper value to the exec.
77
77
  exec_globals = {
78
- "__file__": self.locateModule(module_name) + "\\__init__.py",
78
+ "__file__": source_filename,
79
79
  "add_dll_directory": self._add_dll_directory,
80
80
  }
81
81
 
@@ -111,6 +111,10 @@ class NuitkaPluginDelvewheel(NuitkaPluginBase):
111
111
  detection_value=delvewheel_version,
112
112
  )
113
113
 
114
+ def getModuleSpecificDllPaths(self, module_name):
115
+ if module_name in self.dll_directories:
116
+ yield self.dll_directories[module_name]
117
+
114
118
  def getExtraDlls(self, module):
115
119
  full_name = module.getFullName()
116
120
 
@@ -13,7 +13,7 @@ import os
13
13
  import sys
14
14
 
15
15
  from nuitka.Options import isStandaloneMode
16
- from nuitka.plugins.PluginBase import NuitkaYamlPluginBase
16
+ from nuitka.plugins.YamlPluginBase import NuitkaYamlPluginBase
17
17
  from nuitka.PythonVersions import python_version
18
18
  from nuitka.utils.Distributions import (
19
19
  getDistributionFromModuleName,
@@ -41,7 +41,7 @@ class NuitkaPluginDllFiles(NuitkaYamlPluginBase):
41
41
  def isRelevant():
42
42
  return isStandaloneMode()
43
43
 
44
- def _handleDllConfigFromFilenames(self, dest_path, dll_config, full_name):
44
+ def _handleDllConfigFromFilenames(self, dll_config, full_name, dest_path):
45
45
  # A lot of details here, pylint: disable=too-many-locals
46
46
 
47
47
  # The "when" is at that level too for these.
@@ -260,7 +260,9 @@ conditions are missing, or this version of the module needs treatment added."""
260
260
  full_name=full_name, condition=dll_config.get("when", "True")
261
261
  ):
262
262
  for dll_entry_point in self._handleDllConfig(
263
- dll_config=dll_config, full_name=full_name, count=count
263
+ dll_config=dll_config,
264
+ full_name=full_name,
265
+ count=count,
264
266
  ):
265
267
  yield dll_entry_point
266
268
  found += 1
@@ -15,7 +15,7 @@ import os
15
15
  from nuitka.__past__ import iter_modules, unicode
16
16
  from nuitka.importing.Importing import locateModule
17
17
  from nuitka.importing.Recursion import decideRecursion
18
- from nuitka.plugins.PluginBase import NuitkaYamlPluginBase
18
+ from nuitka.plugins.YamlPluginBase import NuitkaYamlPluginBase
19
19
  from nuitka.utils.ModuleNames import ModuleName
20
20
  from nuitka.utils.Utils import isMacOS, isWin32Windows
21
21
 
@@ -84,6 +84,31 @@ class NuitkaPluginImplicitImports(NuitkaYamlPluginBase):
84
84
 
85
85
  yield current
86
86
 
87
+ def _resolveImplicitImportsConfig(self, full_name, dependency):
88
+ if "(" in dependency:
89
+ value = self.evaluateExpression(
90
+ full_name=full_name,
91
+ expression=dependency,
92
+ config_name="depends value",
93
+ extra_context=None,
94
+ single_value=False,
95
+ )
96
+
97
+ if type(value) in (str, unicode):
98
+ value = (value,)
99
+
100
+ for v in value:
101
+ if "*" in v or "?" in v:
102
+ for resolved in self._resolveModulePattern(v):
103
+ yield resolved
104
+ else:
105
+ yield v
106
+ elif "*" in dependency or "?" in dependency:
107
+ for resolved in self._resolveModulePattern(dependency):
108
+ yield resolved
109
+ else:
110
+ yield dependency
111
+
87
112
  def _handleImplicitImportsConfig(self, module, config):
88
113
  full_name = module.getFullName()
89
114
 
@@ -102,25 +127,11 @@ class NuitkaPluginImplicitImports(NuitkaYamlPluginBase):
102
127
  else:
103
128
  dependency = full_name.getSiblingNamed(dependency[1:]).asString()
104
129
 
105
- if "(" in dependency:
106
- value = self.evaluateExpression(
107
- full_name=full_name,
108
- expression=dependency,
109
- config_name="depends value",
110
- extra_context=None,
111
- single_value=False,
112
- )
113
-
114
- if type(value) in (str, unicode):
115
- value = (value,)
116
-
117
- for v in value:
118
- yield v
119
- elif "*" in dependency or "?" in dependency:
120
- for resolved in self._resolveModulePattern(dependency):
121
- yield resolved
122
- else:
123
- yield dependency
130
+ for value in self._resolveImplicitImportsConfig(
131
+ full_name=full_name,
132
+ dependency=dependency,
133
+ ):
134
+ yield value
124
135
 
125
136
  def _getImportsByFullname(self, module, full_name):
126
137
  """Provides names of modules to imported implicitly."""
@@ -255,6 +266,9 @@ class NuitkaPluginImplicitImports(NuitkaYamlPluginBase):
255
266
  elif full_name == crypto_module_name + ".Cipher.PKCS1_v1_5":
256
267
  yield crypto_module_name + ".Cipher._pkcs1_decode"
257
268
 
269
+ elif full_name == crypto_module_name + ".Cipher.PKCS1_OAEP":
270
+ yield crypto_module_name + ".Cipher._pkcs1_decode"
271
+
258
272
  elif full_name == crypto_module_name + ".Math._IntegerCustom":
259
273
  yield crypto_module_name + ".Math._modexp"
260
274
 
@@ -75,7 +75,9 @@ from inspect import getsource
75
75
  ("matplotlib_version", "__version__"),
76
76
  ),
77
77
  )
78
- except NuitkaCalledProcessError:
78
+ except NuitkaCalledProcessError as e:
79
+ self.debug("Exception during detection: %r" % e)
80
+
79
81
  if "MPLBACKEND" not in os.environ:
80
82
  self.sysexit(
81
83
  """\
@@ -124,10 +124,10 @@ Monkey patching "multiprocessing" for compiled methods.""",
124
124
 
125
125
  # For the call stack, this may look bad or different to what CPython
126
126
  # does, but such is life. The forking module was split up into multiple
127
- # modules in Python 3.4 so this is doubled. TODO: Move the version check
127
+ # modules in Python3 so this is doubled. TODO: Move the version check
128
128
  # into the code and let Nuitka compile time optimize it, which will also
129
129
  # make sure joblib support is there for Python2 as well.
130
- if python_version >= 0x340:
130
+ if python_version >= 0x300:
131
131
  source_code += """
132
132
  def __nuitka_freeze_support():
133
133
  import sys
@@ -13,7 +13,7 @@ from nuitka.Options import (
13
13
  isStandaloneMode,
14
14
  shallCreateAppBundle,
15
15
  )
16
- from nuitka.plugins.PluginBase import NuitkaYamlPluginBase
16
+ from nuitka.plugins.YamlPluginBase import NuitkaYamlPluginBase
17
17
  from nuitka.utils.Utils import isMacOS
18
18
 
19
19