Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/scripts/ci_loop_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse
import json

import requests
from packaging.specifiers import SpecifierSet
from packaging.version import Version


def get_versions(package: str, version_spec: str) -> list[str]:
specifier = SpecifierSet(version_spec)

url = f"https://pypi.org/pypi/{package}/json"
resp = requests.get(url, timeout=30)
resp.raise_for_status()
data = resp.json()

all_versions = data["releases"].keys()

matched = sorted(
(Version(v) for v in all_versions if Version(v) in specifier),
reverse=True,
)
return [str(v) for v in matched]


def main():
parser = argparse.ArgumentParser(description="List matching PyPI versions as JSON")
parser.add_argument("package", help="package name, e.g. setuptools")
parser.add_argument("version", help='version spec, e.g. ">=77.0.1,<83"')
args = parser.parse_args()

versions = get_versions(args.package, args.version)
print(json.dumps(versions))


if __name__ == "__main__":
main()
69 changes: 69 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test Compatibility

on:
push:
paths:
- pyproject.toml
workflow_dispatch:

permissions:
contents: read

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.parser.outputs.versions || '[]' }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2

- name: Check license line changed
id: check
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
elif git diff HEAD~1 HEAD -- pyproject.toml | grep -q '^[+-].*license = "Apache-2.0"'; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- uses: actions/setup-python@v6
if: steps.check.outputs.changed == 'true'
with:
python-version: "3.14"

- name: Generate version matrix
if: steps.check.outputs.changed == 'true'
id: parser
run: |
versions=$(python ci_loop_versions.py setuptools ">=77.0.1,<83")
echo "versions=$versions" >> "$GITHUB_OUTPUT"

check:
needs: prepare
if: needs.prepare.outputs.versions != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.prepare.outputs.versions) }}

steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
cache: pip

- name: Install package with selected setuptools
run: |
python -m pip install --upgrade pip
python -m pip install . "setuptools==${{ matrix.version }}"

- name: Show versions
run: |
python --version
python -m pip show setuptools
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


[build-system]
requires = ["setuptools>=61"]
requires = ["setuptools>=77.0.1,<83"]
build-backend = "setuptools.build_meta"

[project]
Expand Down