Closed maxkoretskyi closed 1 month ago
You should have just tried it! This should work, ~same as Pip.
pex my-package.whl -o my-executable.pex
Does that work for you @maxkoretskyi?
thanks John! It does work 😊 just to not get embarrassed too much, I did try, just in the wrong way:
pex -f my-package.whl -o my-executable.pex
😀
Aha - ok. So, -f
/ --find-links
should also work just like Pip. It needs to be a directory containing a flat set of wheels and / or sdists.
So this-too should work[^1]:
mkdir fl-repo
ln -s ../my-package.whl fl-repo/
pex -f fl-repo my-package -o my-executable.pex
[^1]: Well, maybe work. This re-introduces the question of index precedence. Does Pip resolve from --find-links repos before PyPI? Who knows - they have never guaranteed ordering of resolution when there are multiple indexes / find-links repos in play and that ordering has in face changed over time.
Ok @maxkoretskyi - it sounds like I can close this as an answered question. Let me know though if you have more questions.
@maxkoretskyi is your package local? If so, more simply you can just:
pex . -o my-executable.pex
Here I assume you're in the project's root directory. If not pex path/to/project -o my-executable.pex
works too. Pex understands how to build your project into a wheel no matter your project's build system.
thanks, pretty much answered, just a few clarifications
pex -f fl-repo my-package -o my-executable.pex
I was trying to avoid specifying my-package
b/c I wasn't sure if pex/pip prefers index over -f
also, when I specify path to a wheel like this mydir/k-*.whl
:
pex mydir/k-*.whl -o f.pex
is the expansion supposed to work or not?
Pex understands how to build your project into a wheel no matter your project's build system.
that's a good addition, thanks! so it can do the same as python -m build
?
I was trying to avoid specifying
my-package
b/c I wasn't sure if pex/pip prefers index over-f
Yeah, you're right to be unsure: https://github.com/pex-tool/pex/issues/2567#user-content-fnref-1-c269f1869919f2e2e04982d9887dcad6
is the expansion supposed to work or not?
Well, the expansion is handled by your shell; so its up to your shell! But for bash anyway, the answer is yes. But you should try it!
that's a good addition, thanks! so it can do the same as python -m build
Yes. Just like Pip can. Pex should treat all requirements (positional arguments) on the CLI just like Pip. There is a fair bit of code and tests surrounding Pex's emulation of Pip requirement parsing:
Awesome, thanks!
But you should try it!
PS. I do try everything before asking, just probably in a different way :)
Did pex mydir/k-*.whl -o f.pex
fail?
no, it's good! once I got confirmation from you, I found where I got confused... it's probably too late here
Ok, excellent. Thanks @maxkoretskyi!
I'm trying to build a pex executable but ensure that the library is resolved from a custom index, not PyPi. One risky way to do is to switch places --index-url and
--extra-index-url
:but I'm thinking of a better way of simply using my-package.whl like I can do with
pip
in a venv:is there any way for me to do the same with pex?