Skip to content

Commit

Permalink
[MAINT] Replace setup.py with pyproject.toml (#160)
Browse files Browse the repository at this point in the history
* Add new toml files

---------

Signed-off-by: Adam Li <[email protected]>
  • Loading branch information
adam2392 authored Dec 6, 2023
1 parent 241b6ff commit 52c3824
Show file tree
Hide file tree
Showing 22 changed files with 868 additions and 774 deletions.
425 changes: 212 additions & 213 deletions .circleci/config.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
raison
fro
nd
28 changes: 28 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[flake8]
max-line-length = 100

ignore =
# these rules don't play well with black
# whitespace before ':'
E203
# line break before binary operator
W503
E241,E305,W504,W605,E731

exclude =
.git
.github
.venv
.mypy_cache
.pytest_cache
.circleci
paper
setup.py
doc
benchmarks
build

per-file-ignores =
# __init__.py files are allowed to have unused imports
*/__init__.py:F401
*/**/__init__.py:F401
Empty file added .git-blame-ignore-revs
Empty file.
4 changes: 2 additions & 2 deletions .github/workflows/cffconvert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- CITATION.cff
pull_request:
paths:
- CITATION.cff
- CITATION.cff

jobs:
validate:
Expand All @@ -19,4 +19,4 @@ jobs:
- name: Check whether the citation metadata from CITATION.cff is valid
uses: citation-file-format/[email protected]
with:
args: "--validate"
args: "--validate"
47 changes: 47 additions & 0 deletions .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: code-style
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches: [main, maint/0.2, maint/0.3, maint/0.4]
workflow_dispatch:

jobs:
style:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off .[style]
- name: Run isort
uses: isort/isort-action@master
- name: Run black
uses: psf/black@stable
with:
options: "--check --verbose"
- name: Run Ruff
run: ruff check .
- name: Run codespell
uses: codespell-project/actions-codespell@master
with:
check_filenames: true
check_hidden: true
skip: './.git,./build,./.mypy_cache,./.pytest_cache,./mne_icalabel/iclabel/network/assets'
ignore_words_file: ./.codespellignore
# - name: Run pydocstyle
# run: pydocstyle .
- name: Run toml-sort
run: toml-sort pyproject.toml --check
- name: Run yamllint
run: yamllint . -c .yamllint.yaml --strict
4 changes: 2 additions & 2 deletions .github/workflows/linux_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
curl https://raw.githubusercontent.com/mne-tools/mne-python/main/tools/get_minimal_commands.sh -o get_minimal_commands.sh
chmod +x get_minimal_commands.sh
source ./get_minimal_commands.sh
pip install -r requirements_testing.txt
pip install .[test]
name: 'Install dependencies'
- run: pip install git+https://github.com/mne-tools/mne-python@main
- run: pip install -e .
Expand All @@ -51,5 +51,5 @@ jobs:
python -c "import numpy; numpy.show_config()"
name: 'Show infos'
- name: Run pytest
run: python -m pytest . --cov=mne_connectivity --cov-report=xml --cov-config=setup.cfg --verbose --ignore mne-python
run: python -m pytest . --cov=mne_connectivity --cov-report=xml --cov-config=pyproject.toml --verbose --ignore mne-python
- uses: codecov/codecov-action@v3
36 changes: 18 additions & 18 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10

- name: Checkout code
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install twine wheel
- name: Install dependencies
run: |
pip install .[build]
pip install twine wheel
- name: Build and publish to PyPi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
- name: Build and publish to PyPi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
49 changes: 13 additions & 36 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,24 @@
name: 'unit_tests'
name: "unit_tests"
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
- "main"
pull_request:
branches:
- '*'
- "*"

jobs:
# Run style tests
style:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ 3.9 ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pip
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade --upgrade-strategy eager -r requirements.txt
pip install --upgrade --upgrade-strategy eager -r requirements_testing.txt
- name: Run style & documentation tests
run: make pep

# Run installation tests
install:
runs-on: ${{ matrix.os }}
runs-on: install-${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.11" ]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"]
include:
# An old one
- os: ubuntu-latest
Expand All @@ -57,8 +35,7 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade --upgrade-strategy eager -r requirements.txt
pip install --upgrade --upgrade-strategy eager -r requirements_testing.txt
pip install --upgrade .[test]
- run: mne sys_info
- name: Build sdist
run: python setup.py sdist
Expand Down Expand Up @@ -117,10 +94,10 @@ jobs:
env:
TZ: Europe/Berlin
FORCE_COLOR: true
DISPLAY: ':99.0'
MNE_LOGGING_LEVEL: 'info'
OPENBLAS_NUM_THREADS: '1'
PYTHONUNBUFFERED: '1'
DISPLAY: ":99.0"
MNE_LOGGING_LEVEL: "info"
OPENBLAS_NUM_THREADS: "1"
PYTHONUNBUFFERED: "1"
steps:
- uses: actions/setup-python@v4
with:
Expand All @@ -133,7 +110,7 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade --upgrade-strategy eager -r requirements.txt -r requirements_testing.txt
pip install --upgrade --upgrade-strategy eager .[test]
- if: matrix.mne-version == 'mne-stable'
run: pip install --upgrade mne
- name: Install MNE (main)
Expand All @@ -149,5 +126,5 @@ jobs:
which python
- run: pip install -e .
- run: mne sys_info
- run: python -m pytest . --cov=mne_connectivity --cov-report=xml --cov-config=setup.cfg --verbose --ignore mne-python
- run: python -m pytest . --cov=mne_connectivity --cov-report=xml --cov-config=pyproject.toml --verbose --ignore mne-python
- uses: codecov/codecov-action@v3
6 changes: 6 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: default

rules:
line-length: disable
document-start: disable
truthy: disable
40 changes: 34 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# simple makefile to simplify repetetive build env management tasks under posix
# simple makefile to simplify repetitive build env management tasks under posix

# caution: testing won't work on windows, see README

PYTHON ?= python
PYTESTS ?= pytest
CTAGS ?= ctags
CODESPELL_SKIPS ?= "*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,plot_*.rst,*.rst.txt,*.html,gdf_encodes.txt"
CODESPELL_DIRS ?= mne_connectivity/ doc/ examples/
CODESPELL_DIRS ?= mne_connectivity/ doc/ examples/ benchmarks/
all: clean inplace test test-doc

clean-pyc:
Expand Down Expand Up @@ -65,7 +65,7 @@ test-doc: sample_data testing_data
test-coverage: testing_data
rm -rf coverage .coverage
$(PYTESTS) --cov=mne_connectivity --cov-report html:coverage
# whats the difference with test-no-sample-with-coverage?
# what's the difference with test-no-sample-with-coverage?

test-mem: in testing_data
ulimit -v 1097152 && $(PYTESTS) mne
Expand All @@ -91,11 +91,31 @@ flake:
fi;
@echo "flake8 passed"

black:
@if command -v black > /dev/null; then \
echo "Running black"; \
black mne_connectivity examples; \
else \
echo "black not found, please install it!"; \
exit 1; \
fi;
@echo "black passed"

isort:
@if command -v isort > /dev/null; then \
echo "Running isort"; \
isort mne_connectivity examples doc; \
else \
echo "isort not found, please install it!"; \
exit 1; \
fi;
@echo "isort passed"

codespell: # running manually
@codespell -w -i 3 -q 3 -S $(CODESPELL_SKIPS) --ignore-words=ignore_words.txt $(CODESPELL_DIRS)
@codespell -w -i 3 -q 3 -S $(CODESPELL_SKIPS) --ignore-words=.codespellignore $(CODESPELL_DIRS)

codespell-error: # running on travis
@codespell -i 0 -q 7 -S $(CODESPELL_SKIPS) --ignore-words=ignore_words.txt $(CODESPELL_DIRS)
@codespell -i 0 -q 7 -S $(CODESPELL_SKIPS) --ignore-words=.codespellignore $(CODESPELL_DIRS)

pydocstyle:
@echo "Running pydocstyle"
Expand All @@ -116,4 +136,12 @@ build-doc:
@echo "Building documentation"
make -C doc/ clean
make -C doc/ html-noplot
cd doc/ && make view
cd doc/ && make view

run-checks:
isort --check .
black --check mne_connectivity examples
flake8 .
mypy ./mne_connectivity
@$(MAKE) pydocstyle
@$(MAKE) codespell-error
Loading

0 comments on commit 52c3824

Please sign in to comment.