From 847c975cd10e675c85d39dabf1c05b4cbd65ea30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Wed, 30 Oct 2024 10:14:20 +0100 Subject: [PATCH] MNT: migrate requirement files to PEP 735 dependency groups --- .github/dependabot.yml | 9 ---- .github/workflows/bleeding-edge.yaml | 21 +++------ .github/workflows/ci.yml | 64 +++++++++------------------- pyproject.toml | 10 +++++ requirements/tests.txt | 3 -- requirements/typecheck.txt | 2 - 6 files changed, 37 insertions(+), 72 deletions(-) delete mode 100644 requirements/tests.txt delete mode 100644 requirements/typecheck.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4da269e..5458150 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,14 +1,5 @@ version: 2 updates: -- package-ecosystem: pip - directory: /requirements - schedule: - interval: monthly - groups: - actions: - patterns: - - '*' - - package-ecosystem: github-actions directory: /.github/workflows schedule: diff --git a/.github/workflows/bleeding-edge.yaml b/.github/workflows/bleeding-edge.yaml index f522027..15137f0 100644 --- a/.github/workflows/bleeding-edge.yaml +++ b/.github/workflows/bleeding-edge.yaml @@ -23,8 +23,6 @@ jobs: matrix: os: - ubuntu-latest - - macos-latest - # excluding windows for lack of wheels at the tim of writing runs-on: ${{ matrix.os }} name: Test nightly dependencies @@ -35,36 +33,29 @@ jobs: with: fetch-depth: 0 - - name: Set up Python Dev Version - uses: actions/setup-python@v5 - with: - python-version: 3.13-dev - uses: astral-sh/setup-uv@v3 with: enable-cache: true cache-dependency-glob: | - **/requirements/tests.txt **/pyproject.toml - name: Install dependencies run: | - uv venv + uv venv -p 3.13 uv pip install --pre --no-build numpy matplotlib \ --extra-index-url \ https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \ --index-strategy=unsafe-best-match - name: Build library - # forcing bytecode compilation for colorspacious - # see https://github.com/astral-sh/uv/issues/4758 - run: | - uv pip install . - uv pip install --compile -r requirements/tests.txt + run: uv pip install . - name: Run test suite + # forcing bytecode compilation for colorspacious + # see https://github.com/astral-sh/uv/issues/4758 run: | - source .venv/bin/activate - pytest --color yes --mpl-results-path=test_results + uv run --no-editable --compile-bytecode --group test \ + pytest --color yes --mpl-results-path=test_results - uses: actions/upload-artifact@v4 if: failure() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3156704..13d217c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,10 +31,8 @@ jobs: python-version: '3.13' - os: windows-latest python-version: '3.10' - venv-loc: Script - os: windows-latest python-version: '3.13' - venv-loc: Script - os: ubuntu-20.04 python-version: '3.10' # 2023-09-15 is numpy 1.26.0's release date @@ -48,30 +46,23 @@ jobs: with: enable-cache: true cache-dependency-glob: | - **/requirements/tests.txt **/pyproject.toml - # forcing bytecode compilation for colorspacious - # see https://github.com/astral-sh/uv/issues/4758 - - run: | - uv venv --python ${{ matrix.python-version }} - uv pip install --compile -r requirements/tests.txt ${{ matrix.install-args }} - - name: Build library - run: uv pip install . ${{ matrix.install-args }} + run: | + uv venv -p ${{ matrix.python-version }} + uv pip install . ${{ matrix.install-args }} - run: uv pip list - - name: Run test suite (UNIX) - if: matrix.os != 'windows-latest' - run: | - source .venv/bin/activate - pytest --color yes -ra - - name: Run test suite (Windows) - if: matrix.os == 'windows-latest' + - name: Run test suite + shell: bash # for windows compat + # forcing bytecode compilation for colorspacious + # see https://github.com/astral-sh/uv/issues/4758 + # run: | - .venv/Scripts/activate - pytest --color yes -ra + uv run --no-editable --compile-bytecode --group test ${{ matrix.install-args }} \ + pytest --color yes -ra - uses: actions/upload-artifact@v4 if: failure() with: @@ -83,40 +74,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.x - uses: astral-sh/setup-uv@v3 with: enable-cache: true cache-dependency-glob: | - **/requirements/tests.txt **/pyproject.toml - - name: Build library + - name: Run Image Tests # forcing bytecode compilation for colorspacious # see https://github.com/astral-sh/uv/issues/4758 run: | - uv venv - uv pip install . - uv pip install --compile -r requirements/tests.txt - - - name: Run Image Tests - run: | - source .venv/bin/activate - pytest --color=yes --mpl -m mpl_image_compare \ - --mpl-generate-summary=html \ - --mpl-results-path=pytest_mpl_results \ - --mpl-baseline-path=tests/baseline + uv run -p 3.13 --no-editable --compile-bytecode --group test \ + pytest --color=yes --mpl -m mpl_image_compare \ + --mpl-generate-summary=html \ + --mpl-results-path=pytest_mpl_results \ + --mpl-baseline-path=tests/baseline - name: Generate new image baseline if: failure() run: | - source .venv/bin/activate - pytest --color=yes --mpl -m mpl_image_compare \ - --mpl-generate-path=pytest_mpl_new_baseline \ - --last-failed + uv run --no-editable --group test \ + pytest --color=yes --mpl -m mpl_image_compare \ + --mpl-generate-path=pytest_mpl_new_baseline \ + --last-failed # always attempt to upload artifacts, even # (and especially) in case of failure. @@ -156,10 +136,8 @@ jobs: with: enable-cache: true cache-dependency-glob: | - **/requirements/typecheck.txt **/pyproject.toml - name: Run mypy run: | - uvx --python ${{ matrix.python-version }} \ - --with-requirements=requirements/typecheck.txt --with . \ + uv run -p ${{ matrix.python-version }} --no-editable --group typecheck \ mypy cmyt diff --git a/pyproject.toml b/pyproject.toml index 77d5417..855cf45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,16 @@ Homepage = "https://yt-project.org/" Source = "https://github.com/yt-project/cmyt/" Tracker = "https://github.com/yt-project/cmyt/issues" +[dependency-groups] +typecheck = [ + "mypy>=1.5.1", +] +test = [ + "colorspacious>=1.1.2", + "pytest-mpl>=0.13", + "pytest>=6.2.4", +] + [tool.ruff.lint] exclude = ["*__init__.py"] ignore = ["E501"] diff --git a/requirements/tests.txt b/requirements/tests.txt deleted file mode 100644 index becf2a5..0000000 --- a/requirements/tests.txt +++ /dev/null @@ -1,3 +0,0 @@ -pytest>=6.2.4 -pytest-mpl>=0.13 -colorspacious>=1.1.2 diff --git a/requirements/typecheck.txt b/requirements/typecheck.txt deleted file mode 100644 index 969f390..0000000 --- a/requirements/typecheck.txt +++ /dev/null @@ -1,2 +0,0 @@ -mypy==1.11.2 -matplotlib>=3.8