Skip to content

Commit 7fe4846

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

File tree

5 files changed

+108
-87
lines changed

5 files changed

+108
-87
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 & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,24 @@ jobs:
2929
dependencies: [full]
3030
tests-type: [unit]
3131
test-runner: [pytest]
32-
venv-loc: [bin]
3332
include:
3433
- os: windows-latest
3534
python-version: '3.13'
3635
dependencies: full
3736
tests-type: unit
3837
test-runner: pytest
39-
venv-loc: Scripts
4038
- os: ubuntu-22.04
4139
python-version: '3.10.4'
4240
dependencies: minimal
4341
tests-type: unit
4442
test-runner: pytest
45-
venv-loc: bin
4643
- os: ubuntu-latest
4744
# this job is necessary for non-answer, 'yield' based tests
4845
# because pytest doesn't support such tests
4946
python-version: '3.10'
5047
dependencies: full
5148
tests-type: unit
5249
test-runner: nose
53-
venv-loc: bin
5450
- os: ubuntu-latest
5551
# answer tests use 'yield', so they require nose
5652
# they are also attached to a specific, occasionally updated, Python version
@@ -59,14 +55,12 @@ jobs:
5955
dependencies: full
6056
tests-type: answer
6157
test-runner: nose
62-
venv-loc: bin
6358
- os: ubuntu-latest
6459
# minimal tests with latest Python and no optional dependencies
65-
python-version: '3.x'
60+
python-version: '3.14'
6661
dependencies: ''
6762
tests-type: unit
6863
test-runner: pytest
69-
venv-loc: bin
7064

7165
runs-on: ${{ matrix.os }}
7266

@@ -77,9 +71,10 @@ jobs:
7771

7872
steps:
7973
- name: Set up Python
80-
uses: actions/setup-python@v6
74+
uses: astral-sh/setup-uv@v7
8175
with:
8276
python-version: ${{ matrix.python-version }}
77+
enable-cache: false
8378
- name: Checkout repo (bare)
8479
if: matrix.tests-type != 'answer'
8580
uses: actions/checkout@v5
@@ -92,34 +87,27 @@ jobs:
9287
shell: bash
9388
env:
9489
dependencies: ${{ matrix.dependencies }}
95-
run: |
96-
python -m venv .venv
97-
source .venv/${{matrix.venv-loc}}/activate
98-
source ./tests/ci_install.sh
90+
run: source ./tests/ci_install.sh
9991

10092
- name: Install and patch nosetest
10193
if: matrix.test-runner == 'nose'
94+
# note: this could be handled with [tool.uv.sources]
10295
run: |
103-
source .venv/${{matrix.venv-loc}}/activate
104-
python -m pip install -r nose_requirements.txt
96+
uv pip install -r nose_requirements.txt
10597
find .venv/lib/python${{matrix.python-version}}/site-packages/nose -name '*.py' \
10698
-exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';'
10799
108100
- name: Show final env
109-
run: |
110-
source .venv/${{matrix.venv-loc}}/activate
111-
python -m pip list
101+
run: uv pip list
112102

113103
- name: Run Unit Tests (pytest)
114104
if: matrix.test-runner == 'pytest'
115-
run: |
116-
source .venv/${{matrix.venv-loc}}/activate
117-
pytest yt --color=yes
105+
run: uv run --no-sync pytest yt --color=yes
106+
118107
- name: Run Tests (nose)
119108
if: matrix.test-runner == 'nose'
120109
run: |
121-
source .venv/${{matrix.venv-loc}}/activate
122-
cat nose_ignores.txt | xargs python -m nose -c nose_unit.cfg --traverse-namespace
110+
cat nose_ignores.txt | xargs uv run python -m nose -c nose_unit.cfg --traverse-namespace
123111
124112
image-tests:
125113
name: Image tests
@@ -132,9 +120,10 @@ jobs:
132120

133121
steps:
134122
- name: Set up Python
135-
uses: actions/setup-python@v6
123+
uses: astral-sh/setup-uv@v7
136124
with:
137125
python-version: '3.11'
126+
enable-cache: false
138127

