Skip to content

Conversation

@bdbaddog
Copy link
Contributor

Fixed GH Issue #4809 4809. scoop.sh installed scons (and likely scons-local )created msvs project files would fail.

See #4810 for discussion.
This is the implementation of the fix discussed in that PR.

Largely the work of.
@jcbrill & @madmiraal

Note: I tested this live with the SConstruct from #4809 and scoop.sh installed scons
(And then locally editing scoop installed scons' msvs.py"

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

@bdbaddog bdbaddog requested a review from mwichmann January 18, 2026 05:08
jcbrill added a commit to jcbrill/scons that referenced this pull request Jan 20, 2026
Changes:
* Change SCons/Tool/msvs.py function comment before getExecScriptMain and replace with docstring.  Taken from PR SCons#4817.
* Revert python executable code
* Generate scons_home (user env, SCONS_HOME, or SCONS_LIB_DIR path specification) and scons_path (currently executing SCons module path) paths in unified script in SCons/Tool/msvs.py and testing/framework/TestSConsMSVS.py.  Similar to the two code paths in PR SCons#4817.
* Set the SCONS_HOME variable in the testenv as is done with SCONS_LIB_DIR.  Add SCONS_HOME to testing/framework/TestSConsMSVS.py.
@mwichmann mwichmann added the MSVC Microsoft Visual C++ Support label Jan 25, 2026


def main() -> None:
def main(script_path) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugs of omission?

SCons/SCript/Main main function now takes a required script_path argument.

Missing:

  • SCons/__main__.py needs to pass a script_path argument.
  • The bin/scons-test.py function do_nothing needs to accept a script_path argument.

I could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How'd you find those? Are we missing some tests which should catch such? (python -m scons ?)

Copy link
Contributor

@jcbrill jcbrill Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just searched the source code for combinations of Script.main (e.g. regex Script\.main\( most likely).

Potential issues:

  • The change from main() to main(script_path) can/will break user code.

    Basically anyone doing the same thing: import SCons.Script; SCons.Script.main().

  • Isn't main the entry point when building the wheel wrapper executables for Windows?

    [console_scripts]
    scons = SCons.Script.Main:main
    scons-configure-cache = SCons.Utilities.ConfigureCache:main
    sconsign = SCons.Utilities.sconsign:main
    

    I thought that the entry point was not supposed to take arguments but I certainly could be wrong. A required argument could be problematic.

  • scons.py is not the only way SCons will be called.

    For example, the zipapp (e.g., scons-local-4.10.1.pyz) will be called via __main__.py.

    However, adding os.path.abspath(__file__) will not work for the zippapp. An invocation like S:\SCons\test-4809\scons-local-4.10.1.pyz\__main__.py will fail.

    Something like os.path.dirname(os.path.abspath(__file__)) would be needed to use the name of the zipapp file itself. An invocation like S:\SCons\test-4809\scons-local-4.10.1.pyz should work.

  • Changing the default generated msvs script code path from using PYTHON_ROOT and PYTHONPATH which has allowed deferred evaluation of the location of python and SCons since version 1.0 to a hard-coded absolute path could break some user code.

    Both PYTHON_ROOT (or something similar) and PYTHONPATH were/are useful when using python and SCons from a USB stick and/or when physically moving folders between computers as it avoids hard-coded absolute paths.

    Edit: This is a different animal when actually launching the VS GUI which can be done via batch file(s) via the SCons project root to open the generated .sln in the appropriate build folder.

Don't shoot the messenger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not shooting the messenger, just wanted to see what I should have done to catch those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MSVC Microsoft Visual C++ Support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants