pypa / pipfile

Other
3.24k stars 144 forks source link

Specification for virtualenv's location #88

Open hyperknot opened 7 years ago

hyperknot commented 7 years ago

I'm contributing to add Pipfile support Sublime/Anaconda. The biggest problem right now, is to get the virtualenv's location we need to call a subprocess for pipenv --py. The only alternative would be to bundle the whole 20 MB dependency what pip installing pipenv brings.

I believe this will be the same situation in every IDE which would like to implement support for Pipfiles. If Pipfile aims to be a standard like package.json it should provide a very simple way of finding out where is the virtualenv installed. Imagine if every JS editor would need to call a subprocess just to find where are node_modules for a given project.

I think the hashing, env parsing part of pipenv could be extracted in a few dozen lines of Python. Later that reference implementation can also be ported to other languages, to support JS based editors for example.

ryanhiebert commented 7 years ago

I'd think this is something that pipenv deals with, rather than the pipfile itself. The virtualenv will likely live in different places on different machines, so it doesn't belong in the Pipfile.

hyperknot commented 7 years ago

But how would the Python community imagine wide-spread support for Pipfile if autocomplete support cannot be implemented in a wide range of editors. It really needs to be as simple as it is in the JS environment, or it'll never happen.

Do we really require a subprocess call just to get the path of a file? (which actually right now is 2 subprocess calls)? It takes a couple of seconds on an i7 Macbook Pro with PCIe SSD, and it actually blocks my editor (Sublime) while doing so.

Why not standardise the location (with ENV overrides) and the hashing algorithm in the Pipfile specs? Then there would be just a small snippet of code ported to various languages to get the venv location.

pradyunsg commented 7 years ago

it actually blocks my editor (Sublime) while doing so.

As an aside, I think you can work around that by making the calls asynchronously and caching the responses about locations.

hyperknot commented 7 years ago

@pradyunsg here is my PR for adding Pipfile support to Sublime/Anaconda: https://github.com/DamnWidget/anaconda/pull/720/files

I implemented the caching, but I'm afraid making the whole get_settings async would require rewriting the plugin in major parts.

devkral commented 6 years ago

A way to find out the virtualenvironment path would be helpful to package web applications. No need to adjust the environment. At best some command like:

from pipfile import get_venv_path print(get_venv_path()) # returns the whole path sys.path.insert(0, get_venv_path()) #can be used like this

To improve speed I would suggest a split between the files for loading from the pipfile and generating the path without

gustabot42 commented 6 years ago

We are migrating from 2.7 to 3, in other branch of the repository. It would be nice if the pipfile can handle that, becouse pipenv erase the venv each time we jump from branches.

devkral commented 6 years ago

I found a solution for pipenvs location problem:

put PIPENV_VENV_IN_PROJECT=true into environment.

then the virtual environments will appear deterministic in the .venv subfolder