Skip to content

Commit e06e636

Browse files
committedNov 30, 2023
maint: migrate to PEP517/518 packaging
1 parent aa86b0b commit e06e636

12 files changed

+207
-169
lines changed
 

‎.circleci/config.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ jobs:
229229
command: |
230230
export PY3=$( pyenv versions | awk '/^\* 3/ { print $2 }' )
231231
pyenv local $PY3
232-
python3 -m pip install --upgrade setuptools setuptools_scm pip
232+
python3 -m pip install -U build hatch hatchling pip twine docutils
233233
234234
# Get version, update files.
235-
THISVERSION=$( python3 -m setuptools_scm )
235+
THISVERSION=$( python3 -m hatch version | tail -n1 | xargs )
236236
if [[ ${THISVERSION:0:1} == "0" ]] ; then
237237
echo "WARNING: latest git tag could not be found"
238238
echo "Please, make sure you fetch all tags from upstream with"
@@ -255,7 +255,7 @@ jobs:
255255
export PY3=$( pyenv versions | awk '/^\* 3/ { print $2 }' )
256256
pyenv local $PY3
257257
# Get version, update files.
258-
THISVERSION=$( python3 -m setuptools_scm )
258+
THISVERSION=$( python3 -m hatch version | tail -n1 | xargs )
259259
BUILT_VERSION=$( docker run --rm --entrypoint=python nipreps/sdcflows:latest -c "import sdcflows; print(sdcflows.__version__)" )
260260
BUILT_VERSION=${BUILT_VERSION%$'\r'}
261261
echo "VERSION: \"$THISVERSION\""
@@ -376,13 +376,13 @@ jobs:
376376
command: |
377377
python -m venv /tmp/venv
378378
source /tmp/venv/bin/activate
379-
python -m pip install -U pip setuptools setuptools_scm
380-
pip install --no-cache-dir -r docs/requirements.txt
379+
python -m pip install -U build hatch hatchling pip twine docutils
380+
python -m pip install --no-cache-dir -r docs/requirements.txt
381381
- run:
382382
name: Build only this commit
383383
command: |
384384
source /tmp/venv/bin/activate
385-
python -m setuptools_scm
385+
python -m hatch version | tail -n1 | xargs
386386
BRANCH=$( echo $CIRCLE_BRANCH | sed 's+/+_+g' )
387387
make -C docs SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR=${CIRCLE_TAG:-$BRANCH} html
388388
- store_artifacts:
@@ -422,7 +422,7 @@ jobs:
422422
command: |
423423
python -m venv /tmp/buildenv
424424
source /tmp/buildenv/bin/activate
425-
python -m pip install -U build twine setuptools_scm
425+
python3 -m pip install -U build hatch hatchling pip twine docutils
426426
python3 -m build
427427
twine check dist/sdcflows*
428428
- store_artifacts:
@@ -435,7 +435,7 @@ jobs:
435435
name: Validate version
436436
command: |
437437
source /tmp/buildenv/bin/activate
438-
THISVERSION=$( python -m setuptools_scm )
438+
THISVERSION=$( python -m hatch version | tail -n1 | xargs )
439439
python -m pip install dist/*.whl
440440
mkdir empty
441441
cd empty

‎.git_archival.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
ref-names: $Format:%D$
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

‎.gitattributes

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
sdcflows/_version.py export-subst
21
.git_archival.txt export-subst

‎.github/workflows/docs-build-pr.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ jobs:
4646
4747
- name: Install dependencies
4848
run: |
49-
pip install -r docs/requirements.txt
50-
pip install --no-cache-dir "setuptools ~= 45.0" "setuptools_scm[toml] >= 3.4"
51-
python setup.py --version
49+
python -m pip install -U build hatch hatchling pip docutils
50+
python -m pip install -r docs/requirements.txt
51+
python -m hatch version | tail -n1 | xargs
5252
5353
- name: Build docs
5454
run: |

‎.github/workflows/docs-build-update.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ jobs:
4646
4747
- name: Install dependencies
4848
run: |
49-
pip install -r docs/requirements.txt
50-
pip install --no-cache-dir "setuptools ~= 45.0" "setuptools_scm[toml] >= 3.4"
51-
python setup.py --version
49+
python -m pip install -U build hatch hatchling pip docutils
50+
python -m pip install -r docs/requirements.txt
51+
python -m hatch version | tail -n1 | xargs
5252
5353
- name: Build docs
5454
run: |

‎.github/workflows/pythonpackage.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
4646
VERSION=${GITHUB_REF##*/}
4747
else
48-
pip install setuptools_scm
49-
VERSION=$( python -m setuptools_scm )
48+
pip install -U build hatch hatchling pip twine docutils
49+
VERSION=$( python -m hatch version | tail -n1 | xargs )
5050
fi
5151
echo version=$VERSION | tee -a $GITHUB_OUTPUT
5252
@@ -78,7 +78,7 @@ jobs:
7878
runs-on: ubuntu-latest
7979
strategy:
8080
matrix:
81-
python-version: ["3.8", "3.12"]
81+
python-version: ["3.10", "3.12"]
8282
install: [repo, sdist, wheel, editable]
8383

