generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
[Bug]: py_pex_binary-rule fails to include single-file module pypi-deps #391
Labels
bug
Something isn't working
Comments
ekfeet
changed the title
[Bug]: py_pex_binary-target fails to resolve interpreter requirements
[Bug]: py_pex_binary-rule fails to include single-module pypi-deps
Sep 10, 2024
ekfeet
changed the title
[Bug]: py_pex_binary-rule fails to include single-module pypi-deps
[Bug]: py_pex_binary-rule fails to include single-file module pypi-deps
Sep 10, 2024
I think this is similar but was going convert from zip to pex and got this:
This all works just fine outside of pex |
I got the samething happening when trying to import boto3 |
alexeagle
pushed a commit
that referenced
this issue
Oct 10, 2024
Addresses the bug in #391. Single-file modules such as `six` and `typing-extensions` does not work with the current `py_pex_binary` rule, since it's assumed that there exist a sub-directory within `site-packages` that is not dist-info. An example of what a single-file module pypi-dep looks like: ``` ls bazel-reppro_pex_err/external/rules_python~~pip~pypi_311_six/site-packages/ __init__.py six-1.16.0.dist-info six.py ``` Since `Distribution.load(..)` takes in the `site-packages` directory, we only emit this part of the path, and let `uniquify=True` handle deduplication after `_map_srcs` is applied. --- ### Changes are visible to end-users: no ### Test plan <!-- Delete any which do not apply --> - Manual testing; please provide instructions so we can reproduce: Add `six` to requirements and `"@pypi_six//:pkg"` as a dep to the py_pex_binary example; then import `six` in py_pex_binary's `say.py`. Printing the module or `cowsay.cow(f"{six}")` shows that the previous example and single-files modules now also work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
Hello,
I am trying to use the relatively new
py_pex_binary
-rule, but the generated pex fails when I try to run it. The error I get:I've seen this issue when depending on packages that depends on
six
andtyping-extensions
. The regular binary runs just fine.The .deps/ in the unzipped pex only shows isodate:
The metadata of isodate shows that six is a dependency
Any help is much appreciated!
Version
Development (host) and target OS/architectures: Debian GNU/Linux 12/x86_64
Output of
bazel --version
: bazel 7.2.0Version of the Aspect rules, or other relevant rules from your
WORKSPACE
orMODULE.bazel
file:Language(s) and/or frameworks involved:
rules_py and python
How to reproduce
My build file:
main.py:
requirements.in:
Can also see this gist for all the files and run
bazel run //:requirements.update
and thenbazel run //:main_pex
Any other information?
To me it looks like
six
is not added to runfiles nor deps because of the site-packages structure:which won't match any of the conditions in
_map_srcs
inpy/private/py_pex_binary.bzl
.typing-extensions
has the same site-packages structure. The gist above also contains a hack to remedy the problem to show where I think the issue is.The text was updated successfully, but these errors were encountered: