From 001fadd6a5e0b6ada5085b1edbcf4ed8e0dedd2d Mon Sep 17 00:00:00 2001 From: "alain.delorme" Date: Fri, 4 Aug 2023 10:20:53 +0200 Subject: [PATCH] Fix Windows Support Use python.EXE on windows. Windows doesn't accept launching subprocess.Popen with env={}; at least the PATH must be indicated. --- clonevirtualenv.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clonevirtualenv.py b/clonevirtualenv.py index 399b11d..67eff12 100755 --- a/clonevirtualenv.py +++ b/clonevirtualenv.py @@ -50,13 +50,17 @@ def _dirmatch(path, matchwith): def _virtualenv_sys(venv_path): "obtain version and path info from a virtualenv." executable = os.path.join(venv_path, env_bin_dir, 'python') + env = {} + if sys.platform == 'win32': + executable = os.path.join(venv_path, env_bin_dir, 'python.EXE') + env = { "PATH": os.environ["PATH"] } # Must use "executable" as the first argument rather than as the # keyword argument "executable" to get correct value from sys.path p = subprocess.Popen([executable, '-c', 'import sys;' 'print ("%d.%d" % (sys.version_info.major, sys.version_info.minor));' 'print ("\\n".join(sys.path));'], - env={}, + env=env, stdout=subprocess.PIPE) stdout, err = p.communicate() assert not p.returncode and stdout