From 98d7982e24da00bf9d41099e07831c3909873dff Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 12 Mar 2021 12:42:55 +0100 Subject: Make recompile_requirements run on Windows (cherry picked from commit c9cb42d3cd4e1243c3cdf32e09c828088b62fce7) --- scripts/dev/recompile_requirements.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py index 1849a5218..f9a94bfe3 100644 --- a/scripts/dev/recompile_requirements.py +++ b/scripts/dev/recompile_requirements.py @@ -279,7 +279,7 @@ def run_pip(venv_dir, *args, quiet=False, **kwargs): arg_str = ' '.join(str(arg) for arg in args) utils.print_col('venv$ pip {}'.format(arg_str), 'blue') - venv_python = os.path.join(venv_dir, 'bin', 'python') + venv_python = get_venv_python(venv_dir) return subprocess.run([venv_python, '-m', 'pip'] + args, check=True, **kwargs) @@ -458,6 +458,12 @@ def get_host_python(name): return sys.executable +def get_venv_python(venv_dir): + """Get the path to Python inside a virtualenv.""" + subdir = 'Scripts' if os.name == 'nt' else 'bin' + return os.path.join(venv_dir, subdir, 'python') + + def get_outfile(name): """Get the path to the output requirements.txt file.""" if name == 'qutebrowser': @@ -510,7 +516,7 @@ def test_tox(): with tempfile.TemporaryDirectory() as tmpdir: venv_dir = os.path.join(tmpdir, 'venv') tox_workdir = os.path.join(tmpdir, 'tox-workdir') - venv_python = os.path.join(venv_dir, 'bin', 'python') + venv_python = get_venv_python(venv_dir) init_venv(host_python, venv_dir, req_path) list_proc = subprocess.run([venv_python, '-m', 'tox', '--listenvs'], check=True, -- cgit v1.2.3-54-g00ecf