-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Ensure stale empty python module directories don't break the build #489
Comments
Thanks for reaching out! Do you have any simple reproducible that triggers the issue? In your use-case, are |
I would need a bit of time to confirm a reproducible on my side, but I believe it happens when files from the previous module version are removed, but not the directory tree they were in. This is a peculiarity (or shortcoming if you will) of bitbake build system used in yocto which tracks files but not directories. |
The proposed patch makes four changes:
That feels suspiciously like it's addressing four different issues. If we're going to tackle this issue, we'll want to distill the motivations for each of those changes and determine if they're appropriate and desirable in general. Before we embark on that, let's look at the issue in the title. Addressing the core issue (stale empty python metadata directories), that's been discussed already in #457, except there they're proposing to raise an error and not suppress the undesirable state. In that issue, I explain that This project does expose a I'm trying to understand better what "break the build" means. What operations are failing and how? Attempting to simulate the "empty dir" experience, I did the following: draft @ mkdir foo.dist-info
draft @ py -q
>>> import importlib.metadata
>>> dist, = importlib.metadata.distributions(path=['.'])
>>> dist.metadata
<importlib.metadata._adapters.Message object at 0x2f7e4585a10>
>>> dist.metadata.keys()
[]
>>> dist.metadata.get('Version')
>>> dist.name
>>> bool(dist.metadata)
False Oh! That last bit is interesting. Since there's no METADATA file, it seems one could readily use that as a signal to ignore that dist. e.g.
And since I should also note that this project is highly performance sensitive, so anything that adds extra stat calls during discovery is likely to be a deal-breaker unless carefully designed (but we can worry about that later after figuring out a good strategy for behavior). I'm slightly surprised that Aah. It seems that Tell me more about the breakage you observe and how your patch addresses it, and we can strategize on what to do next. |
The failures we were getting with empty directories are shown here at the top: Do they make sense to you? Can you trace to where the trouble starts? |
Yes, that helps. I know you'd referenced before and I was hoping you'd have already distilled the issue to the proximate cause in this package. I'm happy to take a look. In there, I can see that setuptools is using nspektr and importlib_metadata to validate that the declared dependencies are installed. As it works through the dependency tree, it encounters the invalid distribution and fails to validate the version when it is
So the cause is rooted in the way that Perhaps that routine should be updated to filter on only valid dists or maybe give preference to valid dists. I also note that this use of nspektr was removed in pypa/setuptools#3421 (Setuptools 63), so the bug may no longer be impacting Setuptools. Is it possible that the issue no longer affects the Yocto project because those older versions of Setuptools are no longer needed? |
That seems to be the case. I went to older yocto and the issue was easily triggered there, but it doesn't seem to be happening in recent yocto (I created lots of empty dist-info dirs in site-packages/ with various versions to be sure). So we'll drop the patch and see if this uncovers any other issues. In all likelihood it won't, but I'll report if something happens. |
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up Signed-off-by: Alexander Kanavin <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: a602e67c3a67bddb687ae56d3ab1233d787fb4e2) Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 32f27f96ad87872c483d74a767b470c6347229c5) Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 32f27f96ad87872c483d74a767b470c6347229c5) Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 32f27f96ad87872c483d74a767b470c6347229c5) Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 32f27f96ad87872c483d74a767b470c6347229c5) Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 1a4f25abf29b47949782641c68cc7d3e4136988a) Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up Signed-off-by: Alexander Kanavin <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 1a4f25abf29b47949782641c68cc7d3e4136988a) Signed-off-by: Alexander Kanavin <alexlinutronix.de> Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
python/importlib_metadata#489 Upstream discussion revealed that: - the issue was happening due to a bug in setuptools - the bug was fixed in setuptools 63 (I confirmed this: empty dist-info directories no longer seem to trigger any issues if the patch is dropped) - the patch would obscure any further issues of this kind instead of exposing them for easy fixing, so they suggest we drop it and report if anything else pops up (From OE-Core rev: 1a4f25abf29b47949782641c68cc7d3e4136988a) Signed-off-by: Alexander Kanavin <alexlinutronix.de> Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
I just discovered some build breakage in my Yocto that I bisected to this patch being removed from Yocto. The failing package is
|
I added some
And what do we see in the build tree:
A stale empty |
Yep, this is different and not involving setuptools. So we need to undo the patch removal, unless @jaraco can suggest a better option? Can you look at Ross's traceback please? |
There are still issues with importlib.metadata and empty directories, which surface when doing builds with existing build trees. I've raised this on the upstream ticket that Alex Kanavin has already filed[1] so hopefully we can have a resolution soon. This reverts commit 058c3a6. [1] python/importlib_metadata#489 (From OE-Core rev: 020c9438fa4d90824dcf7068ccf3722b3b7b8ccf) Signed-off-by: Ross Burton <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
There are still issues with importlib.metadata and empty directories, which surface when doing builds with existing build trees. I've raised this on the upstream ticket that Alex Kanavin has already filed[1] so hopefully we can have a resolution soon. This reverts commit 058c3a6e2b30103202f3995930825fc2f366274f. [1] python/importlib_metadata#489 Signed-off-by: Ross Burton <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
There are still issues with importlib.metadata and empty directories, which surface when doing builds with existing build trees. I've raised this on the upstream ticket that Alex Kanavin has already filed[1] so hopefully we can have a resolution soon. This reverts commit 058c3a6e2b30103202f3995930825fc2f366274f. [1] python/importlib_metadata#489 (From OE-Core rev: 020c9438fa4d90824dcf7068ccf3722b3b7b8ccf) Signed-off-by: Ross Burton <ross.burtonarm.com> Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
I'm now thinking for |
The latest version of importlib_metadata (8.1.0) implements the new behavior (preferring non-empty distributions). Please share feedback. Especially, let me know if it doesn't address the issue, if it introduces unexpected regressions, or if you could benefit from a backport to 7.x. |
I think the issues we're seeing are coming from the copy in cpython source tree: I'm not sure how is that synced up with this repo, but we'd appreciate the fix showing up there one way or another in both cpython master and 3.12 branches. |
I will periodically apply changes from here into CPython. Currently, the changes to importlib_metadata are slated to go into CPython 3.14 and later. Of course bugfixes can be backported, but I wasn't thinking of this change as a bugfix as much as a new feature. It changes the designed behavior from finding the first (and presumed only) dist in the filesystem to preferring ones with metadata. It's adding new behavior that adds support for previously unsupported (corrupt) environments. That really doesn't feel like a bugfix. One of the reasons I maintain the backport is to make changes like this available from the future, so users that require this behavior can adopt it now (for Python 3.8+) and then move to importlib.metadata where available. I know how icky it is to have to carry a dependency and version-switched imports, but I also want to honor the regime we've created. In light of that, would you still make the case that this is a bugfix? |
Not necessarily. I'm just trying to understand how we can test the fix, if it won't show up in either 3.12 or 3.13. We can of course not test it now, and just carry the same patch all the way to 3.14. |
If you want to test the fix earlier, you'll need to adopt |
I think we'll wait. We integrate a complete system, so patching all components to import a separate dependency instead of core python library isn't an option. |
There are still issues with importlib.metadata and empty directories, which surface when doing builds with existing build trees. I've raised this on the upstream ticket that Alex Kanavin has already filed[1] so hopefully we can have a resolution soon. This reverts commit 058c3a6e2b30103202f3995930825fc2f366274f. [1] python/importlib_metadata#489 (From OE-Core rev: 020c9438fa4d90824dcf7068ccf3722b3b7b8ccf) Signed-off-by: Ross Burton <ross.burtonarm.com> Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
There are still issues with importlib.metadata and empty directories, which surface when doing builds with existing build trees. I've raised this on the upstream ticket that Alex Kanavin has already filed[1] so hopefully we can have a resolution soon. This reverts commit 058c3a6e2b30103202f3995930825fc2f366274f. [1] python/importlib_metadata#489 (From OE-Core rev: 020c9438fa4d90824dcf7068ccf3722b3b7b8ccf) Signed-off-by: Ross Burton <ross.burtonarm.com> Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
There are still issues with importlib.metadata and empty directories, which surface when doing builds with existing build trees. I've raised this on the upstream ticket that Alex Kanavin has already filed[1] so hopefully we can have a resolution soon. This reverts commit 058c3a6e2b30103202f3995930825fc2f366274f. [1] python/importlib_metadata#489 (From OE-Core rev: 020c9438fa4d90824dcf7068ccf3722b3b7b8ccf) Signed-off-by: Ross Burton <ross.burtonarm.com> Signed-off-by: Richard Purdie <richard.purdielinuxfoundation.org>
The Yocto project has been seeing mysterious build failures that were traced down to stale empty python module directories left behind by previous module versions:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=14816
We are carrying the following patch to address the issue (it both ignores the empty directories, and looks at directories in deterministic sorted order):
We'd like to discuss with upstream if such a fix is appropriate and will be taken as a proper pull request.
This is a cross-post from python/cpython#120492
The text was updated successfully, but these errors were encountered: