Skip to content
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

Merged
merged 2 commits into from Feb 19, 2020

Conversation

mwichmann
Copy link
Collaborator

@mwichmann mwichmann commented Feb 11, 2020

Stop using the imp module in Main, replace with importlib, 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:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated master/src/CHANGES.txt directory (and read the README.txt in that directory)
  • I have updated the appropriate documentation

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>
@mwichmann mwichmann changed the title New main importlib Update Script/Main.py so it uses importlib Feb 11, 2020
SCons.Tool.DefaultToolpath.insert(0, os.path.abspath(site_tools_dir))

if not os.path.exists(site_init_file):
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@mwichmann mwichmann mentioned this pull request Feb 16, 2020
@@ -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.
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@bdbaddog bdbaddog merged commit 82df077 into SCons:master Feb 19, 2020
@mwichmann mwichmann deleted the new-main-importlib branch June 8, 2020 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants