Skip to content

Commit

Permalink
tmp: use constraint-dependencies instead
Browse files Browse the repository at this point in the history
  • Loading branch information
eginhard committed Nov 29, 2024
1 parent 53193dd commit d97170b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/add_uv_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-FileCopyrightText: Enno Hermann
#
# SPDX-License-Identifier: MIT

# /// script
# requires-python = ">=3.12"
# dependencies = [
# "tomli-w",
# ]
# ///

"""Add uv dependency constraints to the pyproject.toml file.
Usage:
$ .github/scripts/add_uv_constraints.py numpy==1.26.4 torch==2.2.2
"""

import sys
from pathlib import Path

import tomli_w
import tomllib

with Path("pyproject.toml").open("rb") as f:
toml = tomllib.load(f)

if "constraint-dependencies" not in toml["tool"]["uv"]:
toml["tool"]["uv"]["constraint-dependencies"] = []

for dep in sys.argv[1:]:
toml["tool"]["uv"]["constraint-dependencies"].append(dep)

with Path("pyproject.toml").open("wb") as f:
tomli_w.dump(toml, f)
26 changes: 12 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@ jobs:
matrix:
include:
- python-version: "3.9"
numpy-version: "--with numpy==1.21.6"
torch-version: "--with torch==1.12.1+cpu"
numpy-version: "numpy==1.21.6"
torch-version: "torch==1.12.1+cpu"
- python-version: "3.10"
numpy-version: "--with numpy==1.21.6"
torch-version: "--with torch==1.12.1+cpu"
numpy-version: "numpy==1.21.6"
torch-version: "torch==1.12.1+cpu"
- python-version: "3.11"
numpy-version: "--with numpy==1.24.4"
torch-version: "--with torch==2.1.1+cpu"
numpy-version: "numpy==1.24.4"
torch-version: "torch==2.1.1+cpu"
- python-version: "3.12"
numpy-version: "--with numpy==1.26.4"
torch-version: "--with torch==2.2.2+cpu"
numpy-version: "numpy==1.26.4"
torch-version: "torch==2.2.2+cpu"
- python-version: "3.13"
steps:
- uses: actions/checkout@v4
- name: Setup uv
uses: ./.github/actions/setup-uv
- name: Tests
run: |
uv sync
uv run -v --extra cpu \
--index https://download.pytorch.org/whl/cpu \
--index-strategy unsafe-best-match \
${{ matrix.numpy-version }} ${{ matrix.torch-version}} \
coverage run --parallel
uv run -v --python 3.12 .github/scripts/add_uv_constraints.py \
${{ matrix.numpy-version }} \
${{ matrix.torch-version }}
uv run -v --extra cpu coverage run --parallel
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
Expand Down

0 comments on commit d97170b

Please sign in to comment.