Skip to content

Commit eff6b4a

Browse files
committed
TST: replace pip with uv in CI
1 parent e962538 commit eff6b4a

File tree

5 files changed

+66
-76
lines changed

5 files changed

+66
-76
lines changed

.github/workflows/bleeding-edge.yaml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ name: CI (bleeding edge)
55
# goals: check stability against
66
# - dev version of Python, numpy, matplotlib, and unyt
77
# - Cython and pytest pre-releases
8-
# - building with future pip default options
98

109
on:
1110
push:
@@ -35,36 +34,38 @@ jobs:
3534
uses: actions/checkout@v5
3635

3736
- name: Set up Python (newest testable version)
38-
uses: actions/setup-python@v6
37+
uses: astral-sh/setup-uv@v7
3938
with:
4039
# this version should be upgraded as often as possible, typically once a year when
4140
# Cython, numpy and matplotlib are known to be compatible
4241
python-version: '3.14'
43-
allow-prereleases: true
42+
enable-cache: false
43+
activate-environment: true # allows using uv pip directly
44+
45+
- name: Configure uv
46+
run: |
47+
echo "UV_PRERELEASE=allow" >> "$GITHUB_ENV"
48+
echo "UV_INDEX=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" >> "$GITHUB_ENV"
49+
echo "UV_INDEX_STRATEGY=unsafe-best-match" >> "$GITHUB_ENV"
4450
4551
- name: Install dependencies
52+
# note: the --no-build flag can later be configured at the project level to
53+
# blacklist certain packages we *never* want to build
4654
run: |
47-
python -m pip install --upgrade pip
48-
python -m pip install --upgrade setuptools wheel
49-
python -m pip install --pre --only-binary ":all:" numpy matplotlib Cython \
50-
--extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
51-
python -m pip install --pre ewah-bool-utils
52-
python -m pip install git+https://github.com/yt-project/unyt.git
53-
python -m pip install git+https://github.com/pytest-dev/pytest.git
55+
uv pip install setuptools
56+
uv pip install --no-build numpy matplotlib Cython ewah-bool-utils
57+
uv add git+https://github.com/yt-project/unyt.git
58+
uv add --extra test git+https://github.com/pytest-dev/pytest.git
5459
5560
- name: Build
5661
# --no-build-isolation is used to guarantee that build time dependencies
5762
# are not installed by pip as specified from pyproject.toml, hence we get
5863
# to use the dev version of numpy at build time.
59-
run: |
60-
python -m pip -v install -e .[test] --no-build-isolation
61-
62-
- run: python -m pip list
64+
run: uv sync --extra test --no-build-isolation
6365

66+
- run: yt config set --local yt log_level 50 # Disable excessive output
6467
- name: Run Tests
65-
run: |
66-
yt config set --local yt log_level 50 # Disable excessive output
67-
pytest yt -vvv --color=yes
68+
run: uv run --no-sync pytest yt -vvv --color=yes
6869

6970
create-issue:
7071
if: ${{ failure() && github.event_name == 'schedule' }}

.github/workflows/build-test.yaml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
venv-loc: bin
6363
- os: ubuntu-latest
6464
# minimal tests with latest Python and no optional dependencies
65-
python-version: '3.x'
65+
python-version: '3.14'
6666
dependencies: ''
6767
tests-type: unit
6868
test-runner: pytest
@@ -77,9 +77,10 @@ jobs:
7777

7878
steps:
7979
- name: Set up Python
80-
uses: actions/setup-python@v6
80+
uses: astral-sh/setup-uv@v7
8181
with:
8282
python-version: ${{ matrix.python-version }}
83+
enable-cache: false
8384
- name: Checkout repo (bare)
8485
if: matrix.tests-type != 'answer'
8586
uses: actions/checkout@v5
@@ -92,34 +93,27 @@ jobs:
9293
shell: bash
9394
env:
9495
dependencies: ${{ matrix.dependencies }}
95-
run: |
96-
python -m venv .venv
97-
source .venv/${{matrix.venv-loc}}/activate
98-
source ./tests/ci_install.sh
96+
run: source ./tests/ci_install.sh
9997

10098
- name: Install and patch nosetest
10199
if: matrix.test-runner == 'nose'
100+
# note: this could be handled with [tool.uv.sources]
102101
run: |
103-
source .venv/${{matrix.venv-loc}}/activate
104-
python -m pip install -r nose_requirements.txt
102+
uv pip install -r nose_requirements.txt
105103
find .venv/lib/python${{matrix.python-version}}/site-packages/nose -name '*.py' \
106104
-exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';'
107105
108106
- name: Show final env
109-
run: |
110-
source .venv/${{matrix.venv-loc}}/activate
111-
python -m pip list
107+
run: uv pip list
112108

113109
- name: Run Unit Tests (pytest)
114110
if: matrix.test-runner == 'pytest'
115-
run: |
116-
source .venv/${{matrix.venv-loc}}/activate
117-
pytest yt --color=yes
111+
run: uv run --no-sync pytest yt --color=yes
112+
118113
- name: Run Tests (nose)
119114
if: matrix.test-runner == 'nose'
120115
run: |
121-
source .venv/${{matrix.venv-loc}}/activate
122-
cat nose_ignores.txt | xargs python -m nose -c nose_unit.cfg --traverse-namespace
116+
cat nose_ignores.txt | xargs uv run python -m nose -c nose_unit.cfg --traverse-namespace
123117
124118
image-tests:
125119
name: Image tests
@@ -132,9 +126,10 @@ jobs:
132126

133127
steps:
134128
- name: Set up Python
135-
uses: actions/setup-python@v6
129+
uses: astral-sh/setup-uv@v7
136130
with:
137131
python-version: '3.11'
132+
enable-cache: false
138133

