Home

A brief introduction to PEP 582

A few days ago I came across a new package manager for python, called pdm. I have been using poetry for about a year now and while I'm mostly happy with it hasn't been without it's problems so I'm always interested in new tools in the space. The feature of particular interest is that the pdm implements PEP 582 which is a new module resolution proposal that would negate the need for virtual environments.

This PEP proposes to add to Python a mechanism to automatically recognize a pypackages directory and prefer importing packages installed in this location over user or global site-packages.

This will avoid the steps to create, activate or deactivate "virtual environments". Python will use the pypackages from the base directory of the script when present.

Virtual environments always come up when introducing new developers to python. Coming from languages like node.js they'll inevitably ask why they have to activate their environment, can't they just run pip install like they do with npm? They'll also likely struggle to find site-packages when inspecting a dependency. I think those are reasonable questions, virtual environments feel like an implementation detail that has been unfairly exposed to the user.

While poetry and other tools have made virtual environments pleasant to work with, so much so that you might hardly even notice them. I think it would still be better to avoid them entirely.

The fact that the proposal is backwards compatible and fairly simple to implement makes it an attractive option. While it's been in the draft stage since 2018, I hope building support in tools like pdm & pyflow will give it the attention it needs to get accepted.