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

Modern packaging + ruff + numpy 2 compat #187

Open
wants to merge 18 commits into
base: master
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
14 changes: 0 additions & 14 deletions .coveragerc

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/black.yml

This file was deleted.

24 changes: 13 additions & 11 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,47 @@ name: Python tests

on:
push:
branches: [master, develop]
branches: [master]
pull_request:
branches: [master, develop]
branches: [master]
raphaelvallat marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest] # macos-latest
python-version: ["3.9", "3.10", "3.11"]
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]

runs-on: ${{ matrix.platform }}

env:
FORCE_COLOR: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install libomp (macOS)
if: ${{ matrix.platform == 'macos-latest' }}
run: brew install libomp

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
pip install .
pip install ".[test]"

- name: Test with pytest
run: |
pytest --cov --cov-report=xml --cov-config=setup.cfg --verbose
pytest --cov --cov-report=xml --verbose

- name: Upload coverage report
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.9 }}
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: a58a0c62-fb11-4429-977b-65bec01ecb44
file: ./coverage.xml
13 changes: 13 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Linting"
uses: astral-sh/ruff-action@v1
- name: "Formatting"
uses: astral-sh/ruff-action@v1
with:
args: "format --check"
19 changes: 2 additions & 17 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# Add README, LICENSE and requirements :
# Add README and LICENSE :
include README.rst
include LICENSE
include requirements.txt

# Add trained classifiers
# v0.4.0
include yasa/classifiers/clf_eeg_lgb_0.4.0.joblib
include yasa/classifiers/clf_eeg+eog_lgb_0.4.0.joblib
include yasa/classifiers/clf_eeg+eog+emg_lgb_0.4.0.joblib
include yasa/classifiers/clf_eeg+eog+emg+demo_lgb_0.4.0.joblib

# v0.5.0
include yasa/classifiers/clf_eeg_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+demo_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog+demo_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+emg_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+emg+demo_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog+emg_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog+emg+demo_lgb_0.5.0.joblib
recursive-include yasa/classifiers/ *.joblib
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
.. image:: https://pepy.tech/badge/yasa
:target: https://pepy.tech/badge/yasa

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff

----------------

.. figure:: /docs/pictures/yasa_logo.png
Expand Down Expand Up @@ -48,6 +52,15 @@ Alternatively, YASA can be installed with conda:
conda config --set channel_priority strict
conda install yasa

To build and install from source, clone this repository or download the source archive and decompress the files

.. code-block:: shell

cd yasa
pip install ".[test]" # install the package
pip install --editable ".[test]" # or editable install
pytest # test the package

**What are the prerequisites for using YASA?**

To use YASA, all you need is:
Expand Down
2 changes: 0 additions & 2 deletions codecov.yml

This file was deleted.

4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import os
import sys
import time
import yasa

import sphinx_bootstrap_theme

import yasa

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Code guidelines

Before starting new code, we highly recommend opening an issue on `GitHub <https://github.com/raphaelvallat/yasa>`_ to discuss potential changes.

* Please use standard `pep8 <https://pypi.python.org/pypi/pep8>`_ and `flake8 <http://flake8.pycqa.org/>`_ Python style guidelines. To test that your code complies with those, you can run:
* Please use standard `pep8 <https://pypi.python.org/pypi/pep8>`_ and `flake8 <http://flake8.pycqa.org/>`_ Python style guidelines. YASA uses `ruff <https://github.com/astral-sh/ruff>`_ for code formatting. Before submitting a PR, please make sure to run the following command in the root folder of YASA:

.. code-block:: bash

$ flake8
$ ruff format --line-length=100

* Use `NumPy style <https://numpydoc.readthedocs.io/en/latest/format.html>`_ for docstrings. Follow existing examples for simplest guidance.

Expand Down
13 changes: 13 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
.. image:: https://pepy.tech/badge/yasa
:target: https://pepy.tech/badge/yasa

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff

----------------

.. figure:: /pictures/yasa_logo.png
Expand Down Expand Up @@ -48,6 +52,15 @@ Alternatively, YASA can be installed with conda:
conda config --set channel_priority strict
conda install yasa

To build and install from source, clone this repository or download the source archive and decompress the files

.. code-block:: shell

cd yasa
pip install ".[test]" # install the package
pip install -e ".[test]" # or editable install
pytest # test the package

**What are the prerequisites for using YASA?**

To use YASA, all you need is:
Expand Down
6 changes: 6 additions & 0 deletions push_pypi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Build and upload a new version of YASA

```bash
python -m build
twine upload dist/yasa-<VERSION>
```
134 changes: 131 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,132 @@
[tool.black]
[build-system]
requires = ["setuptools>=70.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "yasa"
description = "YASA: Analysis of polysomnography recordings."
readme = "README.rst"
license = {text = "BSD (3-clause)"}
authors = [
{name = "Raphael Vallat", email = "[email protected]"},
{name = "Remington Mallett", email = "[email protected]"},
]
raphaelvallat marked this conversation as resolved.
Show resolved Hide resolved
maintainers = [
{name = "Raphael Vallat", email = "[email protected]"},
{name = "Remington Mallett", email = "[email protected]"},
]
classifiers = [
"Intended Audience :: Science/Research",
"Operating System :: MacOS",
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
requires-python = ">=3.9"
dependencies = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the failure on python v3.12, should we change this to >=3.9, <3.12?

I think we should go forward as-is without >3.11 support, but given that Python currently supports versions up to 3.13, I would like to not fall that far behind. Maybe I can add a PR on lspopt about this? We could be patient about a fix and then come up with an alternate plan if need be.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep support for 3.12. I'll investigate the lspopt issue now

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem solved here as well. Just needed to add setuptools to the dependencies.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this still creates a DeprecationWarning in the tests. We should update lspopt at some point:

=============================== warnings summary ===============================
../../../../../opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/lspopt/data/__init__.py:11
  /opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/lspopt/data/__init__.py:11: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import resource_filename

"numpy>=1.18.1",
"scipy",
"pandas",
"matplotlib",
"seaborn",
"mne>=1.3",
"numba>=0.57.1",
"antropy",
"scikit-learn",
"tensorpac>=0.6.5",
"pyriemann>=0.2.7",
"sleepecg>=0.5.0",
"setuptools>=70",
"lspopt",
"ipywidgets",
"joblib",
"lightgbm",
]

[project.optional-dependencies]
test = [
"pytest>=6",
"pytest-cov",
# Ensure coverage is new enough for `source_pkgs`.
"coverage[toml]>=5.3",
"ruff"
]
docs = [
"sphinx>7.0.0",
"pydata_sphinx_theme",
"numpydoc",
"sphinx-copybutton",
"sphinx-design",
"sphinx-notfound-page",
]

[project.urls]
Homepage = "https://github.com/raphaelvallat/yasa/"
Downloads = "https://github.com/raphaelvallat/yasa/"

[tool.setuptools]
py-modules = ["yasa"]
include-package-data = true

[tool.setuptools.package-data]
yasa = [
"classifiers/*.joblib",
]

[tool.setuptools.packages.find]
namespaces = false
where = ["src"]

[tool.setuptools.dynamic]
version = {attr = "yasa.__version__"}

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--showlocals --durations=10 --maxfail=2 --cov"
doctest_optionflags= ["NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL"]
filterwarnings = [
"ignore::UserWarning",
"ignore::RuntimeWarning",
"ignore::FutureWarning",
]
markers = ["slow"]

[tool.coverage.run]
branch = true
omit = [
"*/tests/*",
]
source_pkgs = ["yasa"]

[tool.coverage.paths]
source = ["src"]

[tool.coverage.report]
show_missing = true
# sort = "Cover"

[tool.ruff]
line-length = 100
raphaelvallat marked this conversation as resolved.
Show resolved Hide resolved
target-version = ['py311']
include = '\.pyi?$'
target-version = "py311"
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
lint.select = ["E4", "E7", "E9", "F", "I", "NPY201"]
exclude = [
"notebooks", # Skip jupyter notebook examples
"docs",
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403"] # Ignore star and unused import violations for __init__.py files

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.format]
docstring-code-format = false
docstring-code-line-length = 90
4 changes: 0 additions & 4 deletions requirements-test.txt

This file was deleted.

16 changes: 0 additions & 16 deletions requirements.txt

This file was deleted.

Loading
Loading