-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
bpo-34632: Add importlib.metadata #12547
bpo-34632: Add importlib.metadata #12547
Conversation
Looks now like failure is due to “test altered execution environment”. I think I saw |
I suspect here is where sys.path is modified, but it is configured for teardown... so I'm surprised that it's triggering an 'altered' state. |
Is the problem that |
It seems the cleanup isn't getting called at all. I see |
I'm able to replicate the "env changed" message locally:
|
I can see that the cleanup is happening after the "env changed" test:
|
I tried changing $ git diff
diff --git a/Lib/test/test_importlib/fixtures.py b/Lib/test/test_importlib/fixtures.py
index 737ea4be7a..d0078d913d 100644
--- a/Lib/test/test_importlib/fixtures.py
+++ b/Lib/test/test_importlib/fixtures.py
@@ -28,6 +28,7 @@ def tempdir():
try:
yield pathlib.Path(tmpdir)
finally:
+ print('removing', tmpdir)
sys.path.remove(tmpdir)
shutil.rmtree(tmpdir)
@@ -59,9 +60,11 @@ class SiteDir:
def setUp(self):
self.fixtures = ExitStack()
- self.addCleanup(self.fixtures.close)
self.site_dir = self.fixtures.enter_context(self.site_dir())
+ def tearDown(self):
+ self.fixtures.close()
+
class DistInfoPkg(SiteDir):
files = { But in that case, the result is very similar:
|
If I run the tests thus: $ git diff
diff --git a/Lib/test/test_importlib/fixtures.py b/Lib/test/test_importlib/fixtures.py
index 737ea4be7a..bd5d0e48da 100644
--- a/Lib/test/test_importlib/fixtures.py
+++ b/Lib/test/test_importlib/fixtures.py
@@ -28,7 +28,9 @@ def tempdir():
try:
yield pathlib.Path(tmpdir)
finally:
+ print('removing', tmpdir)
sys.path.remove(tmpdir)
+ print(sys.path)
shutil.rmtree(tmpdir) I can see the
|
Aha! So it seems that the path items are somehow getting added to |
In this ticket, I describe the issue and implemented the change, ported in 58533a7. |
@warsaw Tests are passing, so I think this is ready for your final review and merge. We can of course iterate over the coming weeks to refine the implementation. |
Oh - still needs:
|
@warsaw I think we're ready to accept this. Is there anything more you want to see before landing it? |
Doc/library/importlib.metadata.rst
Outdated
an iterator over instances of the ``Distribution`` abstract class. This | ||
method must have the signature:: | ||
|
||
def find_distributions(name=None, path=sys.path): |
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.
We actually changed this signature to find_distributions(name=None, path=None)
to account for changes in sys.path
after the function's definition. See this MR.
Hi @jaraco - I had just one comment about the documentation. If you can update that and resolve the conflict, I am ready to approve this PR. Thanks! |
Yes, good catch. I'm also planning to merge in the 0.14 release. I'll make sure this change happens with that as well. |
I just tagged 0.15 with this fix (without updating the changelog :( ) but I'm not sure I did that correctly. |
OOh. Got almost all |
Sigh, if only GH had "merge when CI succeeds" button. :/ I will hover over "Squash and merge" as if I was trying to get an A position on Southwest. |
This change should be mention in https://docs.python.org/dev/whatsnew/3.8.html : it's a new module, no? |
Add importlib.metadata module as forward port of the standalone importlib_metadata.
This PR is a revised submission of #9327, based on bugfixes and improvements in importlib_metadata and taken directly from this branch.
https://bugs.python.org/issue34632