pipfile icon indicating copy to clipboard operation
pipfile copied to clipboard

Specification for virtualenv's location

Open hyperknot opened this issue 7 years ago • 7 comments

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.

hyperknot avatar Oct 27 '17 22:10 hyperknot

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.

ryanhiebert avatar Oct 28 '17 19:10 ryanhiebert

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.

hyperknot avatar Oct 29 '17 10:10 hyperknot

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.

pradyunsg avatar Oct 29 '17 12:10 pradyunsg

@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.

hyperknot avatar Oct 29 '17 12:10 hyperknot

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

devkral avatar Jan 06 '18 12:01 devkral

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.

gustabot42 avatar Aug 03 '18 15:08 gustabot42

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

devkral avatar Aug 03 '18 21:08 devkral