diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 7606efea6..2c2cbc8b7 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -21,7 +21,7 @@ def get_src(path): def test_commandline_basic(tmpdir): """Simple command line usage should work and files should be generated""" - home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(str(tmpdir.join("venv"))) + home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(str(tmpdir.join("ve"))) subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, home_dir]) assert os.path.exists(home_dir) @@ -42,7 +42,7 @@ def _check_no_warnings(module): def test_commandline_explicit_interp(tmpdir): """Specifying the Python interpreter should work""" - subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, "-p", sys.executable, str(tmpdir.join("venv"))]) + subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, "-p", sys.executable, str(tmpdir.join("ve"))]) # The registry lookups to support the abbreviated "-p 3.5" form of specifying @@ -54,4 +54,4 @@ def test_commandline_explicit_interp(tmpdir): def test_commandline_abbrev_interp(tmpdir): """Specifying abbreviated forms of the Python interpreter should work""" abbrev = "{}{}.{}".format("" if sys.platform == "win32" else "python", *sys.version_info[0:2]) - subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, "-p", abbrev, str(tmpdir.join("venv"))]) + subprocess.check_call([sys.executable, VIRTUALENV_SCRIPT, "-p", abbrev, str(tmpdir.join("ve"))]) diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py index aafd76097..c4a9493b2 100644 --- a/tests/test_virtualenv.py +++ b/tests/test_virtualenv.py @@ -356,7 +356,7 @@ def test_install_python_bin(): def test_always_copy_option(): """Should be no symlinks in directory tree""" tmp_virtualenv = tempfile.mkdtemp() - ve_path = os.path.join(tmp_virtualenv, "venv") + ve_path = os.path.join(tmp_virtualenv, "ve") try: virtualenv.create_environment(ve_path, symlink=False) diff --git a/tests/test_zipapp.py b/tests/test_zipapp.py index 2a17ade45..48baf7463 100644 --- a/tests/test_zipapp.py +++ b/tests/test_zipapp.py @@ -59,7 +59,7 @@ def test_wheel_basic_invocation(call_wheel, tmp_path): def _test_basic_invocation(make_env, tmp_path): - venv = tmp_path / "venv" + venv = tmp_path / "ve" make_env(str(venv)) assert_venv_looks_good( venv, list(sys.version_info), "{}{}".format(virtualenv.EXPECTED_EXE, ".exe" if virtualenv.IS_WIN else "") @@ -83,7 +83,7 @@ def assert_venv_looks_good(venv, version_info, exe_name): def _test_invocation_dash_p(make_env, tmp_path): - venv = tmp_path / "venv" + venv = tmp_path / "ve" python = {2: _python("3"), 3: _python("2.7")}[sys.version_info[0]] make_env(str(venv), python) expected = {3: 2, 2: 3}[sys.version_info[0]] diff --git a/virtualenv.py b/virtualenv.py index 8184e8657..a05b4b362 100755 --- a/virtualenv.py +++ b/virtualenv.py @@ -1331,6 +1331,22 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy print("Please use the *system* python to run this script") return + try: + import venv + except ImportError: + venv = None + + if venv: + assert sys.version_info[0] == 3 + builder = venv.EnvBuilder(system_site_packages=site_packages, clear=clear, symlinks=False, with_pip=False) + env_dir = os.path.abspath(home_dir) + context = builder.ensure_directories(env_dir) + builder.create_configuration(context) + # TODO: For Python 3.7.2, the work of setup>python is done in setup_scripts :-() + builder.setup_python(context) + # TODO: Look at whether we need to skip setting up our site.py and distutils hacks + return context.env_exe + if clear: rm_tree(lib_dir) # FIXME: why not delete it?