Skip to content

Commit

Permalink
Add --externally-managed / --break-system-packages flag
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Mar 12, 2024
1 parent 93be1e6 commit 742c44c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ jobs:
run: echo $(which python3)

- name: "Validate global Python install"
run: python3 scripts/check_system_python.py --uv ./uv
run: python3 scripts/check_system_python.py --uv ./uv --externally-managed

system-test-macos:
needs: build-binary-macos-aarch64
Expand Down Expand Up @@ -408,7 +408,7 @@ jobs:
run: py -3.9 ./scripts/check_system_python.py --uv ./uv.exe

system-test-pyenv:
needs: build-binary-windows
needs: build-binary-linux
name: "check system | python via pyenv"
runs-on: ubuntu-latest
steps:
Expand Down
12 changes: 10 additions & 2 deletions scripts/check_system_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@

parser = argparse.ArgumentParser(description="Check a Python interpreter.")
parser.add_argument("--uv", help="Path to a uv binary.")
parser.add_argument(
"--externally-managed",
action="store_true",
help="Set if the Python installation has an EXTERNALLY-MANAGED marker.",
)
args = parser.parse_args()

uv: str = os.path.abspath(args.uv) if args.uv else "uv"
allow_externally_managed = (
["--break-system-packages"] if args.externally_managed else []
)

# Create a temporary directory.
with tempfile.TemporaryDirectory() as temp_dir:
Expand All @@ -32,7 +40,7 @@
# Install the package (`pylint`).
logging.info("Installing the package `pylint`.")
subprocess.run(
[uv, "pip", "install", "pylint", "--system"],
[uv, "pip", "install", "pylint", "--system"] + allow_externally_managed,
cwd=temp_dir,
check=True,
)
Expand All @@ -57,7 +65,7 @@
# Uninstall the package (`pylint`).
logging.info("Uninstalling the package `pylint`.")
subprocess.run(
[uv, "pip", "uninstall", "pylint", "--system"],
[uv, "pip", "uninstall", "pylint", "--system"] + allow_externally_managed,
cwd=temp_dir,
check=True,
)
Expand Down

0 comments on commit 742c44c

Please sign in to comment.