-
-
Notifications
You must be signed in to change notification settings - Fork 51
chore(deps): upgrade pex to latest #544
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
base: main
Are you sure you want to change the base?
Conversation
hmm @thesayyn looks like this hacky bit needs a re-hack https://github.com/aspect-build/rules_py/blob/main/py/tools/pex/main.py#L112 |
eh, i was hoping we wouldn't need to update it again. I'll TAL tomorrow |
Pex maintainer here. FWIW importing pex is absolutely unsupported. The Pex CLI will never break you but the non-existent API definitely will. If someone can give me a high-level confirmation of what you're trying to do, I can hopefully point out how you might acheive that with the CLI. |
What we were trying with that patch was to do two things. Add expanded wheels into deps here: Lines 161 to 171 in 55fd502
And set some environment variables
And append some paths to sys.path to support py_binary#imports so that relative imports work. |
|
Thanks @thesayyn. A few questions:
What is an "expanded wheel"? Just unzipped, or fully installed (unpack + spread as specified here: https://packaging.python.org/en/latest/specifications/binary-distribution-format/#details) or something else?
I think
There is no CLI option to build this into the PEX file itself like :; echo 'import os; os.environ["PEX_EXTRA_SYS_PATH"] = "foo:bar"' > preamble
:; pex cowsay -c cowsay --preamble preamble -o cowsay.pex
:; PEX_VERBOSE=1 ./cowsay.pex -t Moo!
pex: Laying out PEX zipfile /home/jsirois/dev/pex-tool/pexcz/cowsay.pex: 0.2ms
pex: Executing installed PEX for /home/jsirois/dev/pex-tool/pexcz/./cowsay.pex at /home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e
pex: Testing /home/jsirois/.pyenv/versions/3.11.11/bin/python3.11 can resolve PEX at /home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e: 2.0ms
pex: Using the current interpreter /home/jsirois/.pyenv/versions/3.11.11/bin/python3.11 since it matches constraints and PYTHONPATH is not set.
pex: Discarding site packages path: Platlib(/home/jsirois/.pyenv/versions/3.11.11/lib/python3.11/site-packages)
pex: Tainted path element: /home/jsirois/.pyenv/versions/3.11.11/lib/python3.11/site-packages
pex: Tainted path element: foo
pex: Scrubbing from user site: /home/jsirois/.local/lib/python3.11/site-packages
pex: Scrubbing from site-packages: /home/jsirois/.pyenv/versions/3.11.11/lib/python3.11/site-packages
pex: Scrubbing from site-packages: foo
pex: Scrubbing from site-packages: /home/jsirois/dev/pex-tool/pexcz/foo
pex: Adding foo:bar to sys.path
pex: New sys.path: ['/home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e/.bootstrap/pex/vendor/_vendored/attrs', '/home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e/.bootstrap', '/home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e', '/home/jsirois/.pyenv/versions/3.11.11/lib/python311.zip', '/home/jsirois/.pyenv/versions/3.11.11/lib/python3.11', '/home/jsirois/.pyenv/versions/3.11.11/lib/python3.11/lib-dynload', 'foo', 'bar']
pex: Activating PEX virtual environment from /home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e: 0.2ms
pex: Bootstrap complete, performing final sys.path modifications...
pex: PYTHONPATH contains:
pex: /home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e
pex: * /home/jsirois/.pyenv/versions/3.11.11/lib/python311.zip
pex: /home/jsirois/.pyenv/versions/3.11.11/lib/python3.11
pex: /home/jsirois/.pyenv/versions/3.11.11/lib/python3.11/lib-dynload
pex: * foo
pex: * bar
pex: /home/jsirois/.cache/pex/installed_wheels/0/274b1e6fc1b966d53976333eb90ac94cb07a450a700b455af9fbdf882244b30a/cowsay-6.1-py3-none-any.whl
pex: /home/jsirois/.cache/pex/unzipped_pexes/1/e18d55d51b2bbad12f8e13eccd0de5cb994eee1e/.bootstrap
pex: * - paths that do not exist or will be imported via zipimport
____
| Moo! |
====
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| || Note the verbose lines just above the cow that start with |
I believe it's unpack + spread. Does pex support this (I wasn't able to find out from doing reading Here's the files in cowsay packaged referenced from the examples/py_pex_binary: external/pypi_cowsay ├── bin │ └── cowsay ├── BUILD.bazel ├── cowsay-6.1-py3-none-any.whl ├── MODULE.bazel ├── MODULE.bazel.lock ├── REPO.bazel ├── rules_python_wheel_entry_point_cowsay.py ├── site-packages │ ├── __init__.py │ ├── cowsay │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── characters.py │ │ ├── main.py │ │ └── tests │ │ ├── __init__.py │ │ ├── solutions.py │ │ ├── test_api.py │ │ └── test_output.py │ └── cowsay-6.1.dist-info │ ├── entry_points.txt │ ├── INSTALLER │ ├── LICENSE.txt │ ├── METADATA │ ├── RECORD │ ├── top_level.txt │ └── WHEEL └── WORKSPACE There's a whl file in here but I believe it can't be used since there can be patches applied on top of it after unpack + spread. |
Pex internally uses unpacked + spread wheels in its cache ... which uv does too. And after reading the code a bit here, I see you're just using uv effectively via some of its crates. Right now you can build a PEX with:
You cannot build a Pex with an unpacked or unpacked + spread wheel from the CLI right now. I think this issue tracks the machinery you need: pex-tool/pex#1361 For related uv issues see:
|
@chrisirhc, @arrdem and @thesayyn Pex 2.59.0 is now available and supports a new |
Thanks @jsirois! I've got some other stuff in the ruleset to wrap up first but that sounds like a much cleaner approach to PEX building than what we currently have, especially if we can leverage the venv building machinery I've been hacking on to create the required trees at build time. |
No description provided.