Skip to content

Commit c536b12

Browse files
authored
Merge pull request #120 from templateflow/maint/hatchling
MAINT: Migrate to hatchling packaging
2 parents 8dd6c2b + 7b85ffa commit c536b12

File tree

7 files changed

+43
-25
lines changed

7 files changed

+43
-25
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
pip install -U pip
3232
pip install -r /tmp/src/templateflow/requirements.txt
3333
pip install datalad
34-
pip install "setuptools>=45" "setuptools_scm >= 6.2" nipreps-versions build twine codecov
34+
pip install -U build hatch hatchling nipreps-versions build twine codecov
3535
3636
- run:
3737
name: Install git and git-annex
@@ -173,8 +173,8 @@ jobs:
173173
name: Build only this commit
174174
command: |
175175
export PATH="$HOME/.conda/bin:$PATH"
176-
python -m pip install "setuptools_scm>=8"
177-
python -m setuptools_scm
176+
python -m pip install -U build hatch hatchling
177+
python -m hatch version
178178
make -C docs SPHINXOPTS="-W" BUILDDIR="$HOME/html" CURBRANCH="${CIRCLE_TAG}" html
179179
- store_artifacts:
180180
path: ~/html

.git_archival.txt

Lines changed: 4 additions & 1 deletion
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$

.github/workflows/pythonpackage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ jobs:
4949
run: |
5050
python -m venv /tmp/buildenv
5151
source /tmp/buildenv/bin/activate
52-
python -m pip install --upgrade setuptools setuptools_scm nipreps-versions
52+
python -m pip install -U build hatch hatchling nipreps-versions
5353
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
5454
TAG=${GITHUB_REF##*/}
5555
fi
56-
THISVERSION=$( python -m setuptools_scm )
56+
THISVERSION=$( python -m hatch version | tail -n1 | xargs )
5757
THISVERSION=${TAG:-$THISVERSION}
5858
echo "Expected VERSION: \"${THISVERSION}\""
5959
echo "version=${THISVERSION}" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# setuptools_scm
2-
templateflow/_version.py
1+
# hatchling
2+
_version.py
33

44
# circleci hash checking
55
requirements.txt

docs/environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ dependencies:
151151
- readline=8.1=h46c0cb4_0
152152
- requests=2.27.1=pyhd8ed1ab_0
153153
- scipy=1.8.0=py39hee8e79c_1
154-
- setuptools=62.1.0=py39hf3d152e_0
155154
- six=1.16.0=pyh6c4a22f_0
156155
- snowballstemmer=2.2.0=pyhd8ed1ab_0
157156
- soupsieve=2.3.1=pyhd8ed1ab_0
@@ -203,5 +202,7 @@ dependencies:
203202
- nipreps-versions==1.0.3
204203
- pandas==1.4.2
205204
- pybids==0.15.2
206-
- setuptools_scm==7.1.0
207205
- sqlalchemy==1.3.24
206+
- hatchling
207+
- hatch-vcs
208+
- nipreps-versions

pyproject.toml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
[build-system]
2-
requires = [
3-
"setuptools>=64",
4-
"setuptools_scm>=8",
5-
]
6-
build-backend = "setuptools.build_meta"
7-
8-
[tool.setuptools_scm]
9-
version_file = "templateflow/_version.py"
10-
version_file_template = """\
11-
\"\"\"Version file, automatically generated by setuptools_scm.\"\"\"
12-
__version__ = "{version}"
13-
"""
14-
fallback_version = "0.0"
15-
# version_scheme = "nipreps-calver"
2+
requires = ["hatchling", "hatch-vcs", "nipreps-versions"]
3+
build-backend = "hatchling.build"
164

175
[project]
186
name = "templateflow"
@@ -73,6 +61,32 @@ tests = ["templateflow[test]"]
7361
docs = ["templateflow[doc]"]
7462
all = ["templateflow[datalad,doc,test]"]
7563

64+
#
65+
# Hatch configurations
66+
#
67+
68+
[tool.hatch.metadata]
69+
allow-direct-references = true
70+
71+
[tool.hatch.build.targets.sdist]
72+
exclude = [".git_archival.txt"] # No longer needed in sdist
73+
74+
[tool.hatch.build.targets.wheel]
75+
packages = ["templateflow"]
76+
# exclude = [
77+
# "templateflow/tests/data", # Large test data directory
78+
# ]
79+
80+
## The following two sections configure setuptools_scm in the hatch way
81+
82+
[tool.hatch.version]
83+
validate-bump = true
84+
source = "vcs"
85+
raw-options = { version_scheme = "nipreps-calver" }
86+
87+
[tool.hatch.build.hooks.vcs]
88+
version-file = "templateflow/_version.py"
89+
7690
#
7791
# Developer tool configurations
7892
#

templateflow/tests/test_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def test_version_scm0(monkeypatch):
10-
"""Retrieve the version via setuptools_scm."""
10+
"""Retrieve the version."""
1111

1212
class _version:
1313
__version__ = '10.0.0'

0 commit comments

Comments
 (0)