Skip to content

Commit

Permalink
Add workarounds for pypy on Debian
Browse files Browse the repository at this point in the history
Work around https://bugs.debian.org/962654 by reinstalling pip in the
virutalenv before installing dependencies for pypy or pypy3.

Work around pypa/pip#8653 by using a version
of pip prior to 20.2 for pypy.

FIXME: This may reinstall pip 0 or more times depending on the package
dependencies (e.g. for pyproject.toml build requires, tox deps, package
deps).  No config option for post-create commands.  May need to create a
tox hook package to do this properly.

Signed-off-by: Kevin Locke <[email protected]>
  • Loading branch information
kevinoid committed Oct 20, 2020
1 parent 20e3d70 commit b7057c6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tox-pip-install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
# This file is part of packagename <https://github.com/kevinoid/packagename>
# Made available under CC0 1.0 Universal, see LICENSE.txt
# Copyright 2019-2020 Kevin Locke <[email protected]>
"""
Script to reinstall pip before running `pip install`.
Workaround for https://bugs.debian.org/962654
"""

import os
import sys

# Must be invoked with pip package (optionally version-constrained) as first
# argument, install options+packages as subsequent options.
if len(sys.argv) < 3 or not sys.argv[1].startswith("pip"):
sys.stderr.write(
'Usage: ' + sys.argv[0] + ' <pip version> [options] <packages...>\n')
sys.exit(1)

# Workaround is only needed on Debian (and derivatives)
if os.path.exists('/etc/debian_version'):
pip_exit_code = os.spawnl(
os.P_WAIT,
sys.executable,
sys.executable,
'-m',
'pip',
'install',
'--force',
sys.argv[1])
if pip_exit_code != 0:
sys.exit(pip_exit_code)

os.execv(
sys.executable,
[sys.executable, '-m', 'pip', 'install'] + sys.argv[2:])
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ commands =
pyroma .
vulture --exclude */docs/*,*/tests/*,*/.tox/*,*/.venv*/* .
black --check --diff .

[testenv:pypy]
# Reinstall pip to work around https://bugs.debian.org/962654
# Use version 20.1.1 to work around https://github.com/pypa/pip/issues/8653
install_command = python tox-pip-install.py pip==20.1.1 {opts} {packages}

[testenv:pypy3]
# Reinstall pip to work around https://bugs.debian.org/962654
install_command = python tox-pip-install.py pip {opts} {packages}

0 comments on commit b7057c6

Please sign in to comment.