Open shamrin opened 1 year ago
Yeah, I'm aware of this style, and it's certainly possible to do. It's just that I'm not sure it will actually be a UX win? Managing tools like 'black' gets complicated b/c you somehow need the magical wrapper scripts to appear/disappear from the path depending on which directory you're in. And posy handles package installation itself, so using posy to install pip doesn't make much sense...
So your example would be just:
$ mkdir project && cd project/ $ posy init --python 3.11.1 # pins python version $ posy install some-dependency # pins some-dependency $ editor main.py # write some code $ posy main.py # invokes main.py with pinned python + dependencies in scope
(Or maybe posy run main.py
or something, exact details to be determined
:-))
On Fri, Mar 24, 2023 at 2:41 AM Alexey Shamrin @.***> wrote:
Posy looks very promising, great work!
@njsmith https://github.com/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 https://volta.sh does for Node and npm.
This means the existing project workflow could be simply:
$ cd project/ $ python main.py # (if needed) installs python and dependencies specified in pyproject.toml, and then runs the script
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 --version23.1.0
$ cd another-project/ # project that has black version 22.10.0 $ black --version22.10.0
(Volta also does it, see "Using project tools" section in "Understanding Volta" page https://docs.volta.sh/guide/understanding).
— Reply to this email directly, view it on GitHub https://github.com/njsmith/posy/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEU42C4OSLC32RKXWLHQ5LW5VT2TANCNFSM6AAAAAAWGKHHN4 . You are receiving this because you were mentioned.Message ID: @.***>
-- Nathaniel J. Smith -- https://vorpus.org http://vorpus.org
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
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:In other words, do what Volta does for Node and npm.
This means the existing project workflow could be simply:
And the new project could be configured as follows:
(Optional) Do the same with tools
(Volta also does it, see "Using project tools" section in "Understanding Volta" page).