From c656c0b2885768fdf8e4d3415d94881321babf40 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 15 Sep 2022 08:35:30 +0300 Subject: Remove unused private method SConsEnvironment._exceeds_version() --- CHANGES.txt | 1 + SCons/Script/SConscript.py | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1925495..ed5fcbf 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Anatoli Babenia: - Do not initialize DefaultEnvironment when calling EnsureSConsVersion() and EnsurePythonVersion(). + - Remove unused private method SConsEnvironment._exceeds_version(). From William Deegan: - Added ValidateOptions() which will check that all command line options are in either diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index 2b11e2f..d340a91 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -385,11 +385,6 @@ class SConsEnvironment(SCons.Environment.Base): # # Private methods of an SConsEnvironment. # - def _exceeds_version(self, major, minor, v_major, v_minor): - """Return 1 if 'major' and 'minor' are greater than the version - in 'v_major' and 'v_minor', and 0 otherwise.""" - return (major > v_major or (major == v_major and minor > v_minor)) - @staticmethod def _get_major_minor_revision(version_string): """Split a version string into major, minor and (optionally) -- cgit v0.12 From 402073f4b8a4c455564862c175176b05b887b3b4 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 15 Sep 2022 08:37:35 +0300 Subject: Do not initialize DefaultEnvironment on Exit(), GetLaunchDir() and SConscriptChdir() --- CHANGES.txt | 4 ++-- SCons/Script/SConscript.py | 9 ++++++--- SCons/Script/__init__.py | 11 +++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ed5fcbf..bba6e10 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,8 +10,8 @@ NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer suppo RELEASE VERSION/DATE TO BE FILLED IN LATER From Anatoli Babenia: - - Do not initialize DefaultEnvironment when calling EnsureSConsVersion() and - EnsurePythonVersion(). + - Do not initialize DefaultEnvironment when calling EnsureSConsVersion(), + EnsurePythonVersion(), Exit(), GetLaunchDir() and SConscriptChdir(). - Remove unused private method SConsEnvironment._exceeds_version(). From William Deegan: diff --git a/SCons/Script/SConscript.py b/SCons/Script/SConscript.py index d340a91..b72f30e 100644 --- a/SCons/Script/SConscript.py +++ b/SCons/Script/SConscript.py @@ -510,7 +510,8 @@ class SConsEnvironment(SCons.Environment.Base): print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v)) sys.exit(2) - def Exit(self, value=0): + @staticmethod + def Exit(value=0): sys.exit(value) def Export(self, *vars, **kw): @@ -518,7 +519,8 @@ class SConsEnvironment(SCons.Environment.Base): global_exports.update(compute_exports(self.Split(var))) global_exports.update(kw) - def GetLaunchDir(self): + @staticmethod + def GetLaunchDir(): global launch_dir return launch_dir @@ -595,7 +597,8 @@ class SConsEnvironment(SCons.Environment.Base): subst_kw['exports'] = exports return _SConscript(self.fs, *files, **subst_kw) - def SConscriptChdir(self, flag: bool) -> None: + @staticmethod + def SConscriptChdir(flag: bool) -> None: global sconscript_chdir sconscript_chdir = flag diff --git a/SCons/Script/__init__.py b/SCons/Script/__init__.py index 0250bd1..6cfea1b 100644 --- a/SCons/Script/__init__.py +++ b/SCons/Script/__init__.py @@ -289,22 +289,23 @@ def Variables(files=None, args=ARGUMENTS): # Adding global functions to the SConscript name space. # -# Static functions that do not use state in DefaultEnvironment(). +# Static functions that do not trigger initialization of +# DefaultEnvironment() and don't use its state. EnsureSConsVersion = _SConscript.SConsEnvironment.EnsureSConsVersion EnsurePythonVersion = _SConscript.SConsEnvironment.EnsurePythonVersion +Exit = _SConscript.SConsEnvironment.Exit +GetLaunchDir = _SConscript.SConsEnvironment.GetLaunchDir +SConscriptChdir = _SConscript.SConsEnvironment.SConscriptChdir # Functions that end up calling methods or Builders in the # DefaultEnvironment(). GlobalDefaultEnvironmentFunctions = [ # Methods from the SConsEnvironment class, above. 'Default', - 'Exit', 'Export', - 'GetLaunchDir', 'Help', 'Import', #'SConscript', is handled separately, below. - 'SConscriptChdir', # Methods from the Environment.Base class. 'AddPostAction', @@ -378,6 +379,8 @@ GlobalDefaultBuilders = [ 'Package', ] +# DefaultEnvironmentCall() initializes DefaultEnvironment() if it is not +# created yet. for name in GlobalDefaultEnvironmentFunctions + GlobalDefaultBuilders: exec ("%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name))) del name -- cgit v0.12