Nuitka-winsvc 1.8.6__cp312-cp312-win_amd64.whl → 1.9.3__cp312-cp312-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 (214) hide show
  1. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/RECORD +212 -203
  3. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/WHEEL +1 -1
  4. nuitka/BytecodeCaching.py +4 -1
  5. nuitka/HardImportRegistry.py +348 -0
  6. nuitka/MainControl.py +45 -25
  7. nuitka/OptionParsing.py +31 -20
  8. nuitka/Options.py +47 -16
  9. nuitka/Progress.py +32 -2
  10. nuitka/PythonFlavors.py +1 -1
  11. nuitka/PythonVersions.py +61 -0
  12. nuitka/Tracing.py +25 -12
  13. nuitka/TreeXML.py +5 -5
  14. nuitka/Variables.py +15 -24
  15. nuitka/Version.py +16 -6
  16. nuitka/__main__.py +15 -0
  17. nuitka/__past__.py +15 -17
  18. nuitka/build/Backend.scons +44 -35
  19. nuitka/build/CCompilerVersion.scons +10 -9
  20. nuitka/build/Onefile.scons +11 -26
  21. nuitka/build/SconsCaching.py +2 -0
  22. nuitka/build/SconsCompilerSettings.py +72 -22
  23. nuitka/build/SconsHacks.py +1 -0
  24. nuitka/build/SconsInterface.py +5 -0
  25. nuitka/build/SconsSpawn.py +16 -3
  26. nuitka/build/SconsUtils.py +11 -12
  27. nuitka/build/include/nuitka/checksum_tools.h +0 -4
  28. nuitka/build/include/nuitka/compiled_asyncgen.h +1 -1
  29. nuitka/build/include/nuitka/compiled_coroutine.h +1 -1
  30. nuitka/build/include/nuitka/compiled_frame.h +7 -4
  31. nuitka/build/include/nuitka/compiled_function.h +13 -3
  32. nuitka/build/include/nuitka/compiled_generator.h +1 -1
  33. nuitka/build/include/nuitka/constants.h +2 -0
  34. nuitka/build/include/nuitka/environment_variables.h +45 -0
  35. nuitka/build/include/nuitka/exceptions.h +32 -4
  36. nuitka/build/include/nuitka/filesystem_paths.h +6 -1
  37. nuitka/build/include/nuitka/freelists.h +11 -1
  38. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  39. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  40. nuitka/build/include/nuitka/helpers.h +2 -0
  41. nuitka/build/include/nuitka/importing.h +3 -0
  42. nuitka/build/include/nuitka/prelude.h +17 -6
  43. nuitka/build/include/nuitka/unfreezing.h +1 -1
  44. nuitka/build/inline_copy/bin/scons.py +14 -0
  45. nuitka/build/inline_copy/tqdm/tqdm/__init__.py +2 -2
  46. nuitka/build/inline_copy/tqdm/tqdm/utils.py +14 -8
  47. nuitka/build/inline_copy/zlib/LICENSE +22 -0
  48. nuitka/build/inline_copy/zlib/crc32.c +1049 -0
  49. nuitka/build/inline_copy/zlib/crc32.h +9446 -0
  50. nuitka/build/inline_copy/zlib/zconf.h +551 -0
  51. nuitka/build/inline_copy/zlib/zlib.h +1938 -0
  52. nuitka/build/inline_copy/zlib/zutil.h +275 -0
  53. nuitka/build/static_src/CompiledAsyncgenType.c +41 -41
  54. nuitka/build/static_src/CompiledCodeHelpers.c +14 -7
  55. nuitka/build/static_src/CompiledCoroutineType.c +60 -51
  56. nuitka/build/static_src/CompiledFrameType.c +12 -12
  57. nuitka/build/static_src/CompiledFunctionType.c +149 -28
  58. nuitka/build/static_src/CompiledGeneratorType.c +64 -65
  59. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +1 -1
  60. nuitka/build/static_src/CompiledMethodType.c +5 -3
  61. nuitka/build/static_src/HelperEnvironmentVariables.c +120 -0
  62. nuitka/build/static_src/HelpersAttributes.c +1 -1
  63. nuitka/build/static_src/HelpersBuiltin.c +1 -1
  64. nuitka/build/static_src/HelpersChecksumTools.c +19 -4
  65. nuitka/build/static_src/HelpersComparisonEq.c +4 -4
  66. nuitka/build/static_src/HelpersComparisonNe.c +4 -4
  67. nuitka/build/static_src/HelpersConstantsBlob.c +40 -23
  68. nuitka/build/static_src/HelpersDictionaries.c +3 -1
  69. nuitka/build/static_src/HelpersDictionariesGenerated.c +9 -9
  70. nuitka/build/static_src/HelpersFilesystemPaths.c +12 -2
  71. nuitka/build/static_src/HelpersImport.c +29 -1
  72. nuitka/build/static_src/HelpersImportHard.c +19 -0
  73. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +5 -4
  74. nuitka/build/static_src/HelpersPythonPgo.c +5 -5
  75. nuitka/build/static_src/HelpersSafeStrings.c +2 -1
  76. nuitka/build/static_src/HelpersStrings.c +12 -10
  77. nuitka/build/static_src/HelpersTypes.c +1 -1
  78. nuitka/build/static_src/InspectPatcher.c +3 -2
  79. nuitka/build/static_src/MainProgram.c +182 -214
  80. nuitka/build/static_src/MetaPathBasedLoader.c +36 -23
  81. nuitka/build/static_src/MetaPathBasedLoaderImportlibMetadataDistribution.c +4 -2
  82. nuitka/build/static_src/MetaPathBasedLoaderResourceReaderFiles.c +38 -2
  83. nuitka/build/static_src/OnefileBootstrap.c +124 -93
  84. nuitka/code_generation/CodeGeneration.py +4 -2
  85. nuitka/code_generation/CodeObjectCodes.py +5 -1
  86. nuitka/code_generation/ConstantCodes.py +4 -0
  87. nuitka/code_generation/Contexts.py +111 -3
  88. nuitka/code_generation/DictCodes.py +5 -5
  89. nuitka/code_generation/FunctionCodes.py +4 -2
  90. nuitka/code_generation/GlobalConstants.py +10 -0
  91. nuitka/code_generation/ImportCodes.py +69 -33
  92. nuitka/code_generation/ModuleCodes.py +4 -1
  93. nuitka/code_generation/Namify.py +6 -5
  94. nuitka/code_generation/YieldCodes.py +3 -3
  95. nuitka/code_generation/templates/CodeTemplatesModules.py +61 -95
  96. nuitka/code_generation/templates_c/HelperDictionaryCopy.c.j2 +3 -3
  97. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +2 -2
  98. nuitka/distutils/DistutilCommands.py +3 -0
  99. nuitka/finalizations/FinalizeMarkups.py +1 -1
  100. nuitka/freezer/DependsExe.py +2 -1
  101. nuitka/freezer/DllDependenciesPosix.py +11 -1
  102. nuitka/freezer/IncludedEntryPoints.py +54 -16
  103. nuitka/freezer/Onefile.py +7 -3
  104. nuitka/freezer/Standalone.py +39 -17
  105. nuitka/importing/Importing.py +195 -62
  106. nuitka/importing/PreloadedPackages.py +2 -1
  107. nuitka/importing/Recursion.py +98 -27
  108. nuitka/importing/StandardLibrary.py +7 -4
  109. nuitka/nodes/BuiltinOpenNodes.py +28 -1
  110. nuitka/nodes/BuiltinRangeNodes.py +2 -2
  111. nuitka/nodes/BuiltinSumNodes.py +1 -1
  112. nuitka/nodes/ChildrenHavingMixins.py +326 -2
  113. nuitka/nodes/HardImportNodesGenerated.py +141 -38
  114. nuitka/nodes/ImportHardNodes.py +0 -8
  115. nuitka/nodes/ImportNodes.py +267 -361
  116. nuitka/nodes/IterationHandles.py +36 -17
  117. nuitka/nodes/LocalsScopes.py +3 -1
  118. nuitka/nodes/NodeBases.py +8 -14
  119. nuitka/nodes/OperatorNodes.py +9 -9
  120. nuitka/nodes/OutlineNodes.py +3 -3
  121. nuitka/nodes/PackageMetadataNodes.py +19 -9
  122. nuitka/nodes/SliceNodes.py +1 -1
  123. nuitka/nodes/VariableAssignNodes.py +25 -15
  124. nuitka/nodes/VariableRefNodes.py +7 -7
  125. nuitka/nodes/YieldNodes.py +2 -2
  126. nuitka/nodes/shapes/BuiltinTypeShapes.py +81 -6
  127. nuitka/nodes/shapes/ShapeMixins.py +21 -0
  128. nuitka/nodes/shapes/StandardShapes.py +9 -3
  129. nuitka/optimizations/OptimizeBuiltinCalls.py +1 -1
  130. nuitka/optimizations/TraceCollections.py +75 -0
  131. nuitka/pgo/PGO.py +14 -6
  132. nuitka/plugins/PluginBase.py +83 -11
  133. nuitka/plugins/Plugins.py +78 -35
  134. nuitka/plugins/standard/AntiBloatPlugin.py +46 -1
  135. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +1 -1
  136. nuitka/plugins/standard/DelvewheelPlugin.py +2 -1
  137. nuitka/plugins/standard/DillPlugin.py +3 -99
  138. nuitka/plugins/standard/DllFilesPlugin.py +45 -0
  139. nuitka/plugins/standard/GiPlugin.py +23 -10
  140. nuitka/plugins/standard/GlfwPlugin.py +1 -0
  141. nuitka/plugins/standard/ImplicitImports.py +267 -15
  142. nuitka/plugins/standard/KivyPlugin.py +1 -0
  143. nuitka/plugins/standard/MatplotlibPlugin.py +43 -25
  144. nuitka/plugins/standard/OptionsNannyPlugin.py +5 -6
  145. nuitka/plugins/standard/PkgResourcesPlugin.py +1 -1
  146. nuitka/plugins/standard/PmwPlugin.py +1 -1
  147. nuitka/plugins/standard/PySidePyQtPlugin.py +37 -20
  148. nuitka/plugins/standard/TkinterPlugin.py +44 -30
  149. nuitka/plugins/standard/TransformersPlugin.py +3 -1
  150. nuitka/plugins/standard/standard.nuitka-package.config.yml +522 -86
  151. nuitka/plugins/standard/stdlib3.nuitka-package.config.yml +8 -1
  152. nuitka/reports/CompilationReportReader.py +53 -0
  153. nuitka/reports/LicenseReport.rst.j2 +4 -4
  154. nuitka/reports/Reports.py +129 -47
  155. nuitka/specs/HardImportSpecs.py +6 -0
  156. nuitka/tools/data_composer/DataComposer.py +29 -17
  157. nuitka/tools/onefile_compressor/OnefileCompressor.py +173 -110
  158. nuitka/tools/podman/__main__.py +17 -2
  159. nuitka/tools/scanning/DisplayPackageDLLs.py +11 -2
  160. nuitka/tools/scanning/DisplayPackageData.py +1 -1
  161. nuitka/tools/specialize/CTypeDescriptions.py +36 -27
  162. nuitka/tools/specialize/SpecializeC.py +1 -1
  163. nuitka/tools/specialize/SpecializePython.py +16 -0
  164. nuitka/tools/testing/Common.py +3 -4
  165. nuitka/tools/testing/OutputComparison.py +23 -0
  166. nuitka/tools/testing/SearchModes.py +2 -2
  167. nuitka/tools/testing/compare_with_cpython/__main__.py +13 -4
  168. nuitka/tools/testing/measure_construct_performance/__main__.py +2 -5
  169. nuitka/tools/watch/__main__.py +194 -56
  170. nuitka/tree/Building.py +8 -2
  171. nuitka/tree/ComplexCallHelperFunctions.py +45 -15
  172. nuitka/tree/ReformulationAssignmentStatements.py +18 -12
  173. nuitka/tree/ReformulationCallExpressions.py +1 -1
  174. nuitka/tree/ReformulationClasses.py +11 -5
  175. nuitka/tree/ReformulationClasses3.py +30 -12
  176. nuitka/tree/ReformulationComparisonExpressions.py +4 -2
  177. nuitka/tree/ReformulationContractionExpressions.py +19 -11
  178. nuitka/tree/ReformulationDictionaryCreation.py +9 -3
  179. nuitka/tree/ReformulationExecStatements.py +6 -6
  180. nuitka/tree/ReformulationForLoopStatements.py +5 -5
  181. nuitka/tree/ReformulationFunctionStatements.py +6 -2
  182. nuitka/tree/ReformulationImportStatements.py +7 -2
  183. nuitka/tree/ReformulationLambdaExpressions.py +1 -1
  184. nuitka/tree/ReformulationMatchStatements.py +3 -1
  185. nuitka/tree/ReformulationNamespacePackages.py +7 -3
  186. nuitka/tree/ReformulationPrintStatements.py +1 -1
  187. nuitka/tree/ReformulationSequenceCreation.py +18 -6
  188. nuitka/tree/ReformulationWithStatements.py +8 -8
  189. nuitka/tree/ReformulationYieldExpressions.py +2 -2
  190. nuitka/tree/SourceHandling.py +27 -5
  191. nuitka/tree/VariableClosure.py +11 -1
  192. nuitka/utils/AppDirs.py +2 -2
  193. nuitka/utils/CStrings.py +39 -3
  194. nuitka/utils/CommandLineOptions.py +42 -1
  195. nuitka/utils/Distributions.py +305 -38
  196. nuitka/utils/Download.py +27 -8
  197. nuitka/utils/FileOperations.py +103 -20
  198. nuitka/utils/Hashing.py +2 -3
  199. nuitka/utils/Importing.py +60 -3
  200. nuitka/utils/InstalledPythons.py +31 -36
  201. nuitka/utils/Jinja2.py +11 -5
  202. nuitka/utils/ModuleNames.py +11 -3
  203. nuitka/utils/ReExecute.py +7 -0
  204. nuitka/utils/SharedLibraries.py +38 -14
  205. nuitka/utils/SlotMetaClasses.py +55 -0
  206. nuitka/utils/Utils.py +10 -0
  207. nuitka/utils/Yaml.py +9 -1
  208. nuitka/build/inline_copy/tqdm/tqdm/_tqdm_gui.py +0 -9
  209. nuitka/build/inline_copy/tqdm/tqdm/gui.py +0 -191
  210. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka-run.bat +0 -0
  211. {Nuitka_winsvc-1.8.6.data → Nuitka_winsvc-1.9.3.data}/scripts/nuitka.bat +0 -0
  212. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/LICENSE.txt +0 -0
  213. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/entry_points.txt +0 -0
  214. {Nuitka_winsvc-1.8.6.dist-info → Nuitka_winsvc-1.9.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,55 @@
1
+ # Copyright 2023, Kay Hayen, mailto:kay.hayen@gmail.com
2
+ #
3
+ # Part of "Nuitka", an optimizing Python compiler that is compatible and
4
+ # integrates with CPython, but also works on its own.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ """ Helper for portable metaclasses that do checks. """
19
+
20
+ from abc import ABCMeta
21
+
22
+ from nuitka.Errors import NuitkaNodeDesignError
23
+
24
+
25
+ def getMetaClassBase(meta_class_prefix, require_slots):
26
+ """For Python2/3 compatible source, we create a base class that has the metaclass
27
+ used and doesn't require making a syntax choice.
28
+
29
+ Also this allows to enforce the proper usage of "__slots__" for all classes using
30
+ it optionally.
31
+ """
32
+
33
+ class MetaClass(ABCMeta):
34
+ def __new__(
35
+ mcs, name, bases, dictionary
36
+ ): # pylint: disable=I0021,arguments-differ
37
+ if require_slots:
38
+ for base in bases:
39
+ if base is not object and "__slots__" not in base.__dict__:
40
+ raise NuitkaNodeDesignError(
41
+ name, "All bases must set __slots__.", base
42
+ )
43
+
44
+ if "__slots__" not in dictionary:
45
+ raise NuitkaNodeDesignError(name, "Class must set __slots__.", name)
46
+
47
+ return ABCMeta.__new__(mcs, name, bases, dictionary)
48
+
49
+ MetaClassBase = MetaClass(
50
+ "%sMetaClassBase" % meta_class_prefix,
51
+ (object,),
52
+ {"__slots__": ()} if require_slots else {},
53
+ )
54
+
55
+ return MetaClassBase
nuitka/utils/Utils.py CHANGED
@@ -21,12 +21,15 @@ Here the small things that fit nowhere else and don't deserve their own module.
21
21
 
22
22
  """
23
23
 
24
+ import ctypes
24
25
  import functools
25
26
  import os
26
27
  import sys
27
28
  import time
28
29
  from contextlib import contextmanager
29
30
 
31
+ from nuitka.__past__ import WindowsError # pylint: disable=I0021,redefined-builtin
32
+
30
33
 
31
34
  def getOS():
32
35
  if os.name == "nt":
@@ -389,3 +392,10 @@ Disable Anti-Virus, e.g. Windows Defender for build folders. Retrying after a se
389
392
  return retryingFunction
390
393
 
391
394
  return inner
395
+
396
+
397
+ def raiseWindowsError(message):
398
+ raise WindowsError(
399
+ ctypes.GetLastError(),
400
+ "%s (%s)" % (message, ctypes.FormatError(ctypes.GetLastError())),
401
+ )
nuitka/utils/Yaml.py CHANGED
@@ -55,6 +55,12 @@ class PackageConfigYaml(object):
55
55
  for item in data:
56
56
  module_name = item.pop("module-name")
57
57
 
58
+ if not module_name:
59
+ general.sysexit(
60
+ "Error, invalid config in '%s' looks like an empty module name was given."
61
+ % (self.name)
62
+ )
63
+
58
64
  if "/" in module_name:
59
65
  general.sysexit(
60
66
  "Error, invalid module name in '%s' looks like a file path '%s'."
@@ -107,7 +113,9 @@ def getYamlPackage():
107
113
 
108
114
  getYamlPackage.yaml = yaml
109
115
  except ImportError:
110
- getYamlPackage.yaml = importFromInlineCopy("yaml", must_exist=True)
116
+ getYamlPackage.yaml = importFromInlineCopy(
117
+ "yaml", must_exist=True, delete_module=True
118
+ )
111
119
 
112
120
  return getYamlPackage.yaml
113
121
 
@@ -1,9 +0,0 @@
1
- from warnings import warn
2
-
3
- from .gui import * # NOQA
4
- from .gui import __all__ # NOQA
5
- from .std import TqdmDeprecationWarning
6
-
7
- warn("This function will be removed in tqdm==5.0.0\n"
8
- "Please use `tqdm.gui.*` instead of `tqdm._tqdm_gui.*`",
9
- TqdmDeprecationWarning, stacklevel=2)
@@ -1,191 +0,0 @@
1
- """
2
- Matplotlib GUI progressbar decorator for iterators.
3
-
4
- Usage:
5
- >>> from tqdm.gui import trange, tqdm
6
- >>> for i in trange(10):
7
- ... ...
8
- """
9
- # future division is important to divide integers and get as
10
- # a result precise floating numbers (instead of truncated int)
11
- from __future__ import absolute_import, division
12
-
13
- import re
14
- from warnings import warn
15
-
16
- # to inherit from the tqdm class
17
- from .std import TqdmExperimentalWarning
18
- from .std import tqdm as std_tqdm
19
- # import compatibility functions and utilities
20
- from .utils import _range
21
-
22
- __author__ = {"github.com/": ["casperdcl", "lrq3000"]}
23
- __all__ = ['tqdm_gui', 'tgrange', 'tqdm', 'trange']
24
-
25
-
26
- class tqdm_gui(std_tqdm): # pragma: no cover
27
- """Experimental Matplotlib GUI version of tqdm!"""
28
- # TODO: @classmethod: write() on GUI?
29
- def __init__(self, *args, **kwargs):
30
- from collections import deque
31
-
32
- import matplotlib as mpl
33
- import matplotlib.pyplot as plt
34
- kwargs = kwargs.copy()
35
- kwargs['gui'] = True
36
- colour = kwargs.pop('colour', 'g')
37
- super(tqdm_gui, self).__init__(*args, **kwargs)
38
-
39
- if self.disable:
40
- return
41
-
42
- warn("GUI is experimental/alpha", TqdmExperimentalWarning, stacklevel=2)
43
- self.mpl = mpl
44
- self.plt = plt
45
-
46
- # Remember if external environment uses toolbars
47
- self.toolbar = self.mpl.rcParams['toolbar']
48
- self.mpl.rcParams['toolbar'] = 'None'
49
-
50
- self.mininterval = max(self.mininterval, 0.5)
51
- self.fig, ax = plt.subplots(figsize=(9, 2.2))
52
- # self.fig.subplots_adjust(bottom=0.2)
53
- total = self.__len__() # avoids TypeError on None #971
54
- if total is not None:
55
- self.xdata = []
56
- self.ydata = []
57
- self.zdata = []
58
- else:
59
- self.xdata = deque([])
60
- self.ydata = deque([])
61
- self.zdata = deque([])
62
- self.line1, = ax.plot(self.xdata, self.ydata, color='b')
63
- self.line2, = ax.plot(self.xdata, self.zdata, color='k')
64
- ax.set_ylim(0, 0.001)
65
- if total is not None:
66
- ax.set_xlim(0, 100)
67
- ax.set_xlabel("percent")
68
- self.fig.legend((self.line1, self.line2), ("cur", "est"),
69
- loc='center right')
70
- # progressbar
71
- self.hspan = plt.axhspan(0, 0.001, xmin=0, xmax=0, color=colour)
72
- else:
73
- # ax.set_xlim(-60, 0)
74
- ax.set_xlim(0, 60)
75
- ax.invert_xaxis()
76
- ax.set_xlabel("seconds")
77
- ax.legend(("cur", "est"), loc='lower left')
78
- ax.grid()
79
- # ax.set_xlabel('seconds')
80
- ax.set_ylabel((self.unit if self.unit else "it") + "/s")
81
- if self.unit_scale:
82
- plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
83
- ax.yaxis.get_offset_text().set_x(-0.15)
84
-
85
- # Remember if external environment is interactive
86
- self.wasion = plt.isinteractive()
87
- plt.ion()
88
- self.ax = ax
89
-
90
- def close(self):
91
- if self.disable:
92
- return
93
-
94
- self.disable = True
95
-
96
- with self.get_lock():
97
- self._instances.remove(self)
98
-
99
- # Restore toolbars
100
- self.mpl.rcParams['toolbar'] = self.toolbar
101
- # Return to non-interactive mode
102
- if not self.wasion:
103
- self.plt.ioff()
104
- if self.leave:
105
- self.display()
106
- else:
107
- self.plt.close(self.fig)
108
-
109
- def clear(self, *_, **__):
110
- pass
111
-
112
- def display(self, *_, **__):
113
- n = self.n
114
- cur_t = self._time()
115
- elapsed = cur_t - self.start_t
116
- delta_it = n - self.last_print_n
117
- delta_t = cur_t - self.last_print_t
118
-
119
- # Inline due to multiple calls
120
- total = self.total
121
- xdata = self.xdata
122
- ydata = self.ydata
123
- zdata = self.zdata
124
- ax = self.ax
125
- line1 = self.line1
126
- line2 = self.line2
127
- # instantaneous rate
128
- y = delta_it / delta_t
129
- # overall rate
130
- z = n / elapsed
131
- # update line data
132
- xdata.append(n * 100.0 / total if total else cur_t)
133
- ydata.append(y)
134
- zdata.append(z)
135
-
136
- # Discard old values
137
- # xmin, xmax = ax.get_xlim()
138
- # if (not total) and elapsed > xmin * 1.1:
139
- if (not total) and elapsed > 66:
140
- xdata.popleft()
141
- ydata.popleft()
142
- zdata.popleft()
143
-
144
- ymin, ymax = ax.get_ylim()
145
- if y > ymax or z > ymax:
146
- ymax = 1.1 * y
147
- ax.set_ylim(ymin, ymax)
148
- ax.figure.canvas.draw()
149
-
150
- if total:
151
- line1.set_data(xdata, ydata)
152
- line2.set_data(xdata, zdata)
153
- try:
154
- poly_lims = self.hspan.get_xy()
155
- except AttributeError:
156
- self.hspan = self.plt.axhspan(0, 0.001, xmin=0, xmax=0, color='g')
157
- poly_lims = self.hspan.get_xy()
158
- poly_lims[0, 1] = ymin
159
- poly_lims[1, 1] = ymax
160
- poly_lims[2] = [n / total, ymax]
161
- poly_lims[3] = [poly_lims[2, 0], ymin]
162
- if len(poly_lims) > 4:
163
- poly_lims[4, 1] = ymin
164
- self.hspan.set_xy(poly_lims)
165
- else:
166
- t_ago = [cur_t - i for i in xdata]
167
- line1.set_data(t_ago, ydata)
168
- line2.set_data(t_ago, zdata)
169
-
170
- d = self.format_dict
171
- # remove {bar}
172
- d['bar_format'] = (d['bar_format'] or "{l_bar}<bar/>{r_bar}").replace(
173
- "{bar}", "<bar/>")
174
- msg = self.format_meter(**d)
175
- if '<bar/>' in msg:
176
- msg = "".join(re.split(r'\|?<bar/>\|?', msg, 1))
177
- ax.set_title(msg, fontname="DejaVu Sans Mono", fontsize=11)
178
- self.plt.pause(1e-9)
179
-
180
-
181
- def tgrange(*args, **kwargs):
182
- """
183
- A shortcut for `tqdm.gui.tqdm(xrange(*args), **kwargs)`.
184
- On Python3+, `range` is used instead of `xrange`.
185
- """
186
- return tqdm_gui(_range(*args), **kwargs)
187
-
188
-
189
- # Aliases
190
- tqdm = tqdm_gui
191
- trange = tgrange