From 46bf8fd81f7f171a149278b7ef7d390328251df8 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Fri, 2 Jan 2026 09:51:07 +0200 Subject: [PATCH] Use scons as the default MSVSSCONS variable --- CHANGES.txt | 3 +++ SCons/Tool/msvs.py | 37 +------------------------------------ 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 792166cf2c..4da702e18c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From John Doe: - Whatever John Doe did. + From Marcel Admiraal: + - Use scons as the default MSVSSCONS variable. + From Thaddeus Crews: - Purge vim/emac local variable bloat. - Implement type hints for Node subclasses. diff --git a/SCons/Tool/msvs.py b/SCons/Tool/msvs.py index 99737568ec..fa6f831f44 100644 --- a/SCons/Tool/msvs.py +++ b/SCons/Tool/msvs.py @@ -151,41 +151,6 @@ def msvs_parse_version(s): num, suite = version_re.match(s).groups() return float(num), suite -# This is how we re-invoke SCons from inside MSVS Project files. -# The problem is that we might have been invoked as either scons.bat -# or scons.py. If we were invoked directly as scons.py, then we could -# use sys.argv[0] to find the SCons "executable," but that doesn't work -# if we were invoked as scons.bat, which uses "python -c" to execute -# things and ends up with "-c" as sys.argv[0]. Consequently, we have -# the MSVS Project file invoke SCons the same way that scons.bat does, -# which works regardless of how we were invoked. -def getExecScriptMain(env, xml=None): - if 'SCONS_HOME' not in env: - env['SCONS_HOME'] = os.environ.get('SCONS_HOME') - scons_home = env.get('SCONS_HOME') - if not scons_home and 'SCONS_LIB_DIR' in os.environ: - scons_home = os.environ['SCONS_LIB_DIR'] - if scons_home: - exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % scons_home - else: - version = SCons.__version__ - exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%(version)s'), join(sys.prefix, 'scons-%(version)s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % locals() - if xml: - exec_script_main = xmlify(exec_script_main) - return exec_script_main - -# The string for the Python executable we tell the Project file to use -# is either sys.executable or, if an external PYTHON_ROOT environment -# variable exists, $(PYTHON)ROOT\\python.exe (generalized a little to -# pluck the actual executable name from sys.executable). -try: - python_root = os.environ['PYTHON_ROOT'] -except KeyError: - python_executable = sys.executable -else: - python_executable = os.path.join('$$(PYTHON_ROOT)', - os.path.split(sys.executable)[1]) - class Config: pass @@ -2146,7 +2111,7 @@ def generate(env) -> None: # MSVSSCONSFLAGS. This helps support consumers who use wrapper scripts to # invoke scons. if 'MSVSSCONS' not in env: - env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env)) + env['MSVSSCONS'] = 'scons' if 'MSVSSCONSFLAGS' not in env: env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}'