How to deploy a command line Python script in Linux, such that it gets installed in its own virtual environment that gets sourced automatically when the script is invoked by the user?
I'd like the user to be able to:
(somehow) install git+https://....my.github.../myscriptname
which would make a new venv in some hidden folder that installs all the dependencies, and then the user can run:
~/some/folder$ myscriptname --do-stuff
from anywhere, which would automatically source the environment and run the script.
Pipenv gets close, but it seems to make a different environment depending on the folder, so if I:
$ pipenv install myscriptname
It can be run from the same dir:
$ pipenv run myscriptname
But from another folder:
~/some/folder$ pipenv run myscriptname
it triggers generation of a new empty venv where the script is not available. Also, it would be great not to have to write pipenv run
before the name of the script.
It turns out pipx
https://pypa.github.io/pipx/ does exactly what asked for!