Skip to content

Commit 5427181

Browse files
authored
Use uv (#504)
Fixes #501. To do: - [ ] Adapt workflow to setup access to PyPI (see https://docs.astral.sh/uv/guides/publish/#publishing-a-package) - [ ] Optimize tests (currently, I'm using `uv pip ...`, but I think this should be replaced with `uv run ...` - [ ] Bump any package versions and/or Python? - [ ] Use Ruff instead of Black?
2 parents c687060 + b6ca66c commit 5427181

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

.github/workflows/run-tests.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,19 @@ jobs:
1919
os: [windows-latest, ubuntu-latest, macos-latest]
2020
python-version: ["3.8", "3.9", "3.10", "3.11"]
2121
steps:
22-
- uses: actions/checkout@v3
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v4
25-
with:
26-
python-version: ${{ matrix.python-version }}
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip poetry
30-
pip install ".[dev]"
22+
- uses: actions/checkout@v4
23+
- name: Setup uv
24+
uses: astral-sh/setup-uv@v3
25+
- name: Install Python ${{ matrix.python-version }}
26+
run: uv python install ${{ matrix.python-version }}
3127
- name: Install libsndfile
3228
if: startsWith(matrix.os, 'ubuntu')
3329
run: |
3430
sudo apt-get install -y libsndfile1
3531
- name: Run tests
36-
run: pytest
37-
- name: Validate poetry file
38-
run: poetry check
32+
run: uv run --extra dev pytest
3933
- name: Check source code format
40-
run: black --check --diff .
34+
run: uv run --extra dev black --check --diff .
4135

4236
test-deb10-i386:
4337
runs-on: ubuntu-latest

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,3 @@ target/
7272

7373
# pyenv
7474
.python-version
75-
76-
# Poetry
77-
poetry.lock

DEVELOPING.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ black .
1616

1717
## Package and Dependency Management
1818

19-
This project uses [poetry](https://python-poetry.org/docs/) for package management and distribution.
19+
This project uses [uv](https://docs.astral.sh/uv/) for package management and distribution.
2020

21-
Development dependencies are specified as optional dependencies, and then added to the "dev" extra group in the [pyproject.toml](./pyproject.toml) file.
21+
Development dependencies are specified as optional dependencies, at least for now and until [development dependencies](https://docs.astral.sh/uv/concepts/dependencies/#development-dependencies) become more widely used.
2222

2323
```sh
24-
# Do NOT use: poetry add <somepackage> --dev
25-
poetry add --optional <somepackage>
24+
uv add <somepackage> --optional <somegroup>
2625
```
2726

28-
The `[tool.poetry.dev-dependencies]` attribute is NOT used because of a [limitation](https://github.com/python-poetry/poetry/issues/3514) that prevents these dependencies from being pip installable. Therefore, dev dependencies are not installed when purely running `poetry install`, and the `--no-dev` flag has no meaning in this project.
29-
3027
## Creating Distributions
3128

32-
Make sure the versions in [version.py](./wfdb/version.py) and [pyproject.toml](./pyproject.toml) are updated and kept in sync.
29+
Make sure to update the version in [version.py](./wfdb/version.py) accordingly.
3330

3431
It may be useful to publish to testpypi and preview the changes before publishing to PyPi. However, the project dependencies likely will not be available when trying to install from there.
3532

@@ -47,10 +44,10 @@ poetry config pypi-token.test-pypi <my-testpypi-token>
4744
To build and upload a new distribution:
4845

4946
```sh
50-
poetry build
47+
uv build
5148

52-
poetry publish -r test-pypi
53-
poetry publish
49+
uv publish --publish-url https://test.pypi.org/legacy/
50+
uv publish
5451
```
5552

5653
## Creating Documentation

pyproject.toml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
26
name = "wfdb"
3-
version = "4.1.2"
47
description = "The WFDB Python package: tools for reading, writing, and processing physiologic signals and annotations."
5-
authors = ["The Laboratory for Computational Physiology <[email protected]>"]
8+
authors = [{name = "The Laboratory for Computational Physiology", email = "[email protected]"}]
9+
license = {text = "MIT License"}
610
readme = "README.md"
11+
requires-python = ">= 3.8"
12+
dependencies = [
13+
"numpy >= 1.10.1, < 2.0.0",
14+
"scipy >= 1.0.0",
15+
"pandas >= 1.3.0",
16+
"soundfile >= 0.10.0",
17+
"matplotlib >= 3.2.2",
18+
"requests >= 2.8.1",
19+
]
20+
dynamic = ["version"]
21+
22+
[project.optional-dependencies]
23+
dev = [
24+
"pytest >= 7.1.1",
25+
"pytest-xdist >= 2.5.0",
26+
"pylint >= 2.13.7",
27+
"black >= 22.3.0",
28+
"sphinx >= 4.5.0",
29+
]
30+
31+
[project.urls]
732
homepage = "https://github.com/MIT-LCP/wfdb-python/"
833
repository = "https://github.com/MIT-LCP/wfdb-python/"
934
documentation = "https://wfdb.readthedocs.io/"
10-
license = "MIT"
11-
12-
[tool.poetry.dependencies]
13-
python = ">=3.7"
14-
numpy = ">=1.10.1,<2.0.0"
15-
scipy = ">=1.0.0"
16-
pandas = ">=1.3.0"
17-
SoundFile = ">=0.10.0"
18-
matplotlib = ">=3.2.2"
19-
requests = ">=2.8.1"
20-
pytest = {version = ">=7.1.1", optional = true}
21-
pytest-xdist = {version = ">=2.5.0", optional = true}
22-
pylint = {version = ">=2.13.7", optional = true}
23-
black = {version = ">=22.3.0", optional = true}
24-
Sphinx = {version = ">=4.5.0", optional = true}
25-
26-
[tool.poetry.extras]
27-
dev = ["pytest", "pytest-xdist", "pylint", "black", "Sphinx"]
28-
29-
# Do NOT use [tool.poetry.dev-dependencies]. See: https://github.com/python-poetry/poetry/issues/3514
3035

3136
[tool.black]
3237
line-length = 80
3338
target-version = ['py37']
3439

35-
[build-system]
36-
requires = ["poetry-core>=1.0.0"]
37-
build-backend = "poetry.core.masonry.api"
40+
[tool.hatch.build.targets.sdist]
41+
exclude = [
42+
"/tests",
43+
"/sample-data",
44+
"/demo-img.png",
45+
"/demo.ipynb",
46+
]
47+
48+
[tool.hatch.version]
49+
path = "wfdb/version.py"

0 commit comments

Comments
 (0)