DEV Community

Ghost
Ghost

Posted on

pnpm, but for Python?

Does anything like pnpm exist for Python? I'm looking for something like virtualenv but which uses symlinks instead of installing packages in the project directory, and that re-uses a local install directory so I could theoretically bootstrap new projects without network access.

Top comments (4)

Collapse
 
rhymes profile image
rhymes

Mmm nice question.

I don't know if there's an easy way.

You could use bandersnatch to create an offline mirror of PyPI and then point pipenv to such mirror

Collapse
 
zkochan profile image
Zoltan Kochan • Edited

Could we make pnpm work for Python?

Collapse
 
allison_seboldt profile image
Allison Seboldt

It sounds like you want pip pip.pypa.io/en/stable/

Collapse
 
raulinlee profile image
Lee Raulin

Hmm... The main advantage of pnpn is that it will only ever store one copy on your hard drive for each library per version number, no matter what.

IOW, if it does not have a local copy of the version of the library you want, it downloads one and only one. Thereafter, every time you "install" that version of that library for a project, it just creates a symlink. This saves gigabytes, depending on how many projects you have.

(JS/Node doesn't have "virtual environments", but basically any time you install anything with npm without using the -g ("global") flag, it's effectively installed to a virtual environment for the project.)

As far as I know, pip doesn't do anything like that. It's just like npm--if you use a virtual env for every project, and lib-x v 1.0.3 is 5 Mb, and you install it for two projects, you now have 10 Mb less space. 3 projects, and it's 15 Mb, etc.

Of course, you could just install the lib globally, and have all your projects use that copy... Exactly like npm.