139134
- name: Checkout repo (with submodules)
140135
uses: actions/checkout@v5
@@ -145,14 +140,14 @@ jobs:
145140
shell: bash
146141
env:
147142
dependencies: 'cartopy'
148-
run: |
149-
source ./tests/ci_install.sh
143+
run: source ./tests/ci_install.sh
150144

151145
- run: python -m pip list
152146

153147
- name: Run Image Tests
154148
run: |
155-
pytest yt --color=yes --mpl -m mpl_image_compare \
149+
uv run --no-sync \
150+
pytest yt --color=yes --mpl -m mpl_image_compare \
156151
--mpl-generate-summary=html \
157152
--mpl-results-path=pytest_mpl_results \
158153
--mpl-baseline-path=tests/pytest_mpl_baseline \
@@ -161,7 +156,8 @@ jobs:
161156
- name: Generate new image baseline
162157
if: failure()
163158
run: |
164-
pytest yt --color=yes --mpl -m mpl_image_compare \
159+
uv run --no-sync \
160+
pytest yt --color=yes --mpl -m mpl_image_compare \
165161
--mpl-generate-path=pytest_mpl_new_baseline \
166162
--last-failed
167163

.github/workflows/type-checking.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@ jobs:
2828
uses: actions/checkout@v5
2929

3030
- name: Set up Python
31-
uses: actions/setup-python@v6
31+
uses: astral-sh/setup-uv@v7
3232
with:
3333
# run with oldest supported python version
3434
# so that we always get compatible versions of
3535
# core dependencies at type-check time
3636
python-version: '3.10'
37+
enable-cache: false
3738

3839
- name: Build
3940
run: |
40-
python3 -m pip install --upgrade pip
41-
python3 -m pip install -e . -r requirements/typecheck.txt
41+
uv sync
42+
uv pip install -r requirements/typecheck.txt
4243
43-
- run: python -m pip list
44+
- run: uv pip list
4445

4546
- name: Run mypy
46-
run: mypy yt
47+
run: uv run --no-sync mypy yt

.github/workflows/wheels.yaml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,27 @@ jobs:
7171
uses: actions/checkout@v5
7272

7373
- name: Set up Python
74-
uses: actions/setup-python@v6
74+
uses: astral-sh/setup-uv@v7
7575
with:
7676
python-version: '3.10'
77+
enable-cache: false
78+
activate-environment: true # allows using uv pip directly
7779

7880
- name: Build sdist
79-
run: pipx run build --sdist
81+
run: uv build --sdist
82+
83+
- name: Install sdist
84+
# setting a dev version as the lower bound to signal that
85+
# pre-releases are to be prefered, but *only* for yt itself (unlike --pre)
86+
run: uv pip install "yt[test]>=0.0.0dev0" --find-links dist/
87+
88+
- run: uv pip list
8089

8190
- name: Test sdist
8291
run: |
83-
python -m pip install "$(echo dist/*.tar.gz)[test]"
84-
python -m pip list
8592
project_dir=$(pwd)
86-
cd ../../
87-
pytest -c $project_dir/pyproject.toml --rootdir . --color=yes --pyargs yt
93+
uv run --directory ../../ --no-project \
94+
pytest -c $project_dir/pyproject.toml --rootdir . --color=yes --pyargs yt
8895
8996
- name: Upload sdist
9097
uses: actions/upload-artifact@v4
@@ -101,28 +108,12 @@ jobs:
101108
with:
102109
submodules: true
103110
- name: Set up Python
104-
uses: actions/setup-python@v6
111+
uses: astral-sh/setup-uv@v7
105112
with:
106113
python-version: '3.13'
107-
- name: install check-manifest
108-
run: |
109-
python -m pip install --upgrade pip
110-
python -m pip install check-manifest
111-
- name: Install build time dependencies
112-
shell: bash
113-
114-
# keep in sync with pyproject.toml
115-
run: |
116-
python -m pip install Cython>=3.0.3
117-
python -m pip install numpy>=2.0.0
118-
python -m pip install ewah-bool-utils>=1.2.0
119-
python -m pip install --upgrade setuptools
120-
- name: build yt
121-
shell: bash
122-
run: |
123-
python -m pip install --no-build-isolation .
114+
enable-cache: false
124115
- name: run check-manifest
125-
run: check-manifest -vvv
116+
run: uvx check-manifest -vvv
126117

127118
deploy:
128119
name: Publish to PyPI

tests/ci_install.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,23 @@ fi
3232
# but the primary intention is to embed this script in CI jobs
3333
if [[ ${dependencies} == "minimal" ]]; then
3434
# test with minimal versions of runtime dependencies
35-
python -m pip install -e ".[test]" -r minimal_requirements.txt
35+
uv venv -c
36+
uv pip install -e ".[test]" -c minimal_requirements.txt
3637
elif [[ ${dependencies} == "cartopy" ]]; then
37-
python -m pip install 'cartopy>=0.22'
3838
# scipy is an optional dependency to cartopy
39-
python -m pip install scipy
40-
python -m pip install -e ".[test]"
39+
uv venv -c
40+
uv pip install 'cartopy>=0.22' scipy
41+
uv sync --extra test --inexact
4142
elif [[ ${dependencies} == "full" ]]; then
4243
# test with all optional runtime dependencies
43-
python -m pip install -e ".[test,full]"
44+
uv sync --extra test --extra full
4445
else
45-
# test with no special requirements
46-
python -m pip install -e ".[test]"
46+
# test with no special requirements
47+
uv sync --extra test
4748
fi
4849

4950
# Disable excessive output
50-
yt config set --local yt log_level 50
51+
uv run --no-sync yt config set --local yt log_level 50
5152
cat yt.toml
5253

5354
set +x

0 commit comments

Comments
 (0)