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

MRG: Use hatchling as build backend #1204

Merged
merged 12 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ruff check-manifest
python -m pip install ruff
- name: Display versions and environment information
run: |
python --version
Expand Down Expand Up @@ -61,15 +61,15 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install wheel setuptools build twine
python -m pip install build twine

- uses: actions/checkout@v4
- name: Build sdist
run: python -m build --sdist
- name: Check sdist
run: twine check --strict dist/*
- name: Install sdist
run: python -m pip install ./dist/mne-bids-*
run: python -m pip install ./dist/mne_bids-*
- name: Clean up working directory
run: rm -rf ./*
- name: Try importing mne_bids
Expand Down
33 changes: 0 additions & 33 deletions MANIFEST.in

This file was deleted.

10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean-pyc clean-so clean-build clean-ctags clean-cache clean-e clean inplace test check-manifest ruff-check ruff-format pep build-doc dist-build
.PHONY: all clean-pyc clean-so clean-build clean-ctags clean-cache clean-e clean inplace test ruff-check ruff-format pep build-doc dist-build

all: clean inplace pep test build-doc dist-build

Expand Down Expand Up @@ -37,10 +37,6 @@ test:
--ignore mne-python \
--ignore examples

check-manifest:
@echo "Checking MANIFEST.in"
@check-manifest .

ruff-format:
@echo "Running ruff format"
@ruff format mne_bids/
Expand All @@ -51,7 +47,7 @@ ruff-check:
@ruff check mne_bids/
@ruff check examples/ --ignore=D103,D400,D205

pep: ruff-check check-manifest ruff-format
pep: ruff-check ruff-format

build-doc:
@echo "Building documentation"
Expand All @@ -62,6 +58,6 @@ build-doc:
dist-build:
@echo "Building dist"
rm -rf dist
@python -m pip install wheel setuptools build twine
@python -m pip install build twine
@python -m build
@python -m twine check --strict dist/*
4 changes: 3 additions & 1 deletion doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ Detailed list of changes
🧐 API and behavior changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^

- nothing yet
- The package build backend has been switched from ``setuptools`` to ``hatchling``. This
only affects users who build and install MNE-BIDS from source, and should not lead to
changed runtime behavior, by `Richard Höchenberger`_ (:gh:`1204`)
Copy link
Member

Choose a reason for hiding this comment

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

in what ways does it affect users who build and install mne-bids from source? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The build process is simply different now. Maybe it should be phrased differently? No user intervention is required

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure it should be in the release notes then🤔 usually we skip "infrastructure changes without effect on the user", don't we?

Copy link
Member Author

Choose a reason for hiding this comment

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

There should be a Code Health section like we have in MNE-BIDS-Pipeline.

Copy link
Member Author

Choose a reason for hiding this comment

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

MS does the same for the VS Code Python extension

image


🛠 Requirements
^^^^^^^^^^^^^^^
Expand Down
8 changes: 7 additions & 1 deletion mne_bids/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""MNE software for easily interacting with BIDS compatible datasets."""

__version__ = "0.15.dev0"
try:
from importlib.metadata import version

__version__ = version("mne_bids")
except Exception:
__version__ = "0.0.0"

Check warning on line 8 in mne_bids/__init__.py

View check run for this annotation

Codecov / codecov/patch

mne_bids/__init__.py#L7-L8

Added lines #L7 - L8 were not covered by tests

from mne_bids import commands
from mne_bids.report import make_report
from mne_bids.path import (
Expand Down
40 changes: 22 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "mne-bids"
Expand Down Expand Up @@ -40,6 +40,7 @@ classifiers = [
]
scripts = { mne_bids = "mne_bids.commands.run:main" }
dependencies = ["mne>=1.5", "numpy>=1.21.2", "scipy>=1.7.1"]

[project.optional-dependencies]
# Variants with dependencies that will get installed on top of those listed unter
# project.dependencies
Expand All @@ -57,14 +58,7 @@ full = [
]

# Dependencies for running the test infrastructure
test = [
"mne_bids[full]",
"pytest",
"pytest-cov",
"pytest-sugar",
"check-manifest",
"ruff",
]
test = ["mne_bids[full]", "pytest", "pytest-cov", "pytest-sugar", "ruff"]

# Dependencies for building the documentation
doc = [
Expand All @@ -80,7 +74,7 @@ doc = [
"mne-nirs @ https://github.com/mne-tools/mne-nirs/archive/refs/heads/main.zip",
"seaborn",
"openneuro-py",
"defusedxml", # for reading BrainVision montages: `examples/convert_eeg_to_bids.py`
"defusedxml", # for reading BrainVision montages: `examples/convert_eeg_to_bids.py`
Copy link
Member

Choose a reason for hiding this comment

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

is this is mistake or by design? if by design, why?

Copy link
Member Author

Choose a reason for hiding this comment

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

My linter adds this automatically... but I can change it

Otherwise number of spaces before an inline comment in TOML is just 1

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw the linter I use comes with the Even Better TOML extension for VS Code

Very helpful tool really

]

# Dependencies for developer installations
Expand All @@ -94,14 +88,24 @@ dev = ["mne_bids[test,doc,full]", "pre-commit"]
"Forum" = "https://mne.discourse.group/"
"Source Code" = "https://github.com/mne-tools/mne-bids"

[tool.setuptools.packages.find]
where = ["."]
include = ["mne_bids"]
exclude = ["tests"]
namespaces = false
[tool.hatch.metadata]
allow-direct-references = true # allow specifying URLs in our dependencies

[tool.hatch.build]
exclude = [
"/.*",
"**/tests",
"/paper",
"/examples",
"/doc",
"/Makefile",
"/CITATION.cff",
"/CONTRIBUTING.md",
]

[tool.setuptools.dynamic]
version = { attr = "mne_bids.__version__" }
[tool.hatch.version]
source = "vcs"
raw-options = { version_scheme = "release-branch-semver" }

[tool.ruff]
select = ["E", "F", "W", "D", "I"]
Expand Down