Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
From William Deegan:
- Fix SCons Docbook schema to work with lxml > 5
- Update pyproject.toml to support Python 3.14 and remove restrictions on lxml version install
- MSVS: Fix msvs project file creation to work with scons-local packages, and with windows scoop.sh
package manager installed SCons. (Based on work by Joseph Brill and Marcel Admiraal)

From Mats Wichmann:
- Introduce some unit tests for the file locking utility routines
Expand Down
4 changes: 4 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ IMPROVEMENTS
an override. Also, if override dict is empty, don't even call the
Override factory function.

- MSVS: Fix msvs project file creation to work with scons-local packages, and with windows scoop.sh
package manager installed SCons. (Based on work by Joseph Brill and Marcel Admiraal)


PACKAGING
---------

Expand Down
29 changes: 19 additions & 10 deletions SCons/Tool/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,34 @@ 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):
"""
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.

:param env: Environment to operate on
:param xml: Extra XML to add to generated MSVS project file
"""
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
exec_script_main = f"import sys; sys.path = [ r'{scons_home}' ] + sys.path; import SCons.Script; SCons.Script.main()"
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()
# *** ADDED SCONS PARENT PATH ***
scons_parent = os.path.abspath(os.path.join(os.path.dirname(SCons.__file__), ".."))
# *** ADDED SCONS PARENT PATH TO END OF THE PREFIX LIST ***
exec_script_main = f"import sys; sys.path = [ r'{scons_parent}' ] + sys.path; import SCons.Script; SCons.Script.main()"
if xml:
exec_script_main = xmlify(exec_script_main)
return exec_script_main
Expand Down
5 changes: 3 additions & 2 deletions testing/framework/TestSConsMSVS.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,10 @@ def msvs_substitute(
project_guid = PROJECT_GUID

if 'SCONS_LIB_DIR' in os.environ:
exec_script_main = f"from os.path import join; import sys; sys.path = [ r'{os.environ['SCONS_LIB_DIR']}' ] + sys.path; import SCons.Script; SCons.Script.main()"
exec_script_main = f"import sys; sys.path = [ r'{os.environ['SCONS_LIB_DIR']}' ] + sys.path; import SCons.Script; SCons.Script.main()"
else:
exec_script_main = f"from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-{self.scons_version}'), join(sys.prefix, 'scons-{self.scons_version}'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()"
exec_script_main = f"import sys; sys.path = [ scons_parent ] + sys.path; import SCons.Script; SCons.Script.main()"

Comment thread
bdbaddog marked this conversation as resolved.
exec_script_main_xml = exec_script_main.replace("'", "'")

result = input.replace(r'<WORKPATH>', workpath)
Expand Down