From 91a73e2b9155787c045bd81d011c801c8c54b7b8 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 27 Jul 2022 09:34:49 -0400 Subject: [PATCH] Handle setup.py in _pip.py --- pyperformance/_pip.py | 14 ++++++++++---- pyperformance/venv.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pyperformance/_pip.py b/pyperformance/_pip.py index 7eb10e04..59283a3b 100644 --- a/pyperformance/_pip.py +++ b/pyperformance/_pip.py @@ -149,10 +149,16 @@ def install_requirements(reqs, *extra, args = [] if upgrade: args.append('-U') # --upgrade - for reqs in [reqs, *extra]: - if os.path.isfile(reqs) and reqs.endswith('.txt'): - args.append('-r') # --requirement - args.append(reqs) + for req in [reqs, *extra]: + if os.path.isfile(req): + name = os.path.basename(req) + if name == "setup.py": + req = os.path.dirname(req) + elif name == "requirements.txt": + args.append('-r') # --requirement + else: + raise ValueError(f"pip doesn't know how to install {req}") + args.append(req) return run_pip('install', *args, **kwargs) diff --git a/pyperformance/venv.py b/pyperformance/venv.py index 074da3c0..93ae97b2 100644 --- a/pyperformance/venv.py +++ b/pyperformance/venv.py @@ -27,7 +27,7 @@ def from_benchmarks(cls, benchmarks): if bench.setup_py: # pip doesn't support installing a setup.py, # but it does support installing from the directory it is in. - self._add(os.path.dirname(bench.setup_py)) + self._add(bench.setup_py) return self def __init__(self):