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 #3399
Conversation
src/engine/SCons/Script/Main.py
Outdated
[site_dir]) | ||
if PY3: | ||
spec = importlib.util.find_spec(site_init_modname) | ||
fp = open(spec.origin, 'r') |
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.
Will would this find modules in the site_dir?
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.
existing code adds it to sys.path
above. it seems to work for the tests at least. importlib method doesn't have way to pass same arg.
b05ec41
to
993b7c7
Compare
src/engine/SCons/Script/Main.py
Outdated
# we don't want a "hit" from a mod elsewhere in sys.path | ||
save_syspath = sys.path | ||
sys.path = [sys.path[0]] | ||
spec = importlib.util.find_spec(site_init_modname) |
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.
I can do this even more simply by using importlib.spec_from_file_location
(don't have to fiddle the path while doing it) if that's preferred. Tests come out the same.
Tweaks: find spec for the site file by path rather than by fiddling sys.path to restrict the search. Rearrange a bit more and improve the comment a bit more. Signed-off-by: Mats Wichmann <mats@linux.com>
Is there still a concern about this one? |
Tweaks: find spec for the site file by path rather than by fiddling sys.path to restrict the search. Rearrange a bit more and improve the comment a bit more. Signed-off-by: Mats Wichmann <mats@linux.com>
d6ac70e
to
8cf9085
Compare
Tweaks: find spec for the site file by path rather than by fiddling sys.path to restrict the search. Rearrange a bit more and improve the comment a bit more. Signed-off-by: Mats Wichmann <mats@linux.com>
8cf9085
to
295ab2c
Compare
instead of deprecated imp module. Signed-off-by: Mats Wichmann <mats@linux.com>
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>
Tweaks: find spec for the site file by path rather than by fiddling sys.path to restrict the search. Rearrange a bit more and improve the comment a bit more. Signed-off-by: Mats Wichmann <mats@linux.com>
295ab2c
to
be90eda
Compare
Signed-off-by: Mats Wichmann <mats@linux.com>
Can you purge the non PY3 code here and update the PR? |
rebase is proving a little challenging, will come back to it in a bit. |
This is withdrawn in favor of #3552 |
instead of deprecated imp module. This approach is different than the one proposed in PR #3159. I find this more straightforward, but open to suggestions.
This is in support of issue #3299, since DeprecationWarnings are thrown.
Signed-off-by: Mats Wichmann mats@linux.com
Contributor Checklist:
master/src/CHANGES.txt
directory (and read theREADME.txt
in that directory)