Skip to content

Commit 435037d

Browse files
authored
Merge pull request #117 from templateflow/maint/pep517-update
MAINT: Finalize migration of package build to PEP517/8
2 parents 5a17078 + 60c1430 commit 435037d

File tree

13 files changed

+225
-129
lines changed

13 files changed

+225
-129
lines changed

.circleci/config.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ jobs:
1313
- checkout:
1414
path: /tmp/src/templateflow
1515

16+
- run:
17+
name: Generate requirements.txt
18+
command: |
19+
python /tmp/src/templateflow/.maint/update_requirements.py
20+
1621
- restore_cache:
1722
keys:
1823
- deps-v10-{{ checksum "/tmp/src/templateflow/requirements.txt"}}-{{ epoch }}
@@ -168,7 +173,8 @@ jobs:
168173
name: Build only this commit
169174
command: |
170175
export PATH="$HOME/.conda/bin:$PATH"
171-
python setup.py --version
176+
python -m pip install "setuptools_scm>=8"
177+
python -m setuptools_scm
172178
make -C docs SPHINXOPTS="-W" BUILDDIR="$HOME/html" CURBRANCH="${CIRCLE_TAG}" html
173179
- store_artifacts:
174180
path: ~/html

.github/workflows/pythonpackage.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,11 @@ jobs:
131131
find ${TEMPLATEFLOW_HOME} >> /tmp/.install-2.txt
132132
diff /tmp/.install.txt /tmp/.install-2.txt
133133
exit $?
134+
135+
flake8:
136+
runs-on: ubuntu-latest
137+
steps:
138+
- uses: actions/checkout@v4
139+
- name: Set up Python
140+
uses: actions/setup-python@v4
141+
- run: pipx run flake8-pyproject templateflow/

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# setuptools_scm
22
templateflow/_version.py
33

4+
# circleci hash checking
5+
requirements.txt
6+
min-requirements.txt
7+
48
# Byte-compiled / optimized / DLL files
59
__pycache__/
610
*.py[cod]
File renamed without changes.

.maint/update_requirements.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
from copy import copy
3+
from pathlib import Path
4+
5+
from packaging.requirements import Requirement, SpecifierSet
6+
7+
try:
8+
from tomllib import loads # Python +3.11
9+
except ImportError:
10+
from pip._vendor.tomli import loads
11+
12+
repo_root = Path(__file__).parent.parent
13+
pyproject = repo_root / 'pyproject.toml'
14+
reqs = repo_root / 'requirements.txt'
15+
min_reqs = repo_root / 'min-requirements.txt'
16+
17+
requirements = [
18+
Requirement(req)
19+
for req in loads(pyproject.read_text())['project']['dependencies']
20+
]
21+
22+
script_name = Path(__file__).relative_to(repo_root)
23+
24+
25+
def to_min(req):
26+
if req.specifier:
27+
req = copy(req)
28+
try:
29+
min_spec = [spec for spec in req.specifier if spec.operator in ('>=', '~=')][0]
30+
except IndexError:
31+
return req
32+
min_spec._spec = ('==',) + min_spec._spec[1:]
33+
req.specifier = SpecifierSet(str(min_spec))
34+
return req
35+
36+
37+
lines = [f'# Auto-generated by {script_name}', '']
38+
39+
# Write requirements
40+
lines[1:-1] = [str(req) for req in requirements]
41+
reqs.write_text('\n'.join(lines))
42+
43+
# Write minimum requirements
44+
lines[1:-1] = [str(to_min(req)) for req in requirements]
45+
min_reqs.write_text('\n'.join(lines))

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ recursive-exclude docs/ *
44

55
recursive-exclude .circleci/ *
66
recursive-exclude .github/ *
7+
recursive-exclude .maint/ *
78

8-
exclude .gitignore .gitattributes .git_archival.txt .travis.yml .zenodo.json codecov.yml update_changes.sh
9+
exclude .gitignore .gitattributes .git_archival.txt .travis.yml .zenodo.json codecov.yml

pyproject.toml

Lines changed: 154 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,164 @@
11
[build-system]
22
requires = [
3-
"setuptools >= 45",
4-
"setuptools_scm >= 6.2",
5-
"nipreps-versions",
3+
"setuptools>=64",
4+
"setuptools_scm>=8",
65
]
76
build-backend = "setuptools.build_meta"
87

