Skip to content

Commit

Permalink
remove host pip cache, as it sometimes (mysql) influences builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Jul 1, 2024
1 parent d0f9953 commit 4a4a8ba
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions devscripts/validation/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
from devscripts.out import info, ok


def run(release: str, image: str, pip_cache_dir: str, extra: str = "") -> "subprocess.CompletedProcess[Any]":
def run(
release: str, image: str, extra: str = ""
) -> "subprocess.CompletedProcess[Any]":
"""Actually run a given wheel test."""
docker_pip_cache = "/tmp/cache"
wheel = f"dist/django_ca-{release}-py3-none-any.whl"
Expand All @@ -40,14 +42,12 @@ def run(release: str, image: str, pip_cache_dir: str, extra: str = "") -> "subpr
commands = [
"python -m venv /tmp/venv",
# NOTE: We require at least setuptools>=68.1 for reading package configuration from pyproject.toml
f"/tmp/venv/bin/pip install --cache-dir={docker_pip_cache} -U pip 'setuptools>=68.1'",
f"/tmp/venv/bin/pip install --cache-dir={docker_pip_cache} {wheel}",
f"/tmp/venv/bin/pip install -U pip 'setuptools>=68.1' wheel",
f"/tmp/venv/bin/pip install {wheel}",
f"/tmp/venv/bin/python {command}",
]

return utils.docker_run(
"-v",
f"{pip_cache_dir}:{docker_pip_cache}",
f"--user={os.getuid()}:{os.getgid()}",
"--rm",
image,
Expand All @@ -67,7 +67,10 @@ class Command(DevCommand):
def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)
self.pyproject_toml = read_configuration(config.ROOT_DIR / "pyproject.toml")
self.extra_choices = ["none", *list(self.pyproject_toml["project"]["optional-dependencies"])]
self.extra_choices = [
"none",
*list(self.pyproject_toml["project"]["optional-dependencies"]),
]

def add_arguments(self, parser: argparse.ArgumentParser) -> None:
parser.add_argument(
Expand All @@ -91,11 +94,6 @@ def handle(self, args: argparse.Namespace) -> None:
release = self.django_ca.__version__
client = self.docker.from_env()

# get pip cache dir in image
host_pip_cache = subprocess.run(
["pip", "cache", "dir"], check=True, capture_output=True, text=True
).stdout.strip()

python_versions = args.python
if not python_versions:
python_versions = config.PYTHON_RELEASES
Expand All @@ -120,11 +118,11 @@ def handle(self, args: argparse.Namespace) -> None:

if test_no_extras:
info("Test with no extras", indent=" ")
run(release, image.id, host_pip_cache)
run(release, image.id)

for extra in extras:
info(f"Test extra: {extra}", indent=" ")
run(release, image.id, host_pip_cache, extra=extra)
run(release, image.id, extra=extra)

time.sleep(1)
image.remove(force=True)
Expand Down

0 comments on commit 4a4a8ba

Please sign in to comment.