During 2018 CPython core developer sprint, I worked on the PEP 582. The goal was to help all the newbie learners during their first day writing Python by skipping the whole complexity of virtual environments. The PEP contains a reference implementation. During the sprint itself, a few core developers did not like the idea of yet another feature focusing only on newbies. Instead, there was another discussion to create a single tool to solve all the problems in the packaging world.
Now, in 2020, we, the Python trainers, are still facing the same problem. How to explain the whole idea of virtual environments to the newbie? Should we teach the concept of the Operating system and shells and environments or teach Python?
A few nights ago, during a chat with Brett Cannon, he suggested having a single tool to do the same and see how people react.
Introducing project PEP582
PEP582 is a single file implementation of the above-mentioned idea. You can call it a stupid hack, but it works.
Installing the project and using it
First, get the latest copy of the source, and then you can install it (without
any root/administrator access) using
Python itself. If you are using Ubuntu
or Debian system, it assumes that you already have
curl https://raw.githubusercontent.com/kushaldas/pep582/master/pep582.py -o pep582.py python3 pep582.py --install Successfully installed in /home/kdas/.local/lib/python3.7/site-packages/pep582.py
After this, in any directory, if you create a
python executable will start using it. If you install any package via
it will also install in the
It does not modify the
PATH variable. If you want to install and use any
executable. This is not a replacement for virtual environments. The tool is here
to help the newbies to start programming fast. For more advanced work, they
will have to learn about virtual environments.
Oh, this works on Windows too. I never tested on Mac yet.
Please play around, and let me know any improvement you want to see. You are always welcome to open issues in the project repository.