Skip to content

Commit

Permalink
For libraries to be accessable after install, we need to instal it wi…
Browse files Browse the repository at this point in the history
…th specific pip binary, not with 'python -m pip instal...'
  • Loading branch information
mknorps committed Dec 18, 2023
1 parent 793f771 commit a926d98
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/project_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ class CachedExperimentVenv:

def venv_script_lines(self, venv_path: Path) -> List[str]:
rm_command = "rd /s /q" if platform.system() == "Windows" else "rm -rf"

pip_path = (
venv_path / "Scripts" / "pip.exe"
if platform.system() == "Windows"
else venv_path / "bin" / "pip"
)
create_empty_file = "type nul > " if platform.system() == "Windows" else "touch"
return (
[
Expand All @@ -138,7 +142,7 @@ def venv_script_lines(self, venv_path: Path) -> List[str]:
f"{sys.executable} -m pip install --upgrade pip",
]
+ [
f"{sys.executable} -m pip install "
f"{pip_path} install "
f"--no-deps {req if platform.system() == 'Windows' else shlex.quote(req)}"
for req in self.requirements
]
Expand Down Expand Up @@ -179,6 +183,7 @@ def __call__(self, cache: pytest.Cache) -> Path:
venv_dir = Path(cache.mkdir(f"fawltydeps_venv_{self.venv_hash()}"))
logger.info(f"Creating venv at {venv_dir}...")
venv_script = self.venv_script_lines(venv_dir)

subprocess.run(
" && ".join(venv_script),
check=True, # fail if any of the commands fail
Expand Down

0 comments on commit a926d98

Please sign in to comment.