-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
Distribution dependencies not showing up in packaged distribution #17353
Comments
Yeah, this does seem like the wrong behavior. To fix it, I think we need to ask what package we should be assigning the data file to in this example. For instance, should the file
|
Probably the right thing is to assume the location of the BUILD file that owns the file is the package? |
Yes, I'd agree with that assumption. I mentioned this on slack, but when we're sharing this repo, we utilize a |
Interestingly, MANIFEST.in doesn't divide files up by package, it just lists files to include. I'm not sure if setup() then deduces the packages, or if it simply ignores that aspect. |
It seems like it ignores that aspect. Personally, I'm not sure what the relevance is in associating data files with particularly packages. |
Yeah, I don't really know TBH. |
I dug into this a little further, and at least wrt to PEP-420, the behavior is correct as-is. Neither pkgutil nor importlib.resources will load the file relative to a package unless there are So I assume in your real-world use case you're loading the file some other way? I don't think we can call it package_data if it's not in a package, so we may have to add it to MANIFEST.in or something. |
Also, if I put the file in |
When we share repos internally, we're using a version control entry to grab a specific hash of our repo. So it's possible |
Yeah, from my readings, And from my experiments (just using Python, both with pkgutil and importlib.resources, entirely outside of Pants!) it looks like loading data from a package requires an So I think this is a Python wrinkle, not a Pants wrinkle... |
TBH there are so many tools and use-cases that still assume the presence of |
Yup, agreed. I think resolution of this can be as simple as agreeing this is working as expected and that it is desirable to not so silently hide that items went missing as part of the packaging. I'd like to handle that just to see the contribution process through if possible. Any thoughts on what's preferable? I'm not sure how much work it is, but I was thinking something like how other subsystems have an ignore/warn/error option. That seems like it would be useful here. |
I agree that adding a least a warning makes sense. In fact, I'm not sure why we did that skipping silently in the first place... We could, in increasing order of work do:
Maybe even just #1 seems reasonable? |
Any progress on this matter? Is there a way to include non-Python files in pants? |
Hi @matan129 , can you clarify your issue? You can include non-Python asset files in built distribution using At least, that is my understanding of re-reading the comments above. |
Yes, that is my understanding as well. The latest summary of this was to provide a better notification to the user when resources in the dependency graph did not show up in the packaged output. Currently, the behavior more silently skips over them. In my original investigation, once I moved the files to a place that was part of the package tree, my resources were included properly. |
@benjyw My bad, I didn't know that |
@benjyw, maybe this thread should be marked as closed with a comment that links to the summary? |
Closing - it looks like this works as intended, and the wrinkle is a Python issue, not a Pants issue. |
Describe the bug
A pants distribution can be constructed in such a way that
dependencies
shows relevant package data in the graph. Upon building the distribution, one will find that those data files have been (silently) omitted from the built distribution. They are left to discover these missing files likely at run time. This issue has been reproduced in https://github.com/engnatha/pants-distribution-bug. The steps to reproduce aresecret_data.txt
is a dependency with./pants dependencies --transitive //:test_distribution
./pants package //:test_distribution
unzip -l dist/test_dist-0-py3-none-any.whl
The silent dropping is coming from this line. The data file cannot be associated with a package and is dropped from
package_data
in the constructedsetup.py
. If one places a dummy file inhelloworld/
, sets up aBUILD
file, and associates that module with the distribution target, then the data file is included again. Note that the "dummy" file can't be just__init__.py
sincetailor
was not picking that up to make a newBUILD
file (though that's likely a separate issue).This does not seem to conform to pep-420 standards for namespace packages that intend to remove the need for python modules within every directory.
Pants version
2.14.0rc5 (though this was also the case on 2.13.0 and likely earlier versions)
OS
Ubuntu 20.04
Additional info
To be fair, sphinx also doesn't gracefully handle namespace packages (at least for the version we use). We have had to put
__init__.py
files around our repo to make documentation building work properly.The text was updated successfully, but these errors were encountered: