Skip to content

Commit 4622a0b

Browse files
authored
Fix installing dev build of pyperformance inside compile/compile_all (#232)
The compile and compile_all commands: - (a) build a fresh Python and `pip` installs `pyperformance` into it. - (b) for each benchmark, creates a virtual environment and installs `pyperformance` (and other things) into that. If hacking on a checkout of `pyperformance`, you want to make sure that it's installing from the local checkout and never from PyPI or your changes won't be in effect. There are two bugs related to this one: - pyperformance detects if it's a dev version by looking for an `pyperformance.egg-link` file in `site-packages` [1]. If that's not the case, pyperformance is installed from PyPI. In step (a), it installs the local `pyperformance` in non-editable mode, thus no `.egg-link` file, so when (b) happens, `pyperformance` is installed from PyPI. - The check for the `.egg-link` file itself is broken, but perhaps because `toml` changed from a module to a package at one point. It needs to look up a directory. [1] https://github.com/python/pyperformance/blob/main/pyperformance/__init__.py#L32
1 parent d8f76a4 commit 4622a0b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pyperformance/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def _is_venv():
3030

3131

3232
def _is_devel_install():
33-
# pip install <path-to-git-checkout> will do a "devel" install.
33+
# pip install -e <path-to-git-checkout> will do a "devel" install.
3434
# This means it creates a link back to the checkout instead
3535
# of copying the files.
3636
try:
3737
import toml
3838
except ModuleNotFoundError:
3939
return False
40-
sitepackages = os.path.dirname(toml.__file__)
40+
sitepackages = os.path.dirname(os.path.dirname(toml.__file__))
4141
if os.path.isdir(os.path.join(sitepackages, 'pyperformance')):
4242
return False
4343
if not os.path.exists(os.path.join(sitepackages, 'pyperformance.egg-link')):

pyperformance/compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def install_performance(self):
396396
cmd = [self.program, '-u', '-m', 'pip', 'install']
397397

398398
if pyperformance.is_dev():
399-
cmd.append(os.path.dirname(pyperformance.PKG_ROOT))
399+
cmd.extend(['-e', os.path.dirname(pyperformance.PKG_ROOT)])
400400
else:
401401
version = pyperformance.__version__
402402
cmd.append('pyperformance==%s' % version)

0 commit comments

Comments
 (0)