98
[tool.setuptools_scm]
10-
write_to = "templateflow/_version.py"
11-
write_to_template = """\
9+
version_file = "templateflow/_version.py"
10+
version_file_template = """\
1211
\"\"\"Version file, automatically generated by setuptools_scm.\"\"\"
1312
__version__ = "{version}"
1413
"""
1514
fallback_version = "0.0"
16-
version_scheme = "nipreps-calver"
15+
# version_scheme = "nipreps-calver"
16+
17+
[project]
18+
name = "templateflow"
19+
description = "TemplateFlow Python Client - TemplateFlow is the Zone of neuroimaging templates."
20+
readme = "README.rst"
21+
authors = [{name = "The NiPreps Developers", email = "[email protected]"}]
22+
classifiers = [
23+
"Development Status :: 3 - Alpha",
24+
"Intended Audience :: Science/Research",
25+
"Topic :: Scientific/Engineering :: Image Recognition",
26+
"License :: OSI Approved :: Apache Software License",
27+
"Programming Language :: Python :: 3.8",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
]
33+
license = {file = "LICENSE"}
34+
requires-python = ">=3.8"
35+
dependencies = [
36+
"pybids >= 0.15.2",
37+
"importlib_resources >= 5.7; python_version < '3.11'",
38+
"requests",
39+
"tqdm",
40+
]
41+
dynamic = ["version"]
42+
43+
[project.urls]
44+
Archive = "https://github.com/templateflow/templateflow"
45+
"Bug Tracker" = "https://github.com/templateflow/python-client/issues"
46+
Home = "https://www.templateflow.org"
47+
Documentation = "https://www.templateflow.org/python-client/"
48+
"Source Code" = "https://github.com/templateflow/python-client"
49+
50+
[project.optional-dependencies]
51+
test = [
52+
"pytest",
53+
"pytest-xdist",
54+
"pytest-cov == 2.5.1",
55+
"coverage",
56+
]
57+
datalad = [
58+
"datalad ~= 0.12.0"
59+
]
60+
doc = [
61+
"nbsphinx",
62+
"packaging",
63+
"pydot>=1.2.3",
64+
"pydotplus",
65+
"sphinx-argparse",
66+
"sphinx ~= 4.0",
67+
"sphinx_rtd_theme >= 0.4.3",
68+
"sphinxcontrib-apidoc",
69+
"sphinx_multiversion",
70+
]
71+
# Aliases
72+
tests = ["templateflow[test]"]
73+
docs = ["templateflow[doc]"]
74+
all = ["templateflow[datalad,doc,test]"]
75+
76+
#
77+
# Developer tool configurations
78+
#
79+
80+
[tool.black]
81+
line-length = 99
82+
skip-string-normalization = true
83+
84+
[tool.isort]
85+
profile = 'black'
86+
87+
[tool.flake8]
88+
max-line-length = "99"
89+
doctests = "False"
90+
exclude = "*build/"
91+
ignore = ["W503", "E203"]
92+
per-file-ignores = [
93+
"**/__init__.py : F401",
94+
"docs/conf.py : E265",
95+
]
96+
97+
[tool.pytest.ini_options]
98+
norecursedirs = [".git"]
99+
addopts = "-svx --doctest-modules"
100+
doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE ELLIPSIS"
101+
env = "PYTHONHASHSEED=0"
102+
filterwarnings = ["ignore::DeprecationWarning"]
103+
junit_family = "xunit2"
104+
105+
[tool.coverage.run]
106+
branch = true
107+
concurrency = 'multiprocessing'
108+
omit = [
109+
'*/tests/*',
110+
'*/conftest.py',
111+
'templateflow/_version.py'
112+
]
113+
114+
[tool.coverage.report]
115+
# Regexes for lines to exclude from consideration
116+
exclude_lines = [
117+
'raise NotImplementedError',
118+
'warnings\.warn',
119+
]
120+
121+
[tool.ruff]
122+
line-length = 99
123+
124+
[tool.ruff.lint]
125+
extend-select = [
126+
"F",
127+
"E",
128+
"W",
129+
"I",
130+
"UP",
131+
"YTT",
132+
"S",
133+
"BLE",
134+
"B",
135+
"A",
136+
# "CPY",
137+
"C4",
138+
"DTZ",
139+
"T10",
140+
# "EM",
141+
"EXE",
142+
"FA",
143+
"ISC",
144+
"ICN",
145+
"PT",
146+
"Q",
147+
]
148+
extend-ignore = [
149+
"S311", # We are not using random for cryptographic purposes
150+
"ISC001",
151+
"S603",
152+
]
153+
154+
[tool.ruff.lint.flake8-quotes]
155+
inline-quotes = "single"
156+
157+
[tool.ruff.lint.extend-per-file-ignores]
158+
"*/test_*.py" = ["S101"]
159+
"fmriprep/utils/debug.py" = ["A002", "T100"]
160+
"docs/conf.py" = ["A001"]
161+
"docs/sphinxext/github_link.py" = ["BLE001"]
162+
163+
[tool.ruff.format]
164+
quote-style = "single"

requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 103 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)