You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a number of small Python scripts with third-party dependencies in my ~/bin that I'm currently using pipx run in their shebangs to run. At the moment (pipx 1.5.0), this results in their venvs being cleaned up after 14 days, resulting in time spent recreating the venvs the next time the scripts are run. Even if an option is added to keep a pipx run venv around (as suggested here), if I later decide to stop using a script, I'll have no way to delete its venv and free up space. Hence, I request that pipx gain the ability to install a single-file Python script as though it were a Python package with dependencies read from inline script metadata.
As a bonus feature, if installing from a URL pointing to a Python script is supported, this would enable highly lightweight "packaging" of scripts. Instead of having to fill out a pyproject.toml and going through all that, authors would be able to distribute single-file programs by just specifying the dependencies inline and telling their users to install with pipx.
Describe the solution you'd like
Add a pipx install-script <path> command1 that takes a path or URL to a Python file, extracts any dependency information from inline script metadata, creates a non-ephemeral virtual environment with the dependencies installed, copies the script into the venv's bin/ directory, makes the script executable, and creates a symlink to the script in $PIPX_BIN_DIR. By default, the basename of the installed script will be unchanged from the source script, but the user can pass a --name <BASENAME> option to specify a new basename (useful for getting rid of .py extensions on installation).
The venv thus created acts just like a "normal" pipx venv created by pipx install: you can get rid of it with pipx uninstall, it shows up in pipx list (albeit without any version info), you can pipx (un)inject stuff into it, you can pipx reinstall it, etc. (I'm not sure what pipx upgrade should do on such venvs; probably the same thing as pipx reinstall.)
Describe alternatives you've considered
Preparing piddling projects as proper Python packages: Too much overhead for things rarely over 150 lines
Using pipx run as a script's shebang: See above
Footnotes
This could also be implemented by extending pipx install, but for the moment I'm keeping the --name option separate from that. ↩
The text was updated successfully, but these errors were encountered:
How would this feature be useful?
I have a number of small Python scripts with third-party dependencies in my
~/bin
that I'm currently usingpipx run
in their shebangs to run. At the moment (pipx 1.5.0), this results in their venvs being cleaned up after 14 days, resulting in time spent recreating the venvs the next time the scripts are run. Even if an option is added to keep apipx run
venv around (as suggested here), if I later decide to stop using a script, I'll have no way to delete its venv and free up space. Hence, I request thatpipx
gain the ability to install a single-file Python script as though it were a Python package with dependencies read from inline script metadata.As a bonus feature, if installing from a URL pointing to a Python script is supported, this would enable highly lightweight "packaging" of scripts. Instead of having to fill out a
pyproject.toml
and going through all that, authors would be able to distribute single-file programs by just specifying the dependencies inline and telling their users to install withpipx
.Describe the solution you'd like
Add a
pipx install-script <path>
command1 that takes a path or URL to a Python file, extracts any dependency information from inline script metadata, creates a non-ephemeral virtual environment with the dependencies installed, copies the script into the venv'sbin/
directory, makes the script executable, and creates a symlink to the script in$PIPX_BIN_DIR
. By default, the basename of the installed script will be unchanged from the source script, but the user can pass a--name <BASENAME>
option to specify a new basename (useful for getting rid of.py
extensions on installation).The venv thus created acts just like a "normal"
pipx
venv created bypipx install
: you can get rid of it withpipx uninstall
, it shows up inpipx list
(albeit without any version info), you canpipx (un)inject
stuff into it, you canpipx reinstall
it, etc. (I'm not sure whatpipx upgrade
should do on such venvs; probably the same thing aspipx reinstall
.)Describe alternatives you've considered
pipx run
as a script's shebang: See aboveFootnotes
This could also be implemented by extending
pipx install
, but for the moment I'm keeping the--name
option separate from that. ↩The text was updated successfully, but these errors were encountered: