Skip to content

Commit

Permalink
ENH: Use hatch and automated releases (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Jul 22, 2024
1 parent f9d4871 commit cb6e342
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 80 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Upload a Python Package using Twine when a release is created

name: Build
on: # yamllint disable-line rule:truthy
release:
types: [published]
push:
branches: ["main", "maint/*"]
pull_request:
branches: ["main", "maint/*"]

permissions:
contents: read

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- run: python -m build --sdist --wheel
- run: twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist

pypi-upload:
needs: package
runs-on: ubuntu-latest
if: github.event_name == 'release'
permissions:
id-token: write # for trusted publishing
environment:
name: pypi
url: https://pypi.org/p/mne-nirs
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release'
9 changes: 8 additions & 1 deletion mne_nirs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from ._version import __version__
from importlib.metadata import version

try:
__version__ = version("mne-nirs")
except Exception:
__version__ = "0.0.0"
del version


from . import channels
from . import datasets
Expand Down
1 change: 0 additions & 1 deletion mne_nirs/_version.py

This file was deleted.

6 changes: 4 additions & 2 deletions mne_nirs/io/snirf/_snirf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def _add_metadata_tags(raw, nirs):
metadata_tags.create_dataset("FrequencyUnit", data=_str_encode("Hz"))

# Add non standard (but allowed) custom metadata tags
if "birthday" in raw.info["subject_info"]:
birthday = datetime.date(*raw.info["subject_info"]["birthday"])
if raw.info["subject_info"].get("birthday", None) is not None:
birthday = raw.info["subject_info"]["birthday"]
if isinstance(birthday, tuple):
birthday = datetime.date(*birthday)
birthstr = birthday.strftime("%Y-%m-%d")
metadata_tags.create_dataset("DateOfBirth", data=[_str_encode(birthstr)])
for key in ("first", "middle", "last"):
Expand Down
71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,74 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "mne-nirs"
description = "An MNE compatible package for processing near-infrared spectroscopy data"
dynamic = ["version"]
maintainers = [{ name = "Robert Luke", email = "[email protected]" }]
license = { text = "BSD-3-Clause" }
readme = { file = "README.rst", content-type = "text/x-rst" }

requires-python = ">=3.9"
keywords = [
"neuroscience",
"neuroimaging",
"MEG",
"EEG",
"ECoG",
"fNIRS",
"brain",
]
classifiers = [
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
]
scripts = { mne = "mne.commands.utils:main" }
dependencies = [
"numpy>=1.11.3,<3",
"scipy>=0.17.1",
"mne>=1.0",
"h5io>=0.1.7",
"nilearn>=0.9",
"seaborn",
]


[project.urls]
Homepage = "https://mne.tools/mne-nirs/"
Download = "https://github.com/mne-tools/mne-nirs"
"Source Code" = "https://github.com/mne-tools/mne-nirs/"

[project.optional-dependencies]
tests = ["pytest", "pytest-cov"]
docs = ["sphinx", "sphinx-gallery", "sphinx_rtd_theme", "numpydoc", "matplotlib"]

[tool.hatch.build]
exclude = [
"/.*",
"/*.yml",
"/*.txt",
"/doc",
"/examples",
"/tools",
"/CONTRIBUTING.md",
"/Dockerfile",
] # tracked by git, but we don't want to ship those files

[tool.hatch.version]
source = "vcs"
raw-options = { version_scheme = "release-branch-semver" }

[tool.codespell]
ignore-words = ".github/workflows/ignore_words.txt"
builtin = "clear,rare,informal,names,usage"
Expand Down
76 changes: 0 additions & 76 deletions setup.py

This file was deleted.

0 comments on commit cb6e342

Please sign in to comment.