pythonloc
pythonloc copied to clipboard
How does it compare to pipenv?
Pipenv is an official tool supported by pypa And to my best understanding serves a similar idea in a different way.
Could you please describe the pros and cons of each?
@abloch i haven’t built pythonloc but here’s my POV:
Pipenv does indeed allow to have per-repository dependencies, but it still uses virtual environments under the hood and requires you to use them anyway (see pipenv shell). So it still has that kind of cognitive load and learning curve for beginners, although it is very convenient once you know how it works and how to use it IMO.
From my understanding, pypackages (of which pythonloc is an early implementation) doesn’t use virtualenvs at all — it just modifies the PATH to prefer importing from local packages instead of other ones. It’s a very intuitive workflow I think, and again simplicity and beginner-friendliness is a big pro. Even for seasoned devs, I think this would simplify greatly how we manage dependencies on a per-project basis.
One con I may see is ok isolation — it seems pypackages encourage you to use your system Python everywhere. It means you may have access to packages you haven’t installed locally (and your project doesn’t dépend to) if you don’t take enough care. Maybe there’s an option in the pypackages spec to address this that I’m not aware of.
(Disclosure: I'm a co-author of PEP 582 that this is implementing.)
Florimond's answer is basically correct. The fundamental difference is that when implemented, CPython will no longer need to rely on your terminal being configured correctly to locate your packages.
Like venv and virtualenv (and also pipenv), it basically relies on sys.path
having more entries in it when you start running. For the existing tools, you need to have configured environment variables in your terminal for this to work (which is done by a combination of activating the environment and/or launching Python via a symlink/redirector where CPython is able to figure out that it's in a venv - and believe me, this code in CPython is far messier than what PEP 582 would require!)
The other difference from pipenv (and also venv/virtualenv, depending on how you use them) is that your dependencies live in the same directory as your code. So your entire directory is totally relocatable to anywhere else on your machine or (if you're careful about native dependencies) another machine. It is the lightest-weight isolation we can do.