I’m not sure where I should post this, but figured I should somewhere.
First off, the project: https://github.com/uranusjr/pyem
Install it with
pipx install pyem so it is globally available. pip works fine and it has no hard dependencies right now, but pipx is still nicer. It provides one single command
pyem, that has two modes:
pyem venvmanages virtual environments in a Python project (marked by
[cmd]in the active virtual environment, or another one you specified with
Backstory: So I ran into another conversation the other day complaining how virtual environments are difficult to use for newcomers and a trouble to teach. The conversation went on to lament on
__pypackages__ should be accepted and how nice Node does it, but I started to think the complaints don’t line up with the proposed solution. It does solve the problem to a degree (like Node), but brings other problems you wouldn’t have with virtual environments.
So the problem people have the most with virtual environments is the activate/deactivate stuff. It’s easy to forget until it’s etched into your muscle memory. You can do something
./venv-3.5/bin/python but that’s even more confusing for newcomers (thosee different lib/bin/scripts paths really don’t help either).
Tools like Poetry and Pipenv also manage environments, but they make a lot of assumptions to your workflow (e.g. one env per project at a time). PyEM tries to slide into the middle. It tires to make as few assumptions as possible, but hides away the most problemetic part of virtual environments. It keeps a directory
.venvs that holds multiple virtual environments, identified by their backing interpreter (called quintuplet since the identifier has five parts). Environment addition is done by
pyem venv add/remove to save some typing from
python3.7 -m venv --prompt=$(basename $PWD) .venvs/my-venv-identifier, and the quintuplet is set up so you can identify an environment with short names.
There are a few edge cases that I hope to improve (especially how you can’t run shell builtins right now), but it’s in a good enough state to cover my own use cases. I’m interested in hearing how others might use it, and where this idea can be taken forward. I’m especially interested in the quintuplet idea (which is IMO the largest missing piece in PEP 582).