Skip to content

Commit 0a58985

Browse files
authored
Merge pull request #79 from DocOtak/to_uv
Switch project to using uv rather than poetry
2 parents 423d641 + 29b5e19 commit 0a58985

File tree

11 files changed

+2481
-3969
lines changed

11 files changed

+2481
-3969
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,70 +17,48 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: ["ubuntu-latest", "macos-latest"]
20-
python-version: ["3.10", "3.11", "3.12", "3.13"]
20+
python-version: ["3.11", "3.12", "3.13", "3.14"]
2121

2222
steps:
2323
- uses: actions/checkout@v4
24-
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v5
24+
- name: Set up latest uv and Python ${{ matrix.python-version }}
25+
uses: astral-sh/setup-uv@v6
2626
with:
2727
python-version: ${{ matrix.python-version }}
28+
activate-environment: true
2829
- name: Install / build
2930
run: |
30-
python -m pip install --upgrade pip
31-
pip install .
31+
uv pip install .
3232
3333
test:
34-
name: test (ubuntu-latest, ${{ matrix.python-version }}, ${{ matrix.pint }} Pint, packages version ${{ matrix.version }})
34+
name: test (ubuntu-latest, ${{ matrix.python-version }}, ${{ matrix.pint }} Pint, packages version ${{ matrix.resolution }})
3535
runs-on: "ubuntu-latest"
36-
env:
37-
poetry_version: 2.1.3
3836
strategy:
3937
fail-fast: false
4038
matrix:
41-
python-version: ["3.10", "3.11", "3.12", "3.13"]
39+
python-version: ["3.11", "3.12", "3.13", "3.14"]
4240
pint: ["with", "without"]
43-
version: ["lock"]
44-
include:
45-
- python-version: "3.10"
46-
version: "minimal"
47-
pint: "with"
48-
- python-version: "3.13"
49-
version: "maximal"
50-
pint: "with"
41+
resolution: ["highest", "lowest-direct"]
5142
steps:
5243
- uses: actions/checkout@v4
53-
- name: Install poetry
54-
run: pipx install poetry==${{ env.poetry_version }}
55-
- name: Set up Python ${{ matrix.python-version }}
56-
uses: actions/setup-python@v5
44+
- name: Install uv and Python ${{ matrix.python-version }}
45+
uses: astral-sh/setup-uv@v6
5746
with:
5847
python-version: ${{ matrix.python-version }}
59-
cache: 'poetry'
48+
activate-environment: true
6049
- name: Install udunits
6150
run: sudo apt-get install -y libudunits2-dev
62-
- name: update lock file
63-
if: matrix.version == 'maximal'
64-
run: poetry update
6551
- name: Install dependencies
6652
run: |
67-
poetry install --with dev
68-
poetry run pip install cf_units==3.3.0
53+
uv sync --resolution ${{matrix.resolution}} --no-group docs
6954
- if: matrix.pint == 'with'
7055
name: Install pint and pint-xarray
7156
run: |
72-
poetry install -E pint
73-
- name: use minimal versions for lock file
74-
if: matrix.version == 'minimal'
57+
uv sync --resolution ${{matrix.resolution}} --no-group docs --extra pint
58+
- name: Install cf_units
7559
run: |
76-
cp pyproject.toml pyproject.toml.bak
77-
pipx install uv
78-
uvx migrate-to-uv
79-
uv add --active "toolz>=0.12.0" "appnope>=0.1.0" "decorator>=5.1.1" "python-json-logger>2.0.4" "matplotlib>=3.5.0" "bleach>5.0.0" --frozen
80-
uv lock --resolution lowest
81-
uv pip freeze > requirements.txt
82-
poetry run pip install -r requirements.txt
83-
cp pyproject.toml.bak pyproject.toml
60+
export UDUNITS2_XML_PATH=/usr/share/xml/udunits/udunits2.xml
61+
uv pip install cf_units==3.3.0
8462
- name: Test with pytest
8563
run: |
86-
poetry run pytest gsw_xarray/tests
64+
uv run --no-sync pytest gsw_xarray/tests