8484
env:

‎.github/workflows/unittests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
strategy:
3636
max-parallel: 5
3737
matrix:
38-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
38+
python-version: ["3.10", "3.11", "3.12"]
3939
deps: ["requirements"]
4040
include:
41-
- python-version: "3.8"
41+
- python-version: "3.10"
4242
deps: "min-requirements"
4343

4444
steps:

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# setuptools-scm
2-
sdcflows/_version.py
2+
_version.py
33

44
# Byte-compiled / optimized / DLL files
55
pip-wheel-metadata

‎MANIFEST.in

-7
This file was deleted.

‎pyproject.toml

+183-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,184 @@
11
[build-system]
2-
requires = ["setuptools >= 42.0", "wheel", "setuptools_scm[toml] >= 3.4"]
3-
4-
[tool.setuptools_scm]
5-
write_to = "sdcflows/_version.py"
6-
write_to_template = """\
7-
\"\"\"Version file, automatically generated by setuptools_scm.\"\"\"
8-
__version__ = "{version}"
9-
"""
10-
fallback_version = "0.0"
2+
requires = ["hatchling", "hatch-vcs", "nipreps-versions"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "sdcflows"
7+
description = "Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes."
8+
readme = "README.rst"
9+
authors = [{name = "The NiPreps Developers", email = "nipreps@gmail.com"}]
10+
classifiers = [
11+
"Development Status :: 4 - Beta",
12+
"Intended Audience :: Science/Research",
13+
"Topic :: Scientific/Engineering :: Image Recognition",
14+
"Topic :: Scientific/Engineering :: Bio-Informatics",
15+
"License :: OSI Approved :: Apache Software License",
16+
"Programming Language :: Python :: 3.10",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
]
20+
license = "Apache-2.0"
21+
requires-python = ">=3.10"
22+
dependencies = [
23+
"attrs >= 20.1.0",
24+
"nibabel >=3.1.0",
25+
"nipype >=1.8.5,<2.0",
26+
"traits <6.4",
27+
"niworkflows >= 1.7.0",
28+
"nitransforms >= 23.0.1",
29+
"numpy >= 1.21.0",
30+
"pybids >= 0.15.1",
31+
"scikit-image >= 0.18",
32+
"scipy >= 1.8.1",
33+
"templateflow",
34+
]
35+
dynamic = ["version"]
36+
37+
[project.urls]
38+
Documentation = "https://www.nipreps.org/sdcflows"
39+
Home = "https://github.com/nipreps/sdcflows"
40+
NiPreps = "https://www.nipreps.org/"
41+
42+
[project.optional-dependencies]
43+
doc = [
44+
"attrs >= 20.1.0",
45+
"furo",
46+
"importlib_resources",
47+
"matplotlib >= 2.2.0",
48+
"nibabel",
49+
"nipype >= 1.5.1",
50+
"traits < 6.4",
51+
"niworkflows ~= 1.6.3",
52+
"numpy",
53+
"packaging",
54+
"pydot >= 1.2.3",
55+
"pydotplus",
56+
"sphinx >= 7.2.2",
57+
"sphinxcontrib-apidoc",
58+
"templateflow"
59+
]
60+
61+
mem = [
62+
"psutil"
63+
]
64+
65+
dev = [
66+
"black",
67+
"pre-commit",
68+
"isort",
69+
"flake8-pyproject",
70+
]
71+
72+
test = [
73+
"coverage",
74+
"pytest",
75+
"pytest-cov",
76+
"pytest-env",
77+
"pytest-xdist"
78+
]
79+
80+
# Aliases
81+
docs = ["sdcflows[doc]"]
82+
tests = ["sdcflows[test]"]
83+
all = ["sdcflows[doc,test,mem,dev,test]"]
84+
85+
[project.scripts]
86+
sdcflows-find-estimators = "sdcflows.cli.find_estimators:main"
87+
88+
#
89+
# Hatch configurations
90+
#
91+
92+
[tool.hatch.metadata]
93+
allow-direct-references = true
94+
95+
[tool.hatch.build.targets.sdist]
96+
exclude = [".git_archival.txt"] # No longer needed in sdist
97+
98+
[tool.hatch.build.targets.wheel]
99+
packages = ["sdcflows"]
100+
# exclude = [
101+
# "sdcflows/tests/data", # Large test data directory
102+
# ]
103+
104+
## The following two sections configure setuptools_scm in the hatch way
105+
106+
[tool.hatch.version]
107+
validate-bump = true
108+
source = "vcs"
109+
raw-options = { version_scheme = "nipreps-calver" }
110+
111+
[tool.hatch.build.hooks.vcs]
112+
version-file = "sdcflows/_version.py"
113+
114+
#
115+
# Developer tool configurations
116+
#
117+
118+
[tool.black]
119+
line-length = 99
120+
target-version = ['py39']
121+
skip-string-normalization = true
122+
exclude = '''
123+
# Directories
124+
/(
125+
\.eggs
126+
| \.git
127+
| \.hg
128+
| \.mypy_cache
129+
| \.tox
130+
| \.venv
131+
| venv
132+
| _build
133+
| build
134+
| dist
135+
)/
136+
'''
137+
138+
[tool.isort]
139+
profile = 'black'
140+
skip_gitignore = true
141+
142+
[tool.flake8]
143+
max-line-length = "99"
144+
doctests = "False"
145+
exclude = "*build/"
146+
ignore = ["W503", "E203"]
147+
per-file-ignores = [
148+
"**/__init__.py : F401",
149+
"docs/conf.py : E265",
150+
]
151+
152+
[tool.pytest.ini_options]
153+
norecursedirs = [".git"]
154+
addopts = "-svx --doctest-modules"
155+
doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE ELLIPSIS"
156+
env = "PYTHONHASHSEED=0"
157+
filterwarnings = ["ignore::DeprecationWarning"]
158+
junit_family = "xunit2"
159+
160+
161+
[tool.coverage.run]
162+
branch = true
163+
concurrency = 'multiprocessing'
164+
omit = [
165+
'*/tests/*',
166+
'*/__init__.py',
167+
'*/conftest.py',
168+
'sdcflows/_version.py'
169+
]
170+
171+
[tool.coverage.report]
172+
# Regexes for lines to exclude from consideration
173+
exclude_lines = [
174+
'raise NotImplementedError',
175+
'warnings\.warn',
176+
]
177+
178+
[tool.codespell]
179+
# nd - import scipy.ndimage as nd
180+
# mapp, reson -- Mapp. and Reson. abbreviations in citation
181+
ignore-words-list = 'nd,mapp,reson'
182+
skip = """
183+
./.git,*.pdf,*.svg,*.min.js,*.ipynb,ORIGINAL_LICENSE,\
184+
./docs/source/_static/example_anatreport.html"""

‎setup.cfg

-113
This file was deleted.

‎setup.py

-18
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.