Suggestion to extend the vision with Volta-style shims
shamrin opened this issue · comments
Posy looks very promising, great work!
@njsmith, do you want to push the vision even further that what you have in the README? Posy could provide shims for python
/ python3
/ pip
. Like this:
$ ls -l $(which python)
/path/to/python -> /path/to/posy-shim
$ ls -l $(which pip)
/path/to/pip -> /path/to/posy-shim
In other words, do what Volta does for Node and npm.
This means the existing project workflow could be simply:
$ cd project/
$ python main.py # (if needed) installs python and deps from pyproject.toml, and then runs main.py
And the new project could be configured as follows:
$ mkdir project && cd project/
$ posy init --python 3.11.1 # pins python version in pyproject.toml
$ pip install some-dependency # installs dependency in project environment
$ editor main.py # write some code
$ python main.py # invokes main.py with pinned python and with project dependencies in scope
(Optional) Do the same with tools
$ cd project/ # project that has black version 23.1.0
$ black --version
23.1.0
$ cd another-project/ # project that has black version 22.10.0
$ black --version
22.10.0
(Volta also does it, see "Using project tools" section in "Understanding Volta" page).
oh forget to say the main point: I'm totally open to doing this if it turns out to make sense. UX is the kind of thing you have to experiment with :-)
Thank you for your reply @njsmith! Yeah, separate posy
command has its advantages: direct, short, no magic.
Another possible improvement is to provide pip
stub, to prevent xkcd Python environment mess:
$ pip
error: `pip` command disabled, use `posy install` instead
Posy does use the magic marker file that's supposed to tell pip not to mess with its environments: https://github.com/njsmith/posy/blob/cfea84949d057664e0ec1f2f88dbccc701630ce1/src/data-files/EXTERNALLY-MANAGED