Commit aab8a450 by Imaclean74 Committed by Sébastien Eustace

use symlinks in created venv by default on non-windows platforms. (#1069)

* use symlinks in created venv by default on non-windows platforms. Issue #779

* Fixed test for deployments without venv module available.
parent 08008ba4
...@@ -298,7 +298,13 @@ class Env(object): ...@@ -298,7 +298,13 @@ class Env(object):
try: try:
from venv import EnvBuilder from venv import EnvBuilder
builder = EnvBuilder(with_pip=True) # use the same defaults as python -m venv
if os.name == "nt":
use_symlinks = False
else:
use_symlinks = True
builder = EnvBuilder(with_pip=True, symlinks=use_symlinks)
build = builder.create build = builder.create
except ImportError: except ImportError:
# We fallback on virtualenv for Python 2.7 # We fallback on virtualenv for Python 2.7
......
...@@ -24,3 +24,22 @@ def test_env_get_in_project_venv(tmp_dir, environ): ...@@ -24,3 +24,22 @@ def test_env_get_in_project_venv(tmp_dir, environ):
venv = Env.get(cwd=Path(tmp_dir)) venv = Env.get(cwd=Path(tmp_dir))
assert venv.path == Path(tmp_dir) / ".venv" assert venv.path == Path(tmp_dir) / ".venv"
def test_env_has_symlinks_on_nix(tmp_dir):
venv_path = Path(tmp_dir) / "Virtual Env"
Env.build_venv(str(venv_path))
venv = VirtualEnv(venv_path)
venv_available = False
try:
from venv import EnvBuilder
venv_available = True
except ImportError:
pass
if os.name != "nt" and venv_available:
assert os.path.islink(venv.python)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment