Skip to content

Commit

Permalink
MRG: Use hatchling as build backend (#1204)
Browse files Browse the repository at this point in the history
* Use hatchling as build backend

Also dynamically generate version number via hatch-vcs

Addresses #1174

* Add excludes

* Add .git_archival.txt

* Remove MANIFEST.in

* Update Makefile

* Fix filename

* Consistency

* Remove check-manifest

* Remove deps

* Update changelog

* Update formatting
  • Loading branch information
hoechenberger authored Dec 7, 2023
1 parent e6ca823 commit ee9efd9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 62 deletions.
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/*
8 changes: 8 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ Detailed list of changes

- nothing yet

⚕️ Code health
^^^^^^^^^^^^^^

- 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`)


:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

.. include:: authors.rst
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"

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`
]

# 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

0 comments on commit ee9efd9

Please sign in to comment.