-
Notifications
You must be signed in to change notification settings - Fork 433
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
pipx as a frozen standalone binary #244
Comments
The way that the |
😆 pipsi solved this by bootstrapping itself, and pipx used to install itself this way. I didn't really see a big benefit from doing this though so I stopped doing it with pipx because it added a bunch of extra confusion to people trying to install it for the first time. At that time pipx had I think zero dependencies and now it has a couple plus several transient dependencies. @mattsb42 made a clever package on PyPI called pipipxx which does this (from its README):
Anyway, back to PyOxidizer:
This isn't a problem is it? PyOxidizer bundles the entire Python runtime, so if the PyOxidizer version of pipx is built with 3.7, the resource loader api will be available and work just fine. |
Oh btw this was discussed a little in another issue. #146 (comment) |
If there are still difficulties locating or running the pipx locates the file and reads it as a string: then runs it here with the |
FWIW, I've found that using a The original idea behind
Now, that said, It also turns out that testing things involving ephemeral venvs is hard. :) Most of my usual toolset is built around testing inside venvs, and I can't do that with [1] mattsb42-meta/pipx-in-pipx#4 |
Thanks for the write up @mattsb42! pipipxx and a PyOxidizer-pipx both seem useful to me. Agreed about the name and some UX issues during installation. I recently installed it and it looked like it failed (a bare exception and |
Yup, that was probably mattsb42-meta/pipx-in-pipx#4. It was meant to be pronounced "pipx in pipx"...thus the name "pipipxx" with "pipx" replacing the second "p" in "pipx". Unfortunately, I have to explain that to each new person I encounter, so I'm pretty sure the name was too "clever" for its own good. :/ |
I've been doing a bit of analysis of 'fat binary' tools, which can be seen at https://github.com/storyscript/community/issues/8#issuecomment-540956151 PyOxidizer is great, but any use of https://github.com/Nuitka/Nuitka/ and PyInstaller have mostly solved the Another option is to vendor everything, and I highly recommend https://github.com/dephell/dephell for doing vendoring automagically. |
@cs01 can you tag this as a good first issue for someone to dive into? I think this would solve a ton of problems. |
I would not say this to be good as the first issue as can expose quite a lot of edge cases. Though I think here we can just do zipapp, I've done something similar on virtualenv which I think we can reuse. |
Fair enough- it just seemed like a self-contained and discrete task but I of course haven't gotten my hands dirty with it yet :) Do you want to link the example you've done before? |
To be fair given we only want python3.6+ might be enough to do a https://github.com/linkedin/shiv |
I've got a version using PyOxidizer half way done.
|
IMHO that's the wrong abstraction level. PyOxidizer is meant to be a binary executable. It's not meant to create virtual environments. I'm fairly certain that creating a venv from within a pyoxidizer binary would not work. |
@gaborbernat I think you're right. PyOxidizer cannot create venvs yet. I linked several issues within indygreg/PyOxidizer#218 detailing how this might be possible in the future. In the mean time, I think the problem with zipapps is that they are still beholden to the system python installation meaning pipx will/can break when the global python is upgraded What do you think of this approach for at least macos/linux: https://www.scylladb.com/2019/02/14/the-complex-path-for-a-simple-portable-python-interpreter-or-snakes-on-a-data-plane/ I think it would be preferable to just link to a stable, globally insalled python, in the correct way such that venvs don't break for minor upgrades. But the approach in the |
pipx is based on the global python by design. Removing this would imply we ship our own python for every platform... something I'm not sure we want to get into, as seems trying to do more than we can chew. |
I played around publishing pipx to Scoop with the [Python embeddable package](The embeddable package). https://github.com/uranusjr/pipx-standalone
(Edit: I merged to 32 and 64 bit manifests.) Most things seem to work OK if I pass |
I'm a bit on the edge with this; if the user needs to pass in a python why not just ship it as to be called via that python on start? Why complicate with scoop the runtime and venv python separations? |
I would strongly prefer not depending on the packager-managed Python, since that means I’ll need to patch the pipx manifest when Python upgrades (see Homebrew’s plan to release Python 3.8; this happens every time Python releases a new version). I can help develop and maintain a recipe, but certainly don’t have the capacity to constantly follow a moving target to avoid breakage. |
I managed to workaround this problem using just pipx and venv:
|
@yajo FYI, that is almost exactly what pipx-in-pipx does for you. :) |
I've used pyinstaller in the past to package a self-contained app, which is very mature. The one thing I remember about that is you need to build on every separate platform to make the apps for those platforms. But with every major OS now available to us using GitHub Actions we should be able to automate that wholly in GitHub. |
As a simple solution, why not just ship a zipapp of pipx? I've been using a self-built zipapp for some time now and it works pretty well (the biggest issue is that I have to remember to manually update it). Even if the ultimate goal is something more sophisticated, IMO an "official" zipapp would be a useful starting point. It could be published as a github release here - there are tools (for example scoop on Windows) which make it pretty easy to track new github releases and automate upgrades. |
Potentially relevant: https://discuss.python.org/t/announce-pybi-and-posy/23021 |
|
Another new option is https://github.com/ofek/pyapp. |
pipx solves the problem of system tools depending on python installations, of which you may have one (a problem because messing with the system python is dicey), or many (a problem because you have to keep version-gardening).
Even if you're disciplined and keep as much as possible in virtualenvs, you still end up having to install one system tool outside of a virtual environment... pipx (the call is coming from inside the house!). If it would be welcome, I'm considering trying to freeze pipx into a static binary using PyOxidizer. It would then be pretty easy to deploy on different package managers etc. and generally be a "real" system tool, isolated from the system and other un-virtualenv'd pythons. Once pipx is installed, other python-based system tools are a breeze to install.
However, I suspect there might be some interaction between PyOxidizer and the bits of pipx which complain about being used in a virtualenv. I'll see what happens.
The text was updated successfully, but these errors were encountered: