Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 #241

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ jobs:
- run: ls -al dist
- name: Triage dependencies
run: |
if [[ "${{ matrix.python-version }}" != "3.13" ]]; then
echo "PIP_EXTRA=wfdb numpy<2 numba pytest-error-for-skips" | tee -a $GITHUB_ENV
echo "PYTEST_EXTRA=--error-for-skips" | tee -a $GITHUB_ENV
fi
echo "PIP_EXTRA=wfdb numba pytest-error-for-skips" | tee -a $GITHUB_ENV
echo "PYTEST_EXTRA=--error-for-skips" | tee -a $GITHUB_ENV
- run: python -m pip install ./dist/*.whl pytest pytest-cov edfio $PIP_EXTRA --only-binary="numpy,numba,edfio"
- run: pytest -rfEXs --cov=sleepecg --cov-report=xml --tb=short --cov-branch --color=yes $PYTEST_EXTRA tests/
- uses: codecov/codecov-action@v5
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
rev: v0.9.2
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.14.1
hooks:
- id: mypy
exclude: ^tests|^examples
args: [--python-version=3.9]
args: [--python-version=3.10]
additional_dependencies:
- types-PyYAML
- types-requests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Python](https://img.shields.io/pypi/pyversions/sleepecg.svg?logo=python&logoColor=white)
![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fcbrnr%2Fsleepecg%2Frefs%2Fheads%2Fmain%2Fpyproject.toml&logo=python&logoColor=white)
[![PyPI](https://img.shields.io/pypi/v/sleepecg)](https://pypi.org/project/sleepecg/)
[![Docs](https://readthedocs.org/projects/sleepecg/badge/?version=latest)](https://sleepecg.readthedocs.io/en/stable/index.html)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.05411/status.svg)](https://doi.org/10.21105/joss.05411)
Expand Down
44 changes: 21 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools", "setuptools-scm", "wheel", "numpy>=2,<3"]
requires = ["setuptools", "setuptools-scm", "wheel", "numpy>=2"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -11,38 +11,38 @@ authors = [
{name = "Clemens Brunner", email = "clemens.brunner@gmail.com"},
]
readme = "README.md"
requires-python = ">= 3.9"
requires-python = ">= 3.10"
classifiers = [
"License :: OSI Approved :: BSD License",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Typing :: Typed",
]
keywords = ["sleep", "ecg", "qrs", "peak"]
dependencies = [
"numpy >= 1.25.0, < 3.0.0",
"PyYAML >= 5.4.0",
"requests >= 2.25.0",
"scipy >= 1.7.0",
"tqdm >= 4.60.0",
"numpy >= 1.26.0",
"pyyaml >= 6.0.0",
"requests >= 2.32.3",
"scipy >= 1.13.0",
"tqdm >= 4.66.0",
]
dynamic = ["version"]

[project.optional-dependencies]
full = [ # complete package functionality
"edfio >= 0.4.0",
"joblib >= 1.0.0",
"matplotlib >= 3.5.0",
"numba >= 0.59.1",
"tensorflow >= 2.16.1",
"wfdb >= 3.4.0",
"edfio >= 0.4.4",
"joblib >= 1.4.2",
"matplotlib >= 3.9.2",
"numba >= 0.61.0",
"tensorflow >= 2.17.0; python_version < '3.13'",
"wfdb >= 4.2.0",
]

dev = [ # everything needed for development
Expand All @@ -52,20 +52,18 @@ dev = [ # everything needed for development
"pre-commit >= 2.13.0",
"pytest >= 6.2.0",
"ruff >= 0.4.0",
"setuptools >= 56.0.0",
"setuptools >= 72.1.0",
]

doc = [ # RTD uses this when building the documentation
"mkdocs-material >= 8.4.0",
"mkdocstrings-python >= 0.8.2",
"mkdocs-material >= 9.5.0",
"mkdocstrings-python >= 1.11.1",
]

cibw = [ # cibuildwheel uses this for running the test suite
"edfio >= 0.4.0",
"numba >= 0.59.1",
"wfdb >= 3.4.0",
# https://github.com/MIT-LCP/wfdb-python/pull/511
"numpy < 2.0.0", # TODO: just for wfdb!
"edfio >= 0.4.4",
"numba >= 0.61.0",
"wfdb >= 4.2.0",
]

[project.urls]
Expand All @@ -79,7 +77,7 @@ test-requires = "pytest"
test-extras = "cibw"
test-command = "pytest {package}"
skip = 'pp* *musllinux*'
build = "cp39-*" # abi3
build = "cp310-*" # abi3

[[tool.cibuildwheel.overrides]]
select = "*"
Expand Down
2 changes: 1 addition & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"

mkdocs:
configuration: mkdocs.yml
Expand Down
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

# Following https://github.com/joerick/python-abi3-package-sample


# Currently set to 3.9. If this is bumped for example to 3.10, the hex
# in the Extension needs to change to 0x030A0000, and the cibuildwheel `build`
# selector needs to change in pyproject.toml
# Currently set to 3.10. If this is bumped for example to 3.11, the hex in the Extension
# needs to change to 0x030B0000, and the cibuildwheel `build` selector needs to change
# in pyproject.toml.

class bdist_wheel_abi3(bdist_wheel):
def get_tag(self) -> tuple:
python, abi, plat = super().get_tag()

if python.startswith("cp"):
# on CPython, our wheels are abi3 and compatible back to 3.6
return "cp39", "abi3", plat
return "cp310", "abi3", plat

return python, abi, plat

Expand All @@ -26,7 +25,7 @@ def get_tag(self) -> tuple:
"sleepecg._heartbeat_detection",
["src/sleepecg/_heartbeat_detection.c"],
include_dirs=[np.get_include()],
define_macros=[("Py_LIMITED_API", "0x03090000")],
define_macros=[("Py_LIMITED_API", "0x030A0000")],
py_limited_api=True,
),
],
Expand Down
4 changes: 2 additions & 2 deletions src/sleepecg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import datetime
import warnings
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from pathlib import Path
from typing import Any, Callable, TypeVar
from typing import Any, TypeVar

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion tests/test_sleep_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _dummy_nsrr_xml(filename: str, hours: float, random_state: int):
start += epoch_duration

xml_file.write(
"</ScoredEvents>\n" "</PSGAnnotation>\n",
"</ScoredEvents>\n</PSGAnnotation>\n",
)


Expand Down