-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Issue description
tl;dr .venv files already exist in some dev setups but when present, pipenv attempts to use that file as a directory and install a virtualenv into it.
Virtualenvwrapper has suggested for awhile to use .venv files in your project directory to hold the name of your virtualenv so that you could automatically activate virtualenvs. Spacemacs (an Emacs editor setup) also does this behavior by default.
Two problems:
- Pipenv will silently fail to create and activate a virtualenv when a
.venvfile is present. - If a
.venvfile is added to an existing pipenv project, pipenv breaks because it can't activate the virtualenv at<project_dir>/.venvignoring the place where it had already created a virtualenv.
Prior Art Links:
- Virtualenvwrapper Tips & Tricks: http://virtualenvwrapper.readthedocs.io/en/latest/tips.html
- Spacemacs Python Layer: https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Blang/python#automatic-activation-of-local-pyenv-version
- Virtualenv in git directories: https://hmarr.com/2010/jan/19/making-virtualenv-play-nice-with-git/
- Sample .bash_profile using
.venvfiles: justinabrahms/jlilly-bashy-dotfiles@04899f0#commitcomment-1526375
Expected result
At the least, Pipenv should check if .venv is a file or a directory before attempting to automatically use it as a directory and install a virtualenv into it. If it's a file, then behave as if no .venv was found at all.
Actual result
If a .venv file exists in the project directory, Pipenv will attempt to create and use a virtualenv at <project_dir>/.venv and yell at the user a bit because it's not a directory but (a) it won't actually fail and (b) it won't actually save a virtualenv anywhere.
Output:
Creating a virtualenv for this project...
Pipfile: <project_path>\Pipfile
Using <python_path> to create virtualenv...
Running virtualenv with interpreter <python_path>
ERROR: File already exists and is not a directory.
Please provide a different path or delete the file.
Virtualenv location: <project_path>\.venv
Steps to replicate
touch .venv
pipenv install
Also see output of pipenv --venv
$ pipenv --support
REDACTED
Pipenv version: '2018.7.1'
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.6.5',
'os_name': 'nt',
'platform_machine': 'AMD64',
'platform_python_implementation': 'CPython',
'platform_release': '10',
'platform_system': 'Windows',
'platform_version': '10.0.17134',
'python_full_version': '3.6.5',
'python_version': '3.6',
'sys_platform': 'win32'}
System environment variables:
ADSK_CLM_WPAD_PROXY_CHECKALIASESALLUSERSPROFILEANSICONANSICON_DEFAPPDATAARCHITECTURECHOCOLATEYINSTALLCHOCOLATEYLASTPATHUPDATECMDER_ROOTCOMMONPROGRAMFILESCOMMONPROGRAMFILES(X86)COMMONPROGRAMW6432COMPUTERNAMECOMSPECCONEMUANSICONEMUANSILOGCONEMUARGSCONEMUARGS2CONEMUBACKHWNDCONEMUBASEDIRCONEMUBASEDIRSHORTCONEMUBUILDCONEMUCFGDIRCONEMUCONFIGCONEMUDIRCONEMUDRAWHWNDCONEMUDRIVECONEMUHOOKSCONEMUHWNDCONEMUPALETTECONEMUPIDCONEMUSERVERPIDCONEMUTASKCONEMUWORKDIRCONEMUWORKDRIVEDRIVERDATAFPS_BROWSER_APP_PROFILE_STRINGFPS_BROWSER_USER_PROFILE_STRINGFSHARPINSTALLDIRGIT_INSTALL_ROOTGOPATHGOROOTGTK_BASEPATHHOMEHOMEDRIVEHOMEPATHLOCALAPPDATALOGONSERVERNUMBER_OF_PROCESSORSONEDRIVEOSPATHPATHEXTPLINK_PROTOCOLPROCESSOR_ARCHITECTUREPROCESSOR_IDENTIFIERPROCESSOR_LEVELPROCESSOR_REVISIONPROGRAMDATAPROGRAMFILESPROGRAMFILES(X86)PROGRAMW6432PROMPTPSMODULEPATHPUBLICRUBYOPTSESSIONNAMESVN_SSHSYSTEMDRIVESYSTEMROOTTEMPTERMTMPUSER-ALIASESUSERDOMAINUSERDOMAIN_ROAMINGPROFILEUSERNAMEUSERPROFILEVERBOSE-OUTPUTWINDIRWORKON_HOMEPYTHONDONTWRITEBYTECODEPIP_PYTHON_PATH
Pipenvûspecific environment variables:
Contents of Pipfile:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[scripts]
server = "python manage.py runserver"
migrate = "python manage.py migrate"
test = "python manage.py test"
[packages]
"boto3" = "==1.7"
dj-database-url = "==0.5.0"
json-logging-py = "*"
"psycopg2" = "==2.7"
pytz = "==2018.4"
requests = "==2.18.4"
Django = "==2.0.6"
django_csp = "==3.4"
"Jinja2" = "==2.10"
djangorestframework = "*"
[dev-packages]
ipython = "*"
pylint = "*"
pylint-django = "*"
pylint-plugin-utils = "*"
autoflake = "*"
importmagic = "*"
epc = "*"
[requires]
python_version = "3.6"