From c95e08a5b42c898bc02a19bd62edd207d5895298 Mon Sep 17 00:00:00 2001 From: emil Date: Tue, 23 Jun 2026 23:55:48 +0200 Subject: [PATCH] fix: pass --break-system-packages to pip in CI environments When PIP_BREAK_SYSTEM_PACKAGES=1 is set (CI), pass the flag to pip install so it can upgrade debian-installed packages like platformdirs that lack RECORD files. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .taskid | 2 +- src/devx/tools/setup.py | 7 ++++++- tests/unit/test_setup.py | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.taskid b/.taskid index 018dd5f..3d638f2 100644 --- a/.taskid +++ b/.taskid @@ -1 +1 @@ -DEVX-16 +DEVX-17 diff --git a/src/devx/tools/setup.py b/src/devx/tools/setup.py index aceb9ab..fe11708 100644 --- a/src/devx/tools/setup.py +++ b/src/devx/tools/setup.py @@ -28,7 +28,12 @@ def _run(cmd: list[str]) -> None: def _install_python_deps(bin_dir: str, extras: str = "dev") -> None: """Install the project with the specified extras in editable mode.""" pip = str(Path(bin_dir) / "pip") - _run([pip, "install", "-e", f".[{extras}]"]) + cmd = [pip, "install", "-e", f".[{extras}]"] + # In CI (system Python), --break-system-packages allows upgrading + # debian-installed packages (e.g. platformdirs) that lack RECORD files. + if os.environ.get("PIP_BREAK_SYSTEM_PACKAGES") == "1": + cmd.append("--break-system-packages") + _run(cmd) def _install_pre_commit_hooks(bin_dir: str) -> None: diff --git a/tests/unit/test_setup.py b/tests/unit/test_setup.py index 2fd529c..3f3ada6 100644 --- a/tests/unit/test_setup.py +++ b/tests/unit/test_setup.py @@ -1,5 +1,6 @@ """Unit tests for devx.tools.setup.""" +import os import subprocess from pathlib import Path from unittest.mock import MagicMock, patch @@ -47,6 +48,12 @@ class TestInstallPythonDeps: _install_python_deps(".venv/bin", "ci,lint") mock_run.assert_called_once_with([".venv/bin/pip", "install", "-e", ".[ci,lint]"]) + @patch("devx.tools.setup._run") + def test_install_with_break_system_packages(self, mock_run: MagicMock) -> None: + with patch.dict(os.environ, {"PIP_BREAK_SYSTEM_PACKAGES": "1"}): + _install_python_deps(".venv/bin", "ci") + mock_run.assert_called_once_with([".venv/bin/pip", "install", "-e", ".[ci]", "--break-system-packages"]) + class TestInstallPreCommitHooks: @patch("devx.tools.setup._run") -- 2.54.0