From 5cea8af4d075bd22a6461c72e6ebe916c3d01016 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 26 Sep 2017 12:03:16 -0400 Subject: [PATCH] safetey checks Signed-off-by: Kenneth Reitz --- pipenv/cli.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index a3c6b3c6..ae78adb2 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -48,7 +48,7 @@ from .environments import ( PIPENV_SKIP_VALIDATION, PIPENV_HIDE_EMOJIS, PIPENV_INSTALL_TIMEOUT, PYENV_INSTALLED, PIPENV_YES, PIPENV_DONT_LOAD_ENV, PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_MAX_SUBPROCESS, - PIPENV_DONT_USE_PYENV, SESSION_IS_INTERACTIVE + PIPENV_DONT_USE_PYENV, SESSION_IS_INTERACTIVE, PIPENV_USE_SYSTEM ) # Backport required for earlier versions of Python. @@ -533,6 +533,15 @@ def ensure_virtualenv(three=None, python=None, site_packages=False): python = ensure_python(three=three, python=python) # Create the virtualenv. + # Abort if --system (or running in a virtualenv). + if PIPENV_USE_SYSTEM: + click.echo( + crayons.red( + 'You are attempting to re-create a virtualenv that ' + 'Pipenv did not create. Aborting.' + ) + ) + sys.exit(1) do_create_virtualenv(python=python, site_packages=site_packages) except KeyboardInterrupt: @@ -1574,6 +1583,15 @@ def cli( # --rm was passed... elif rm: + # Abort if --system (or running in a virtualenv). + if PIPENV_USE_SYSTEM: + click.echo( + crayons.red( + 'You are attempting to remove a virtualenv that ' + 'Pipenv did not create. Aborting.' + ) + ) + sys.exit(1) if project.virtualenv_exists: loc = project.virtualenv_location click.echo(