Skip to content

Allow for specifying local wheels and sdists as dependencies #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyperformance/_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def install_requirements(reqs, *extra,
if upgrade:
args.append('-U') # --upgrade
for reqs in [reqs, *extra]:
if os.path.exists(reqs):
if os.path.isfile(reqs) and reqs.endswith('.txt'):
args.append('-r') # --requirement
args.append(reqs)
return run_pip('install', *args, **kwargs)
Expand Down
4 changes: 4 additions & 0 deletions pyperformance/tests/data/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[benchmarks]

name metafile
local_wheel <local>
9 changes: 9 additions & 0 deletions pyperformance/tests/data/bm_local_wheel/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "pyperformance_bm_local_wheel"
requires-python = ">=3.8"
dependencies = ["pyperf"]
urls = {repository = "https://github.com/python/pyperformance"}
version = "1.0"

[tool.pyperformance]
name = "local_wheel"
1 change: 1 addition & 0 deletions pyperformance/tests/data/bm_local_wheel/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this_is-1.0.2-py2.py3-none-any.whl#egg=this_is
19 changes: 19 additions & 0 deletions pyperformance/tests/data/bm_local_wheel/run_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
A dummy benchmark that uses a local wheel
"""

import pyperf
from this_is import en_us


def bench():
return 1.0


if __name__ == "__main__":
runner = pyperf.Runner()
runner.metadata['description'] = "A dummy benchmark that has a local wheel dependency"

args = runner.parse_args()
runner.bench_func('local_wheel', bench)

Binary file not shown.
13 changes: 13 additions & 0 deletions pyperformance/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ def test_run_and_show(self):
# XXX Capture and check the output.
self.run_module('pyperf', 'slowest', filename)

def test_run_test_benchmarks(self):
# Run the benchmarks that exist only for testing
# in pyperformance/tests/data
filename = self.resolve_tmp('bench-test.json')

self.run_pyperformance(
'run',
'--manifest', os.path.join(tests.DATA_DIR, 'MANIFEST'),
'-b', 'all',
'-o', filename,
capture=None,
)

###################################
# compile

Expand Down
6 changes: 5 additions & 1 deletion pyperformance/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def _add_from_file(self, filename):
if not os.path.exists(filename):
return
for line in _utils.iter_clean_lines(filename):
self._add(line)
fullpath = os.path.join(os.path.dirname(filename), line.strip())
if os.path.isfile(fullpath):
self._add(fullpath)
else:
self._add(line)

def _add(self, line):
self.specs.append(line)
Expand Down