From f2ce8fb7de67531dbd4c435407f80e3a85af0049 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 9 Oct 2024 11:06:31 +0200 Subject: [PATCH 1/9] Use uv --- .github/workflows/run-tests.yml | 7 ++--- .gitignore | 3 -- DEVELOPING.md | 15 ++++------ pyproject.toml | 53 +++++++++++++++++---------------- 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fd6afbf1..31c10539 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -24,18 +24,17 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: Install dependencies run: | - python -m pip install --upgrade pip poetry - pip install ".[dev]" + uv pip install ".[dev]" - name: Install libsndfile if: startsWith(matrix.os, 'ubuntu') run: | sudo apt-get install -y libsndfile1 - name: Run tests run: pytest - - name: Validate poetry file - run: poetry check - name: Check source code format run: black --check --diff . diff --git a/.gitignore b/.gitignore index a9de35ba..ebdd3e46 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,3 @@ target/ # pyenv .python-version - -# Poetry -poetry.lock diff --git a/DEVELOPING.md b/DEVELOPING.md index f78508b0..8b9a239f 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -16,17 +16,14 @@ black . ## Package and Dependency Management -This project uses [poetry](https://python-poetry.org/docs/) for package management and distribution. +This project uses [uv](https://docs.astral.sh/uv/) for package management and distribution. -Development dependencies are specified as optional dependencies, and then added to the "dev" extra group in the [pyproject.toml](./pyproject.toml) file. +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. ```sh -# Do NOT use: poetry add --dev -poetry add --optional +uv add --optional ``` -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. - ## Creating Distributions Make sure the versions in [version.py](./wfdb/version.py) and [pyproject.toml](./pyproject.toml) are updated and kept in sync. @@ -47,10 +44,10 @@ poetry config pypi-token.test-pypi To build and upload a new distribution: ```sh -poetry build +uv build -poetry publish -r test-pypi -poetry publish +uv publish --publish-url https://test.pypi.org/legacy/ +uv publish ``` ## Creating Documentation diff --git a/pyproject.toml b/pyproject.toml index 0b7822c6..05320c50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,37 +1,38 @@ -[tool.poetry] +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] name = "wfdb" version = "4.1.2" description = "The WFDB Python package: tools for reading, writing, and processing physiologic signals and annotations." -authors = ["The Laboratory for Computational Physiology "] +authors = [{name = "The Laboratory for Computational Physiology", email = "contact@physionet.org"}] +license = {text = "MIT License"} readme = "README.md" +requires-python = ">= 3.7" +dependencies = [ + "numpy >= 1.10.1, < 2.0.0", + "scipy >= 1.0.0", + "pandas >= 1.3.0", + "soundfile >= 0.10.0", + "matplotlib >= 3.2.2", + "requests >= 2.8.1", +] + +[project.optional-dependencies] +dev = [ + "pytest >= 7.1.1", + "pytest-xdist >= 2.5.0", + "pylint >= 2.13.7", + "black >= 22.3.0", + "sphinx >= 4.5.0", +] + +[project.urls] homepage = "https://github.com/MIT-LCP/wfdb-python/" repository = "https://github.com/MIT-LCP/wfdb-python/" documentation = "https://wfdb.readthedocs.io/" -license = "MIT" - -[tool.poetry.dependencies] -python = ">=3.7" -numpy = ">=1.10.1,<2.0.0" -scipy = ">=1.0.0" -pandas = ">=1.3.0" -SoundFile = ">=0.10.0" -matplotlib = ">=3.2.2" -requests = ">=2.8.1" -pytest = {version = ">=7.1.1", optional = true} -pytest-xdist = {version = ">=2.5.0", optional = true} -pylint = {version = ">=2.13.7", optional = true} -black = {version = ">=22.3.0", optional = true} -Sphinx = {version = ">=4.5.0", optional = true} - -[tool.poetry.extras] -dev = ["pytest", "pytest-xdist", "pylint", "black", "Sphinx"] - -# Do NOT use [tool.poetry.dev-dependencies]. See: https://github.com/python-poetry/poetry/issues/3514 [tool.black] line-length = 80 target-version = ['py37'] - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" From 3b1e63f420cf6bde0ed7b79b596972c54b64ec9c Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 10 Oct 2024 07:11:37 +0200 Subject: [PATCH 2/9] Install into --system --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 31c10539..f8e6511c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -28,7 +28,7 @@ jobs: uses: astral-sh/setup-uv@v3 - name: Install dependencies run: | - uv pip install ".[dev]" + uv pip install --system ".[dev]" - name: Install libsndfile if: startsWith(matrix.os, 'ubuntu') run: | From d058b688d6184dc9c28d12c473032dd3cbfa176a Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:05:54 +0200 Subject: [PATCH 3/9] More uv --- .github/workflows/run-tests.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f8e6511c..28f40bd1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,22 +19,17 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install uv + - uses: actions/checkout@v4 + - name: Setup uv uses: astral-sh/setup-uv@v3 - - name: Install dependencies - run: | - uv pip install --system ".[dev]" + - name: Install Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} - name: Install libsndfile if: startsWith(matrix.os, 'ubuntu') run: | sudo apt-get install -y libsndfile1 - name: Run tests - run: pytest + run: uv run --extra dev pytest - name: Check source code format run: black --check --diff . From 7e113c7d0b9a072149386c4a19a691303f9939bc Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:13:16 +0200 Subject: [PATCH 4/9] Bump Python to >= 3.7.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 05320c50..23f15958 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = "The WFDB Python package: tools for reading, writing, and processi authors = [{name = "The Laboratory for Computational Physiology", email = "contact@physionet.org"}] license = {text = "MIT License"} readme = "README.md" -requires-python = ">= 3.7" +requires-python = ">= 3.7.1" dependencies = [ "numpy >= 1.10.1, < 2.0.0", "scipy >= 1.0.0", From 660c06dc53455fd7fbc80ce12999172a59af4019 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:18:23 +0200 Subject: [PATCH 5/9] Bump to 3.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 23f15958..b5dfad89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = "The WFDB Python package: tools for reading, writing, and processi authors = [{name = "The Laboratory for Computational Physiology", email = "contact@physionet.org"}] license = {text = "MIT License"} readme = "README.md" -requires-python = ">= 3.7.1" +requires-python = ">= 3.8" dependencies = [ "numpy >= 1.10.1, < 2.0.0", "scipy >= 1.0.0", From 86f9ba337cfb7fd9bb9c606b536c121f6d95c39d Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:23:24 +0200 Subject: [PATCH 6/9] Fix black --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 28f40bd1..dc0d322e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -31,7 +31,7 @@ jobs: - name: Run tests run: uv run --extra dev pytest - name: Check source code format - run: black --check --diff . + run: uv run --extra dev black --check --diff . test-deb10-i386: runs-on: ubuntu-latest From efcc568910b3259ea5cd7f5aba12be02c8de3b45 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:23:30 +0200 Subject: [PATCH 7/9] Exclude tests and sample-data --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b5dfad89..c5ac2eb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,3 +36,9 @@ documentation = "https://wfdb.readthedocs.io/" [tool.black] line-length = 80 target-version = ['py37'] + +[tool.hatch.build.targets.sdist] +exclude = [ + "/tests", + "/sample-data", +] From 7496cffba620822d450596948ff24fdfdd916ec3 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:39:05 +0200 Subject: [PATCH 8/9] Exclude demo.ipynb --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c5ac2eb2..d2dc8c11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,4 +41,6 @@ target-version = ['py37'] exclude = [ "/tests", "/sample-data", + "/demo-img.png", + "/demo.ipynb", ] From b6ca66c2dea494c6555f1ccf22225c5ae9ca2e2d Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 15 Oct 2024 09:49:13 +0200 Subject: [PATCH 9/9] Use dynamic version --- DEVELOPING.md | 2 +- pyproject.toml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DEVELOPING.md b/DEVELOPING.md index 8b9a239f..af77d3dd 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -26,7 +26,7 @@ uv add --optional ## Creating Distributions -Make sure the versions in [version.py](./wfdb/version.py) and [pyproject.toml](./pyproject.toml) are updated and kept in sync. +Make sure to update the version in [version.py](./wfdb/version.py) accordingly. 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. diff --git a/pyproject.toml b/pyproject.toml index d2dc8c11..09fbdad9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,6 @@ build-backend = "hatchling.build" [project] name = "wfdb" -version = "4.1.2" description = "The WFDB Python package: tools for reading, writing, and processing physiologic signals and annotations." authors = [{name = "The Laboratory for Computational Physiology", email = "contact@physionet.org"}] license = {text = "MIT License"} @@ -18,6 +17,7 @@ dependencies = [ "matplotlib >= 3.2.2", "requests >= 2.8.1", ] +dynamic = ["version"] [project.optional-dependencies] dev = [ @@ -44,3 +44,6 @@ exclude = [ "/demo-img.png", "/demo.ipynb", ] + +[tool.hatch.version] +path = "wfdb/version.py"