-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Replace use of imp library with importlib. #3159
Conversation
we've never supported python 3.4, so please remove support code for that. |
# module's dictionary, so anything that code defines ends | ||
# up adding to that module. This is really short, but all | ||
# the error checking makes it longer. | ||
loader_details = ( |
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.
Please add a brief comment as to what this does
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.
Well, the same what the previous code ... opens module found in the particular location. See https://stackoverflow.com/a/37124336/164233
OK, I will mention it.
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.
Also, this doesn't work.
[ 106s] + python3 bootstrap.py build/scons
[ 106s] /usr/bin/python3 /home/abuild/rpmbuild/BUILD/scons-3.0.1/bootstrap/src/script/scons.py build/scons
[ 107s] *** Error loading site_init file './site_scons/site_init.py':
[ 107s] AttributeError: 'NoneType' object has no attribute 'loader':
[ 107s] File "/home/abuild/rpmbuild/BUILD/scons-3.0.1/bootstrap/src/engine/SCons/Script/Main.py", line 1401:
[ 107s] _exec_main(parser, values)
[ 107s] File "/home/abuild/rpmbuild/BUILD/scons-3.0.1/bootstrap/src/engine/SCons/Script/Main.py", line 1364:
[ 107s] _main(parser)
[ 107s] File "/home/abuild/rpmbuild/BUILD/scons-3.0.1/bootstrap/src/engine/SCons/Script/Main.py", line 991:
[ 107s] _load_all_site_scons_dirs(d.get_internal_path())
[ 107s] File "/home/abuild/rpmbuild/BUILD/scons-3.0.1/bootstrap/src/engine/SCons/Script/Main.py", line 844:
[ 107s] _load_site_scons_dir(d)
[ 107s] File "/home/abuild/rpmbuild/BUILD/scons-3.0.1/bootstrap/src/engine/SCons/Script/Main.py", line 782:
[ 107s] mod = importlib.util.module_from_spec(spec)
[ 107s] File "<frozen importlib._bootstrap>", line 580:
src/engine/SCons/Tool/__init__.py
Outdated
@@ -136,7 +137,7 @@ def _tool_module(self): | |||
sys.path = self.toolpath + sys.path | |||
# sys.stderr.write("Tool:%s\nPATH:%s\n"%(self.name,sys.path)) | |||
|
|||
if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] in (0,1,2,3,4)): |
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.
Hmm. the py3 < 3.5 code shouldn't have ever been here..
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 will gladly remove the other part of the condition, but that's what I've found in your code. Should I?
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.
Yes. No code needed to support < 3.5 in the py 3 series.
This code is left over from when I did the bulk of the port before the decision was made to only support 3.5+
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.
Well, this is primarily for Py2 code.
We are getting almost 100% passing with py3.7 without these changes? But if imp is obsolete, definitely worth moving forward! |
We had hundreds of build errors like this one. |
https://docs.python.org/3/library/imp.html … “Deprecated since version 3.4: The imp package is pending deprecation in favor of importlib.” |
We are getting almost 100% passing with py3.7 without these changes? But if imp is obsolete, definitely worth moving forward! Looks like a bunch of test broke with py3.5 and 3.6. Can you take a look and resolve? |
Could we get this merged and then fix bugs which were already there? |
No. The policy is that tests should pass before merge. It's currently breaking site_scons, which is pretty important. |
Did tests pass without applying my patch? It seems to me that most of these failed tests are not my fault. Are they? |
Yes. |
@mcepl Are you able to reproduce the test success without your pass with the various python versions? |
I don't understand. Do you want me to play manually Travis/Appveyor? What's the point? |
SCons' regression tests pass on all versions of python (except pypy) without your change. You asked if the tests passed without your changes and so I pointed you to travis-ci results which showed the failures from your changes. If you look at this run: https://travis-ci.org/SCons/scons/builds/408108763 So please resolve the failures with your changes under py3.5 and 3.6 (and likely 3.7) or we cannot accept the pull request. |
When running tests for
See full log |
We don't have a RHEL build worker at this point.
Regardless your changes cause new tests to fail on our regression machines.
Please address.
These are the newly failing tests with your changes I'm asking you to
address:
test/FindSourceFiles.py
test/packaging/guess-package-name.py
test/packaging/multiple-packages-at-once.py
test/packaging/multiple-subdirs.py
test/packaging/place-files-in-subdirectory.py
test/packaging/sandbox-test/sandbox-test.py
test/packaging/strip-install-dir.py
test/packaging/tar/bz2_packaging.py
test/packaging/tar/gz.py
test/packaging/use-builddir.py
test/packaging/zip.py
test/site_scons/basic.py
test/site_scons/site-dir.py
test/site_scons/site_init.py
Do these pass on your machine for py 2.7, 3.5, 3.6, 3.7 ?
(They pass on our test machines for 2.7, but not for the other versions)
…-Bill
On Mon, Aug 6, 2018 at 9:27 AM, Matěj Cepl ***@***.***> wrote:
SCons' regression tests pass on all versions of python (except pypy)
without your change.
When running tests for master branch on my RHEL, I get these tests
failing:
Failed the following 6 tests:
test/packaging/option--package-type.py
test/packaging/rpm/cleanup.py
test/packaging/rpm/internationalization.py
test/packaging/rpm/multipackage.py
test/packaging/rpm/package.py
test/packaging/rpm/tagging.py
See full log
<https://github.com/SCons/scons/files/2263323/scons-runtest-log.txt>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3159 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFBNC_-dJK39cTNFD-JDwEgDVHqB7Tsks5uOG6FgaJpZM4Vf8SE>
.
|
Adding comment from IRC which may shed some light on where problems occur
|
Fwiw, this issue (use of "imp") completely blows up running the testsuite with Python 3.8 (still in alpha state), which has dialed up the intensity on warnings - on a large number of tests, the deprecation warning ends up in the stderr and so expected-output matches fail. |
@@ -122,8 +121,17 @@ def Package(env, target=None, source=None, **kw): | |||
# load the needed packagers. | |||
def load_packager(type): | |||
try: | |||
file,path,desc=imp.find_module(type, __path__) | |||
return imp.load_module(type, file, path, desc) | |||
if PY2: |
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 think I have an alternate solution for this location... we just want a relative import as we're already in SCons/Tool/Packaging
. For that, the following seems to work (for 2.7 as well)
try:
return importlib.import_module("." + type, __name__)
Rebased on the top of the current |
My suggestions seem to have broken everything... odd because I thought I was running with the same things here and having it work. |
@mwichmann I really have problem here. I can do Python work pretty well (I am the lead Python maintainer for SUSE), but SCons seems to me to be so complicated I am really lost. If anybody who knows her way around SCons internals wants to take over this PR and lead it to some useable end, I would be more than happy. |
I'll do some work on it. I can't really disagree with you, it's starting to feel comfortable for me in many parts now (and others remain complete mysteries), and that's after about two years of fiddling with it on and off. I don't want to offend Bill and the original developers, but it is too complex, sigh. |
Several locations with simple usage of deprecated "imp" module changed to use "importlib". These match with work in SCons#3159, but this is not a complete implementation of SCons#3159. More regex patterns are changed to be raw strings. Some strings which did not seem appropriate to change to raw strings (e.g. contain embedded tabs, which Python should honor) had backslashes escaped to avoid accidental Python interpretation. Example: '\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />\n' Python 3.8 was Warning \M was an unknown escape. More open().write(), open().read() style usage changed to use context managers so the file is closed. WIP part: even with Python 3.7, the tests which call sconsign.py fail; oddly they do not fail without the patch to compat.py. sconsign.py does an import using imp module (which is what generates the errors) so needs to be updated anyway. It does not quite fit the "simple usage" pattern - can't do a simple relative import since sconsign is normally located elsewhere in the tree than the main scons code body. With this version of the patch, 700 tests now pass with 3.8, and Warning messages reduced to 2800 (current master has 200 pass, 9000 warns) Signed-off-by: Mats Wichmann <mats@linux.com>
Several locations with simple usage of deprecated "imp" module changed to use "importlib". These match with work in SCons#3159, but this is not a complete implementation of SCons#3159. More regex patterns are changed to be raw strings. Some strings which did not seem appropriate to change to raw strings (e.g. contain embedded tabs, which Python should honor) had backslashes escaped to avoid accidental Python interpretation. Example: '\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />\n' Python 3.8 was Warning \M was an unknown escape. More open().write(), open().read() style usage changed to use context managers so the file is closed. WIP part: even with Python 3.7, the tests which call sconsign.py fail; oddly they do not fail without the patch to compat.py. sconsign.py does an import using imp module (which is what generates the errors) so needs to be updated anyway. It does not quite fit the "simple usage" pattern - can't do a simple relative import since sconsign is normally located elsewhere in the tree than the main scons code body. With this version of the patch, 700 tests now pass with 3.8, and Warning messages reduced to 2800 (current master has 200 pass, 9000 warns) Signed-off-by: Mats Wichmann <mats@linux.com>
So as an update, some of the
|
imp library has been deprecated since 3.4 and in 3.7 it finally breaks builds. Presrving compatibility with python >= 2.7.
obsoleted by PR #3552 |
imp library has been deprecated since 3.4 and in 3.7 it finally breaks builds.
Preserving compatibility with python >= 2.7.
No functionality has been changed or added.
master/src/CHANGES.txt
directory (and read theREADME.txt
in that directory)