diff --git a/pipenv/core.py b/pipenv/core.py index 3e220df59c..586a4b48b9 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -961,17 +961,19 @@ def convert_three_to_python(three, python): return python -def _create_virtualenv_cmd(project, python, creator_venv=True, site_packages=False): +def _create_virtualenv_cmd(project, python, site_packages=False): cmd = [ Path(sys.executable).absolute().as_posix(), "-m", "virtualenv", ] - if creator_venv: - cmd.append("--creator=venv") + if project.s.PIPENV_VIRTUALENV_CREATOR: + cmd.append(f"--creator={project.s.PIPENV_VIRTUALENV_CREATOR}") cmd.append(f"--prompt={project.name}") cmd.append(f"--python={python}") cmd.append(project.get_location_for_virtualenv()) + if project.s.PIPENV_VIRTUALENV_COPIES: + cmd.append("--copies") # Pass site-packages flag to virtualenv, if desired... if site_packages: @@ -1023,13 +1025,8 @@ def do_create_virtualenv(project, python=None, site_packages=None, pypi_mirror=N with console.status( "Creating virtual environment...", spinner=project.s.PIPENV_SPINNER ): - try: - cmd = _create_virtualenv_cmd(project, python, creator_venv=True, site_packages=site_packages) - c = subprocess_run(cmd, env=pip_config) - except (ImportError, FileNotFoundError, exceptions.VirtualenvCreationException): - cmd = _create_virtualenv_cmd(project, python, creator_venv=False, site_packages=site_packages) - c = subprocess_run(cmd, env=pip_config) - + cmd = _create_virtualenv_cmd(project, python, site_packages=site_packages) + c = subprocess_run(cmd, env=pip_config) click.secho(f"{c.stdout}", fg="cyan", err=True) if c.returncode != 0: error = ( diff --git a/pipenv/environments.py b/pipenv/environments.py index b079d3902b..34bb0d160a 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -346,6 +346,16 @@ def __init__(self) -> None: ) """Tells Pipenv whether to name the venv something other than the default dir name.""" + self.PIPENV_VIRTUALENV_CREATOR = get_from_env( + "VIRTUALENV_CREATOR", check_for_negation=False + ) + """Tells Pipenv to use the virtualenv --creator= argument with the user specified value.""" + + self.PIPENV_VIRTUALENV_COPIES = get_from_env( + "VIRTUALENV_COPIES", check_for_negation=True + ) + """Tells Pipenv to use the virtualenv --copies to prevent symlinks when specified as Truthy.""" + self.PIPENV_PYUP_API_KEY = get_from_env("PYUP_API_KEY", check_for_negation=False) # Internal, support running in a different Python from sys.executable.