New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Script/Main.py so it uses importlib #3552
Conversation
instead of deprecated imp module. import site_init.py file directly for Py3 Find spec for the site file by path rather than by fiddling sys.path to restrict the search. Py3: address the problem that we might get a "site_init.py" from somewhere else in sys.path. Clean up excess indentation / try nesting; adjust comment. Signed-off-by: Mats Wichmann <mats@linux.com>
Also simplify cleanup a bit - we don't need to leave the site file open, can use a context manager to read the code and let it close there. Signed-off-by: Mats Wichmann <mats@linux.com>
SCons.Tool.DefaultToolpath.insert(0, os.path.abspath(site_tools_dir)) | ||
|
||
if not os.path.exists(site_init_file): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the impact of moving this below the site_tools_dir if above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just grouping, flow matches the reworded docstring.
@@ -62,6 +62,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER | |||
- Accommodate VS 2017 Express - it's got a more liberal license then VS | |||
Community, so some people prefer it (from 2019, no more Express) | |||
- vswhere call should also now work even if programs aren't on the C: drive. | |||
- Script/Main.py now uses importlib instead of imp module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding motivation.. imp deprecated and will be removed in Py#.#?
Are we still using imp elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to insert the word "deprecated" when you decide to push it that's fine. I don't think there's a timeline, they're still dickering about deprecation (sounds familiar!).
Deprecated since version 3.4: The imp package is pending deprecation in favor of importlib.
If you want me to update it from here I will.
Stop using the
imp
module in Main, replace withimportlib
, for "importing" the site file. It started life as a side-by-side change with a Py3 version added to the existing code, but since originally being proposed (different PR), Python 2 support is being dropped, so it has been recast with just the importlib piece.This replaces PR #3399 (see some history there if interested). It relates to Issue #3299 .
Contributor Checklist:
master/src/CHANGES.txt
directory (and read theREADME.txt
in that directory)