139128
- name: Checkout repo (with submodules)
140129
uses: actions/checkout@v5
@@ -145,14 +134,14 @@ jobs:
145134
shell: bash
146135
env:
147136
dependencies: 'cartopy'
148-
run: |
149-
source ./tests/ci_install.sh
137+
run: source ./tests/ci_install.sh
150138

151139
- run: python -m pip list
152140

153141
- name: Run Image Tests
154142
run: |
155-
pytest yt --color=yes --mpl -m mpl_image_compare \
143+
uv run --no-sync \
144+
pytest yt --color=yes --mpl -m mpl_image_compare \
156145
--mpl-generate-summary=html \
157146
--mpl-results-path=pytest_mpl_results \
158147
--mpl-baseline-path=tests/pytest_mpl_baseline \
@@ -161,7 +150,8 @@ jobs:
161150
- name: Generate new image baseline
162151
if: failure()
163152
run: |
164-
pytest yt --color=yes --mpl -m mpl_image_compare \
153+
uv run --no-sync \
154+
pytest yt --color=yes --mpl -m mpl_image_compare \
165155
--mpl-generate-path=pytest_mpl_new_baseline \
166156
--last-failed
167157

.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: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,71 @@ 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
80-
81-
- name: Test sdist
82-
run: |
83-
python -m pip install "$(echo dist/*.tar.gz)[test]"
84-
python -m pip list
85-
project_dir=$(pwd)
86-
cd ../../
87-
pytest -c $project_dir/pyproject.toml --rootdir . --color=yes --pyargs yt
81+
run: uv build --sdist
8882

8983
- name: Upload sdist
9084
uses: actions/upload-artifact@v4
9185
with:
9286
name: sdist
9387
path: dist/*.tar.gz
9488

89+
- name: copy configuration files
90+
run: |
91+
mkdir cfg
92+
cp pyproject.toml cfg
93+
cp conftest.py cfg
94+
95+
- name: Upload pytest configuration files
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: pytest-conf
99+
path: cfg
100+
101+
test_sdist:
102+
name: Test source distribution
103+
runs-on: ubuntu-latest
104+
needs: [build_sdist]
105+
steps:
106+
- name: Download sdist
107+
uses: actions/download-artifact@v5
108+
with:
109+
name: sdist
110+
path: dist
111+
112+
- name: Set up Python
113+
uses: astral-sh/setup-uv@v7
114+
with:
115+
python-version: '3.10'
116+
enable-cache: false
117+
118+
- name: Download pytest configuration files
119+
uses: actions/download-artifact@v5
120+
with:
121+
name: pytest-conf
122+
path: cfg
123+
124+
- name: Display structure of downloaded files
125+
run: ls -R
126+
127+
- name: Install sdist
128+
run: |
129+
uv venv
130+
uv pip install "$(echo dist/yt-*.tar.gz)[test]"
131+
132+
- run: uv pip list
133+
134+
- name: Test sdist
135+
run: |
136+
uv run --no-project --directory cfg \
137+
pytest --color=yes --pyargs yt
138+
95139
check_manifest:
96140
name: Check MANIFEST.in
97141
runs-on: ubuntu-latest
@@ -101,32 +145,16 @@ jobs:
101145
with:
102146
submodules: true
103147
- name: Set up Python
104-
uses: actions/setup-python@v6
148+
uses: astral-sh/setup-uv@v7
105149
with:
106150
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 .
151+
enable-cache: false
124152
- name: run check-manifest
125-
run: check-manifest -vvv
153+
run: uvx check-manifest -vvv
126154

127155
deploy:
128156
name: Publish to PyPI
129-
needs: [build_wheels, build_sdist, check_manifest]
157+
needs: [build_wheels, test_sdist, check_manifest]
130158
runs-on: ubuntu-latest
131159
# upload to PyPI on every tag starting with 'yt-'
132160
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/yt-')

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)