From 0e37b4547480e68c8e3edd9d0577a1a426fd13e3 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sat, 16 Jun 2018 03:37:14 -0400 Subject: [PATCH 1/3] Make `PIPENV_VIRTUALENV` global - Fixes #2273 - Hopefully for real this time Signed-off-by: Dan Ryan --- pipenv/core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 3758dfb4..67a61438 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1321,7 +1321,8 @@ def do_init( if not project.lockfile_exists and not skip_lock: # Unless we're in a virtualenv not managed by pipenv, abort if we're # using the system's python. - if (system or allow_global) and not PIPENV_VIRTUALENV: + global PIPENV_VIRTUALENV + if (system or allow_global) and not (PIPENV_VIRTUALENV): click.echo( '{0}: --system is intended to be used for Pipfile installation, ' 'not installation of specific packages. Aborting.'.format( @@ -1793,7 +1794,8 @@ def do_install( keep_outdated = project.settings.get('keep_outdated') remote = requirements and is_valid_url(requirements) # Warn and exit if --system is used without a pipfile. - if system and package_name and not PIPENV_VIRTUALENV: + global PIPENV_VIRTUALENV + if (system or allow_global) and not (PIPENV_VIRTUALENV): click.echo( '{0}: --system is intended to be used for Pipfile installation, ' 'not installation of specific packages. Aborting.'.format( From e92368e223324df29cd233982c885cba135364e2 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sat, 16 Jun 2018 13:05:58 -0400 Subject: [PATCH 2/3] Fix syntax error Signed-off-by: Dan Ryan --- pipenv/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/core.py b/pipenv/core.py index 67a61438..ad9479b4 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1795,7 +1795,7 @@ def do_install( remote = requirements and is_valid_url(requirements) # Warn and exit if --system is used without a pipfile. global PIPENV_VIRTUALENV - if (system or allow_global) and not (PIPENV_VIRTUALENV): + if system and package_name and not PIPENV_VIRTUALENV: click.echo( '{0}: --system is intended to be used for Pipfile installation, ' 'not installation of specific packages. Aborting.'.format( From c12bb6e9a67013599e32718e3efd59309c20e103 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 17 Jun 2018 03:52:22 -0400 Subject: [PATCH 3/3] Definitely fixed this time. Tested for real. Signed-off-by: Dan Ryan --- pipenv/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index ad9479b4..321ec588 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1261,6 +1261,7 @@ def do_init( pypi_mirror=None, ): """Executes the init functionality.""" + global PIPENV_VIRTUALENV if not system: if not project.virtualenv_exists: try: @@ -1292,7 +1293,7 @@ def do_init( ) requirements_dir.cleanup() sys.exit(1) - elif system or allow_global: + elif (system or allow_global) and not (PIPENV_VIRTUALENV): click.echo( crayons.red( u'Pipfile.lock ({0}) out of date, but installation ' @@ -1321,7 +1322,6 @@ def do_init( if not project.lockfile_exists and not skip_lock: # Unless we're in a virtualenv not managed by pipenv, abort if we're # using the system's python. - global PIPENV_VIRTUALENV if (system or allow_global) and not (PIPENV_VIRTUALENV): click.echo( '{0}: --system is intended to be used for Pipfile installation, '