Skip to content

Commit ccd2972

Browse files
authored
Use uv instead of conda (#464)
1 parent 7c0320b commit ccd2972

21 files changed

+326
-413
lines changed

.github/workflows/benchmarks.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,18 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Set up conda environment
25-
uses: mamba-org/setup-micromamba@v2
24+
- name: Set up Python and uv
25+
uses: astral-sh/setup-uv@v4
2626
with:
27-
environment-name: flox-bench
28-
create-args: >-
29-
python=3.12
30-
asv
31-
mamba
32-
libmambapy<2.0
33-
conda-build
34-
init-shell: bash
35-
cache-environment: true
27+
python-version: "3.12"
28+
enable-cache: true
29+
cache-dependency-glob: "pyproject.toml"
30+
31+
- name: Install dependencies
32+
run: |
33+
uv sync --group benchmark --no-dev
3634
3735
- name: Run benchmarks
38-
shell: bash -l {0}
3936
id: benchmark
4037
env:
4138
OPENBLAS_NUM_THREADS: 1
@@ -50,12 +47,12 @@ jobs:
5047
run: |
5148
# set -x
5249
# ID this runner
53-
asv machine --yes
50+
uv run --no-dev asv machine --yes
5451
echo "Baseline: $LAST_HEAD_SHA ($BASE_LABEL)"
5552
echo "Contender: ${GITHUB_SHA} ($HEAD_LABEL)"
5653
# Run benchmarks for current commit against base
5754
ASV_OPTIONS="--split --show-stderr --factor $ASV_FACTOR"
58-
asv continuous $ASV_OPTIONS $BASE_SHA ${GITHUB_SHA} \
55+
uv run --no-dev asv continuous $ASV_OPTIONS $BASE_SHA ${GITHUB_SHA} \
5956
| sed "/Traceback \|failed$\|PERFORMANCE DECREASED/ s/^/::error::/" \
6057
| tee benchmarks.log
6158
# Report and export results for subsequent steps

.github/workflows/ci-additional.yaml

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,30 @@ jobs:
3535
runs-on: "ubuntu-latest"
3636
needs: detect-ci-trigger
3737
if: needs.detect-ci-trigger.outputs.triggered == 'false'
38-
defaults:
39-
run:
40-
shell: bash -l {0}
41-
4238
env:
43-
CONDA_ENV_FILE: ci/environment.yml
4439
PYTHON_VERSION: "3.13"
4540

4641
steps:
4742
- uses: actions/checkout@v5
4843
with:
4944
fetch-depth: 0 # Fetch all history for all branches and tags.
5045

51-
- name: set environment variables
52-
run: |
53-
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
54-
55-
- name: Setup micromamba
56-
uses: mamba-org/setup-micromamba@v2
46+
- name: Set up Python and uv
47+
uses: astral-sh/setup-uv@v4
5748
with:
58-
environment-file: ${{env.CONDA_ENV_FILE}}
59-
environment-name: flox-tests
60-
init-shell: bash
61-
cache-environment: true
62-
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
63-
create-args: |
64-
python=${{ env.PYTHON_VERSION }}
49+
python-version: ${{ env.PYTHON_VERSION }}
50+
enable-cache: true
51+
cache-dependency-glob: "pyproject.toml"
6552

66-
- name: Install flox
53+
- name: Install dependencies
6754
run: |
68-
python -m pip install --no-deps -e .
55+
uv sync --group complete --no-dev
6956
- name: Version info
7057
run: |
71-
conda info -a
72-
conda list
58+
uv pip list
7359
- name: Run doctests
7460
run: |
75-
python -m pytest --doctest-modules \
61+
uv run --no-dev python -m pytest --doctest-modules \
7662
flox/aggregations.py flox/core.py flox/xarray.py \
7763
--ignore flox/tests \
7864
--cov=./ --cov-report=xml
@@ -90,46 +76,32 @@ jobs:
9076
runs-on: "ubuntu-latest"
9177
needs: detect-ci-trigger
9278
if: needs.detect-ci-trigger.outputs.triggered == 'false'
93-
defaults:
94-
run:
95-
shell: bash -l {0}
9679
env:
97-
CONDA_ENV_FILE: ci/environment.yml
9880
PYTHON_VERSION: "3.13"
9981

10082
steps:
10183
- uses: actions/checkout@v5
10284
with:
10385
fetch-depth: 0 # Fetch all history for all branches and tags.
10486

105-
- name: set environment variables
106-
run: |
107-
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
108-
- name: Setup micromamba
109-
uses: mamba-org/setup-micromamba@v2
87+
- name: Set up Python and uv
88+
uses: astral-sh/setup-uv@v4
11089
with:
111-
environment-file: ${{env.CONDA_ENV_FILE}}
112-
environment-name: flox-tests
113-
init-shell: bash
114-
cache-environment: true
115-
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
116-
create-args: |
117-
python=${{ env.PYTHON_VERSION }}
118-
- name: Install flox
90+
python-version: ${{ env.PYTHON_VERSION }}
91+
enable-cache: true
92+
cache-dependency-glob: "pyproject.toml"
93+
94+
- name: Install dependencies
11995
run: |
120-
python -m pip install --no-deps -e .
96+
uv sync --group complete --no-dev --group types
12197
- name: Version info
12298
run: |
123-
conda info -a
124-
conda list
125-
- name: Install mypy
126-
run: |
127-
python -m pip install mypy
99+
uv pip list
128100
129101
- name: Run mypy
130102
run: |
131103
mkdir .mypy_cache
132-
python -m mypy --install-types --non-interactive --cache-dir=.mypy_cache/ --cobertura-xml-report mypy_report
104+
uv run --no-dev mypy --cache-dir=.mypy_cache/ --cobertura-xml-report mypy_report
133105
134106
- name: Upload mypy coverage to Codecov
135107
uses: codecov/codecov-action@v5.5.0

.github/workflows/ci.yaml

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,24 @@ jobs:
1818
test:
1919
name: Test (${{matrix.env}}, ${{ matrix.python-version }}, ${{ matrix.os }})
2020
runs-on: ${{ matrix.os }}
21-
defaults:
22-
run:
23-
shell: bash -l {0}
2421
strategy:
2522
fail-fast: false
2623
matrix:
2724
os: ["ubuntu-latest"]
28-
env: ["environment"]
25+
env: ["complete"]
2926
python-version: ["3.11", "3.13"]
3027
include:
3128
- os: "windows-latest"
32-
env: "environment"
29+
env: "complete"
3330
python-version: "3.13"
3431
- os: "ubuntu-latest"
35-
env: "no-dask" # "no-xarray", "no-numba"
32+
env: "no-dask"
3633
python-version: "3.13"
3734
- os: "ubuntu-latest"
38-
env: "minimal-requirements"
35+
env: "minimal"
3936
python-version: "3.11"
4037
- os: "windows-latest"
41-
env: "env-numpy1"
38+
env: "numpy1"
4239
python-version: "3.11"
4340
steps:
4441
- uses: actions/checkout@v5
@@ -47,18 +44,18 @@ jobs:
4744
- name: Set environment variables
4845
run: |
4946
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
50-
- name: Set up conda environment
51-
uses: mamba-org/setup-micromamba@v2
47+
- name: Set up Python and uv
48+
uses: astral-sh/setup-uv@v4
5249
with:
53-
environment-file: ci/${{ matrix.env }}.yml
54-
environment-name: flox-tests
55-
init-shell: bash
56-
cache-environment: true
57-
create-args: |
58-
python=${{ matrix.python-version }}
59-
- name: Install flox
60-
run: |
61-
python -m pip install --no-deps -e .
50+
python-version: ${{ matrix.python-version }}
51+
enable-cache: true
52+
cache-dependency-glob: "pyproject.toml"
53+
- name: Install dependencies (with config file)
54+
if: matrix.env == 'numpy1'
55+
run: uv sync --group ${{ matrix.env }} --config-file uv-numpy1.toml --no-dev
56+
- name: Install dependencies (without config file)
57+
if: matrix.env != 'numpy1'
58+
run: uv sync --group ${{ matrix.env }} --no-dev
6259

6360
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
6461
- name: Restore cached hypothesis directory
@@ -73,8 +70,8 @@ jobs:
7370
- name: Run Tests
7471
id: status
7572
run: |
76-
python -c "import xarray; xarray.show_versions()"
77-
pytest --durations=20 --durations-min=0.5 -n auto --cov=./ --cov-report=xml --hypothesis-profile ci
73+
uv run --no-dev python -c "import xarray; xarray.show_versions()" || true
74+
uv run --no-dev pytest --durations=20 --durations-min=0.5 -n auto --cov=./ --cov-report=xml --hypothesis-profile ci
7875
- name: Upload code coverage to Codecov
7976
uses: codecov/codecov-action@v5.5.0
8077
with:
@@ -96,48 +93,39 @@ jobs:
9693
xarray-groupby:
9794
name: xarray-groupby
9895
runs-on: ubuntu-latest
99-
defaults:
100-
run:
101-
shell: bash -l {0}
10296
steps:
10397
- uses: actions/checkout@v5
10498
with:
10599
repository: "pydata/xarray"
106100
fetch-depth: 0 # Fetch all history for all branches and tags.
107-
- name: Set up conda environment
108-
uses: mamba-org/setup-micromamba@v2
101+
- name: Set up Python and uv
102+
uses: astral-sh/setup-uv@v4
109103
with:
110-
environment-file: ci/requirements/environment.yml
111-
environment-name: xarray-tests
112-
init-shell: bash
113-
cache-environment: true
114-
create-args: >-
115-
python=3.11
116-
pint>=0.22
117-
- name: Install xarray
104+
python-version: "3.13"
105+
enable-cache: true
106+
cache-dependency-glob: "pyproject.toml"
107+
- name: Install xarray and dependencies
118108
run: |
119-
python -m pip install --no-deps .
109+
uv add --dev .[complete] pint>=0.22
120110
- name: Install upstream flox
121111
run: |
122-
python -m pip install --no-deps \
123-
git+https://github.com/dcherian/flox.git@${{ github.ref }}
112+
uv add git+https://github.com/dcherian/flox.git@${{ github.ref }}
124113
- name: Version info
125114
run: |
126-
conda info -a
127-
conda list
128-
python xarray/util/print_versions.py
115+
uv tree
116+
uv run --no-dev python xarray/util/print_versions.py
129117
- name: import xarray
130118
run: |
131-
python -c 'import xarray'
119+
uv run --no-dev python -c 'import xarray'
132120
- name: import flox
133121
run: |
134-
python -c 'import flox'
122+
uv run --no-dev python -c 'import flox'
135123
- name: Run Tests
136124
if: success()
137125
id: status
138126
run: |
139127
set -euo pipefail
140-
python -m pytest -n auto \
128+
uv run --no-dev python -m pytest -n auto \
141129
xarray/tests/test_groupby.py \
142130
xarray/tests/test_units.py::TestDataArray::test_computation_objects \
143131
xarray/tests/test_units.py::TestDataArray::test_grouped_operations \

.github/workflows/pypi.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v5
12-
- name: Set up Python
13-
uses: actions/setup-python@v5
11+
- uses: actions/checkout@v4
12+
- name: Set up Python and uv
13+
uses: astral-sh/setup-uv@v4
1414
with:
1515
python-version: "3.x"
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
pip install build setuptools setuptools-scm wheel twine
2016
- name: Build and publish
2117
env:
2218
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2319
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2420
run: |
25-
python -m build
26-
twine upload dist/*
21+
uv build
22+
uv publish

.github/workflows/testpypi-release.yaml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- uses: actions/setup-python@v5
25-
name: Install Python
26-
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
python -m pip install build twine
31-
python -m pip install tomli tomli_w
24+
- name: Set up Python and uv
25+
uses: astral-sh/setup-uv@v4
26+
with:
27+
python-version: "3.x"
3228

3329
# - name: Disable local versions
3430
# run: |
@@ -39,11 +35,12 @@ jobs:
3935
- name: Build tarball and wheels
4036
run: |
4137
git clean -xdf
42-
python -m build
38+
uv build
4339
4440
- name: Check built artifacts
4541
run: |
46-
python -m twine check --strict dist/*
42+
uv pip install twine
43+
uv run twine check --strict dist/*
4744
if [ -f dist/flox-999.tar.gz ]; then
4845
echo "❌ INVALID VERSION NUMBER"
4946
exit 1
@@ -60,9 +57,11 @@ jobs:
6057
needs: build-artifacts
6158
runs-on: ubuntu-latest
6259
steps:
63-
- uses: actions/setup-python@v5
64-
name: Install Python
65-
- uses: actions/download-artifact@v5
60+
- name: Set up Python and uv
61+
uses: astral-sh/setup-uv@v4
62+
with:
63+
python-version: "3.x"
64+
- uses: actions/download-artifact@v4
6665
with:
6766
name: releases
6867
path: dist
@@ -73,8 +72,7 @@ jobs:
7372
7473
- name: Verify the built dist/wheel is valid
7574
run: |
76-
python -m pip install --upgrade pip
77-
python -m pip install dist/flox*.whl
75+
uv pip install dist/flox*.whl
7876
# python -m cf_xarray.scripts.print_versions
7977
8078
# - name: Publish package to TestPyPI

0 commit comments

Comments
 (0)