From cd854e627428f4b6e463a8372246f0214c34ccd5 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 10 Aug 2026 19:20:45 +0200 Subject: [PATCH] Replace tox and pip with uv tox and pip split dependency/environment management across two tools: pip installs packages, tox orchestrates per-purpose virtualenvs (quality/unit/doc) on top of it. uv replaces both with a single fast tool that handles dependency resolution/installation, Python version management, virtualenv creation, and building sdists - fewer moving parts for contributors to learn, and noticeably faster CI installs. - CI (`ci_tests.yml`): `astral-sh/setup-uv` installs uv + the matrix Python version (with built-in caching); `tox -e quality` becomes `uvx pre-commit run --all-files`; `tox -e unit` becomes `uv sync --group ci` + `uv run pytest`. The `"3.x"` matrix wildcard is replaced with an explicit `"3.14"`, since `setup-uv` needs exact versions. - Release (`deploy.yml`): `pip install setuptools wheel build && python -m build -s` becomes `uv build --sdist`. - The CI-only git dependencies previously listed in `tox.ini`'s `unit` env `deps=` (`petabtests`, `benchmark_models_petab`), plus the `tests`/`reports`/`combine`/`vis` extras, now live in a single PEP 735 `[dependency-groups]` `ci` group in `pyproject.toml` (via a self-referential `petab[tests,reports,combine,vis]` entry) - dependency-groups are excluded from built distribution metadata, so PyPI's rejection of direct/VCS references doesn't apply here. - No `uv.lock` is committed - this is a library, so CI keeps resolving against current constraints each run, matching the previous un-pinned tox/pip behavior. - Added `[tool.uv] constraint-dependencies = ["pysb>=1.17.0"]`: uv resolves one dependency graph across all declared extras, not just the ones requested for a given sync, so the unit-test job was transitively pulling in pysb via the unrelated `doc` extra and landing on 1.16.0, whose legacy build bootstrap hits a dead URL. Pinning the resolver to >=1.17.0 avoids it without changing the public `tests`/`doc` extras' declared ranges. - Removed `tox.ini` and `requirements-dev.txt` (only contained `tox>=3.26.0`). - Updated `doc/development.rst` dev-workflow commands to use `uv sync`/`uv run`/`uvx`. - Fixed `README.md`'s stated Python requirement (`>=3.11` -> `>=3.12`) to match `pyproject.toml`'s `requires-python`. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/ci_tests.yml | 35 +++++++++---------------------- .github/workflows/deploy.yml | 13 ++++-------- README.md | 2 +- doc/development.rst | 3 ++- pyproject.toml | 12 +++++++++++ requirements-dev.txt | 1 - tox.ini | 38 ---------------------------------- 7 files changed, 29 insertions(+), 75 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 tox.ini diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 2c3115bd..194088a2 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -12,47 +12,32 @@ jobs: strategy: matrix: platform: [windows-latest, macos-latest, ubuntu-latest] - python-version: ["3.12", "3.x"] + python-version: ["3.12", "3.14"] runs-on: ${{ matrix.platform }} steps: - name: Check out repository uses: actions/checkout@v7 - - name: Prepare python ${{ matrix.python-version }} - uses: actions/setup-python@v7 + - name: Install uv and python ${{ matrix.python-version }} + uses: astral-sh/setup-uv@v9.0.0 with: + enable-cache: true python-version: ${{ matrix.python-version }} - - name: Get pip cache directory - id: pip_cache_dir - run: | - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - - name: Cache - uses: actions/cache@v6 - with: - path: ${{ steps.pip_cache_dir.outputs.dir }} - key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/.ci_pip_reqs.txt') }}-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.python-version }}- - - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel - pip install -r requirements-dev.txt - - name: Quality tests - run: tox -e quality + run: uvx pre-commit run --all-files if: matrix.platform == 'ubuntu-latest' - name: Unit tests - run: tox -e unit + run: | + uv sync --group ci + uv pip install "sympy>=1.12.1" + uv run --no-sync pytest --cov=petab --cov-report=xml --cov-append --durations=10 tests - name: Coverage uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml - if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.x' + if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.14' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 71247855..46ea636b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,16 +16,11 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v7 - - name: Set up python - uses: actions/setup-python@v7 - with: - python-version: 3.x + - name: Install uv + uses: astral-sh/setup-uv@v9.0.0 - - name: Install dependencies / build sdist - run: | - python -m pip install --upgrade pip - pip install setuptools wheel build - python -m build -s + - name: Build sdist + run: uv build --sdist - name: Publish a Python distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index 7888714e..455ea046 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ and the easiest way to install it is running pip3 install petab -`petab` requires Python>=3.11. We are following +`petab` requires Python>=3.12. We are following [NumPy's Python support policy](https://numpy.org/neps/nep-0029-deprecation_policy.html). Development versions of the PEtab library can be installed using diff --git a/doc/development.rst b/doc/development.rst index 181505a9..71b44d51 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -60,7 +60,7 @@ the pre-commit hooks, run: .. code-block:: bash - pip install pre-commit + uv tool install pre-commit pre-commit install To run the pre-commit checks manually on all, not just the modified files, run: @@ -85,6 +85,7 @@ To build the documentation, run: .. code-block:: bash + uv sync --extra doc --extra vis cd doc make html # then open `build/html/index.html` in a browser diff --git a/pyproject.toml b/pyproject.toml index d6dfccc9..981839ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,6 +84,18 @@ petab_visualize = "petab.v1.visualize.cli:_petab_visualize_main" Repository = "https://github.com/PEtab-dev/libpetab-python" Documentation = "https://petab.readthedocs.io/projects/libpetab-python/" +[dependency-groups] +ci = [ + "petab[tests,reports,combine,vis]", + "petabtests @ git+https://github.com/PEtab-dev/petab_test_suite@main", + "benchmark_models_petab @ git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python", +] + +[tool.uv] +# pysb<1.17 fails to build: its legacy `ez_setup.py` bootstrap downloads +# setuptools from a defunct pypi.python.org URL. +constraint-dependencies = ["pysb>=1.17.0"] + [tool.setuptools.packages.find] include = ["petab", "petab.*"] namespaces = false diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index cd043e47..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1 +0,0 @@ -tox >= 3.26.0 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index ffeb503c..00000000 --- a/tox.ini +++ /dev/null @@ -1,38 +0,0 @@ -[tox] -envlist = quality,unit,doc -isolated_build = True - -[testenv] - -[testenv:quality] -extras = quality -commands = - pre-commit run --all-files -description = - Quality tests - -[testenv:unit] -extras = tests,reports,combine,vis -deps= - git+https://github.com/PEtab-dev/petab_test_suite@main - -e git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master\#subdirectory=src/python&egg=benchmark_models_petab - -commands = - python -m pip install sympy>=1.12.1 - python -m pytest --cov=petab --cov-report=xml --cov-append --durations=10 \ - tests -description = - Basic tests - -[testenv:doc] -description = Build the documentation -extras = doc,vis -deps= - # workaround for m2r2 issue with py3.13: No module named 'pkg_resources' - # see also: https://github.com/CrossNox/m2r2/issues/72 - setuptools -allowlist_externals = rm -commands = - rm -rf {tox_root}/doc/build - sphinx-build -W -b html . build/html -changedir = {tox_root}/doc