.github/workflows/publish.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ on:
55
- "v*.*.*"
66
workflow_dispatch:
77
jobs:
8-
build:
8+
publish:
99
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write
12+
1013
steps:
11-
- uses: actions/checkout@v4
12-
- name: Build and publish to pypi
13-
uses: JRubics/poetry-publish@v2.0
14-
with:
15-
pypi_token: ${{ secrets.PYPI_TOKEN }}
14+
- uses: actions/checkout@v4
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
17+
- name: Build Dists
18+
run: uv build
19+
- name: Publish Python distribution to PyPI
20+
run: uv publish

.github/workflows/ruff.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Install Python
15-
uses: actions/setup-python@v5
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v6
1616
with:
17-
python-version: "3.11"
18-
- name: Install dependencies
17+
enable-cache: true
18+
- name: Lint with ruff
1919
run: |
20-
python -m pip install --upgrade pip
21-
pip install ruff
22-
# Update output format to enable automatic inline annotations.
23-
- name: Run Ruff
24-
run: ruff check --output-format=github .
25-
- name: Run Ruff format
26-
run: ruff format --check .
20+
uvx ruff check --output-format=github .
21+
- name: Test code style with ruff
22+
run: |
23+
uvx ruff format --check .

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ target/
8585
profile_default/
8686
ipython_config.py
8787

88-
# poetry
89-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
90-
# This is especially recommended for binary packages to ensure reproducibility, and is more
91-
# commonly ignored for libraries.
92-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
93-
#poetry.lock
94-
9588
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
9689
__pypackages__/
9790

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

.readthedocs.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ build:
99
tools:
1010
python: "3.12"
1111
jobs:
12-
post_create_environment:
13-
# Install poetry
14-
# https://python-poetry.org/docs/#installing-manually
15-
- pip install poetry
16-
post_install:
17-
# Install dependencies with 'docs' extra
18-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
12+
# https://docs.readthedocs.com/platform/stable/build-customization.html#install-dependencies-with-uv
13+
pre_create_environment:
14+
- asdf plugin add uv
15+
- asdf install uv latest
16+
- asdf global uv latest
17+
create_environment:
18+
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
19+
install:
20+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --resolution highest --group docs
1921

2022
sphinx:
2123
configuration: docs/conf.py

README.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,31 +262,30 @@ to open an issue in the `GitHub issues page <https://github.com/DocOtak/gsw-xarr
262262
In order to contribute to gsw-xarray, please fork the repository and
263263
submit a pull request. A good step by step tutorial for starting with git can be found in the
264264
`xarray contributor guide <https://xarray.pydata.org/en/stable/contributing.html#working-with-the-code>`_.
265-
A main difference is that we do not use conda as python environment, but poetry.
265+
A main difference is that we do not use conda as python environment, but uv.
266266

267267
Set up the environment
268268
......................
269269

270-
You will first need to `install poetry <https://python-poetry.org/docs/#installation>`_.
270+
You will first need to `install uv <https://docs.astral.sh/uv/getting-started/installation/>`_.
271271
Then go to your local clone of gsw-xarray and launch installation:
272272

273273
.. code:: bash
274274
275275
cd /path/to/your/gsw-xarray
276-
poetry install --with dev
276+
uv sync --all-groups
277277
278-
You can then activate the environment by launching a shell
279-
within the virtual environment:
278+
If desired, you can then activate the environment manually:
280279

281280
.. code:: bash
282281
283-
poetry shell
282+
source .venv/bin/activate
284283
285284
You can check that the tests pass locally:
286285

287286
.. code:: bash
288287
289-
pytest gsw_xarray/tests
288+
uv run pytest gsw_xarray/tests
290289
291290
You can install `pre-commit <https://pre-commit.com/#install>`_ to run the linting
292291
automatically at each commit.

gsw_xarray/tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def test_versions_are_in_sync():
1010

1111
path = Path(__file__).resolve().parents[2] / "pyproject.toml"
1212
pyproject = toml.loads(open(str(path)).read())
13-
pyproject_version = pyproject["tool"]["poetry"]["version"]
13+
pyproject_version = pyproject["project"]["version"]
1414

1515
package_init_version = gsw_xarray.__version__
1616

0 commit comments

Comments
 (0)