Skip to content

Commit 1674e86

Browse files
authored
Merge pull request #181 from nipy/mnt/python-support
MNT: Drop Python 3.7 support, test through 3.11
2 parents 2009ceb + 300ae9d commit 1674e86

File tree

10 files changed

+42
-39
lines changed

10 files changed

+42
-39
lines changed

.github/workflows/pythonpackage.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,30 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: [3.7, 3.8, 3.9]
19+
python-version: ['3.8', '3.9', '3.10', '3.11']
2020

2121
steps:
2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v4
2424
with:
2525
python-version: ${{ matrix.python-version }}
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727
with:
2828
fetch-depth: 0
29-
- name: Build in confined, updated environment and interpolate version
29+
- name: Build package
3030
run: |
31-
python -m venv /tmp/buildenv
32-
source /tmp/buildenv/bin/activate
33-
python -m pip install -U setuptools pip wheel twine docutils
34-
python setup.py sdist bdist_wheel
35-
python -m twine check dist/nitransforms*
31+
pipx run build
32+
- name: Determine expected version
33+
run: |
34+
python -m venv /tmp/getversion
35+
source /tmp/getversion/bin/activate
36+
python -m pip install setuptools_scm
3637
3738
# Interpolate version
3839
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
3940
TAG=${GITHUB_REF##*/}
4041
fi
41-
THISVERSION=$( python setup.py --version )
42+
THISVERSION=$( python -m setuptools_scm )
4243
THISVERSION=${TAG:-$THISVERSION}
4344
echo "Expected VERSION: \"${THISVERSION}\""
4445
echo "THISVERSION=${THISVERSION}" >> ${GITHUB_ENV}
@@ -47,7 +48,7 @@ jobs:
4748
run: |
4849
python -m venv /tmp/install_sdist
4950
source /tmp/install_sdist/bin/activate
50-
python -m pip install --upgrade pip wheel
51+
python -m pip install --upgrade pip
5152
python -m pip install dist/nitransforms*.tar.gz
5253
INSTALLED_VERSION=$(python -c 'import nitransforms; print(nitransforms.__version__, end="")')
5354
echo "VERSION: \"${THISVERSION}\""
@@ -58,7 +59,7 @@ jobs:
5859
run: |
5960
python -m venv /tmp/install_wheel
6061
source /tmp/install_wheel/bin/activate
61-
python -m pip install --upgrade pip wheel
62+
python -m pip install --upgrade pip
6263
python -m pip install dist/nitransforms*.whl
6364
INSTALLED_VERSION=$(python -c 'import nitransforms; print(nitransforms.__version__, end="")')
6465
echo "INSTALLED: \"${INSTALLED_VERSION}\""
@@ -89,10 +90,9 @@ jobs:
8990
if: "!contains(github.event.head_commit.message, '[skip ci]')"
9091
runs-on: ubuntu-latest
9192
steps:
92-
- uses: actions/checkout@v2
93+
- uses: actions/checkout@v3
9394
- name: Set up Python 3.7
94-
uses: actions/setup-python@v1
95+
uses: actions/setup-python@v4
9596
with:
9697
python-version: 3.7
97-
- run: pip install flake8
98-
- run: flake8 nitransforms/
98+
- run: pipx run flake8 nitransforms

.github/workflows/travis.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ jobs:
1111
strategy:
1212
max-parallel: 5
1313
matrix:
14-
python-version: [3.7, 3.8, 3.9]
14+
python-version: ['3.8', '3.9', '3.10', '3.11']
1515

1616
steps:
1717
- name: Git settings (pacify DataLad)
1818
run: |
1919
git config --global user.name 'NiPreps Bot'
2020
git config --global user.email '[email protected]'
2121
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@v4
2323
with:
2424
python-version: ${{ matrix.python-version }}
25-
- uses: actions/cache@v2
25+
- uses: actions/cache@v3
2626
id: conda
2727
with:
2828
path: |
@@ -33,10 +33,10 @@ jobs:
3333
python-${{ matrix.python-version }}-
3434
- name: Install DataLad
3535
run: |
36-
$CONDA/bin/conda install -c conda-forge git-annex datalad pip codecov pytest
36+
$CONDA/bin/conda install -c conda-forge git-annex datalad pip pytest
3737
$CONDA/bin/python -m pip install datalad-osf
3838
39-
- uses: actions/cache@v2
39+
- uses: actions/cache@v3
4040
with:
4141
path: ${{ env.TEST_DATA_HOME }}
4242
key: data-cache-v2
@@ -53,7 +53,7 @@ jobs:
5353
$CONDA/bin/datalad update --merge -d nitransforms-tests/
5454
$CONDA/bin/datalad get -d nitransforms-tests/
5555
56-
- uses: actions/checkout@v2
56+
- uses: actions/checkout@v3
5757
- name: Install minimal dependencies
5858
run: |
5959
$CONDA/bin/pip install .[tests]
@@ -62,5 +62,6 @@ jobs:
6262
$CONDA/bin/pytest -v --cov nitransforms --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules nitransforms/
6363
6464
- name: Submit code coverage
65-
run: |
66-
$CONDA/bin/python -m codecov --flags travis --file cov.xml -e $GITHUB_RUN_NUMBER
65+
uses: codecov/codecov-action@v3
66+
with:
67+
files: cov.xml

nitransforms/cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def cli_apply(pargs):
4545
cval=pargs.cval,
4646
prefilter=pargs.prefilter,
4747
)
48-
moved.to_filename(pargs.out or "nt_{}".format(os.path.basename(pargs.moving)))
48+
moved.to_filename(pargs.out or f"nt_{os.path.basename(pargs.moving)}")
4949

5050

5151
def get_parser():

nitransforms/io/lta.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def set_type(self, new_type):
176176
return
177177

178178
raise NotImplementedError(
179-
"Converting {0} to {1} is not yet available".format(
179+
"Converting {} to {} is not yet available".format(
180180
transform_codes.label[current], transform_codes.label[new_type]
181181
)
182182
)
@@ -334,7 +334,7 @@ def to_string(self):
334334
code = int(self["type"])
335335
header = [
336336
"# LTA-array file created by NiTransforms",
337-
"type = {} # {}".format(code, transform_codes.label[code]),
337+
f"type = {code} # {transform_codes.label[code]}",
338338
"nxforms = {}".format(self["nxforms"]),
339339
]
340340
xforms = [xfm.to_string(partial=True) for xfm in self._xforms]

nitransforms/nonlinear.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class BSplineFieldTransform(TransformBase):
241241

242242
def __init__(self, coefficients, reference=None, order=3):
243243
"""Create a smooth deformation field using B-Spline basis."""
244-
super(BSplineFieldTransform, self).__init__()
244+
super().__init__()
245245
self._order = order
246246

247247
coefficients = _ensure_image(coefficients)

nitransforms/tests/test_io.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_Linear_common(tmpdir, data_path, sw, image_orientation, get_testdata):
204204
with pytest.raises(TransformFileError):
205205
factory.from_string("")
206206

207-
fname = "affine-%s.%s%s" % (image_orientation, sw, ext)
207+
fname = f"affine-{image_orientation}.{sw}{ext}"
208208

209209
# Test the transform loaders are implemented
210210
xfm = factory.from_filename(data_path / fname)
@@ -262,7 +262,7 @@ def test_LinearList_common(tmpdir, data_path, sw, image_orientation, get_testdat
262262

263263
tflist1 = factory(mats)
264264

265-
fname = "affine-%s.%s%s" % (image_orientation, sw, ext)
265+
fname = f"affine-{image_orientation}.{sw}{ext}"
266266

267267
with pytest.raises(FileNotFoundError):
268268
factory.from_filename(fname)
@@ -305,7 +305,7 @@ def test_ITKLinearTransform(tmpdir, testdata_path):
305305

306306
# Test to_filename(textfiles)
307307
itkxfm.to_filename("textfile.tfm")
308-
with open("textfile.tfm", "r") as f:
308+
with open("textfile.tfm") as f:
309309
itkxfm2 = itk.ITKLinearTransform.from_fileobj(f)
310310
assert np.allclose(itkxfm["parameters"], itkxfm2["parameters"])
311311

nitransforms/tests/test_linear.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_linear_save(tmpdir, data_path, get_testdata, image_orientation, sw_tool
226226
elif sw_tool == "fs":
227227
ext = ".lta"
228228

229-
xfm_fname1 = "M.%s%s" % (sw_tool, ext)
229+
xfm_fname1 = f"M.{sw_tool}{ext}"
230230
xfm.to_filename(xfm_fname1, fmt=sw_tool)
231231

232232
xfm_fname2 = str(data_path / "affine-%s.%s%s") % (image_orientation, sw_tool, ext)
@@ -257,7 +257,7 @@ def test_apply_linear_transform(tmpdir, get_testdata, get_testmask, image_orient
257257
msk.to_filename("mask.nii.gz")
258258

259259
# Write out transform file (software-dependent)
260-
xfm_fname = "M.%s%s" % (sw_tool, ext)
260+
xfm_fname = f"M.{sw_tool}{ext}"
261261
# Change reference dataset for AFNI & oblique
262262
if (sw_tool, image_orientation) == ("afni", "oblique"):
263263
io.afni.AFNILinearTransform.from_ras(
@@ -278,7 +278,7 @@ def test_apply_linear_transform(tmpdir, get_testdata, get_testmask, image_orient
278278
# skip test if command is not available on host
279279
exe = cmd.split(" ", 1)[0]
280280
if not shutil.which(exe):
281-
pytest.skip("Command {} not found on host".format(exe))
281+
pytest.skip(f"Command {exe} not found on host")
282282

283283
# resample mask
284284
exit_code = check_call([cmd], shell=True)

nitransforms/tests/test_nonlinear.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_displacements_field1(
158158
# skip test if command is not available on host
159159
exe = cmd.split(" ", 1)[0]
160160
if not shutil.which(exe):
161-
pytest.skip("Command {} not found on host".format(exe))
161+
pytest.skip(f"Command {exe} not found on host")
162162

163163
# resample mask
164164
exit_code = check_call([cmd], shell=True)
@@ -219,7 +219,7 @@ def test_displacements_field2(tmp_path, testdata_path, sw_tool):
219219
# skip test if command is not available on host
220220
exe = cmd.split(" ", 1)[0]
221221
if not shutil.which(exe):
222-
pytest.skip("Command {} not found on host".format(exe))
222+
pytest.skip(f"Command {exe} not found on host")
223223

224224
exit_code = check_call([cmd], shell=True)
225225
assert exit_code == 0

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[build-system]
2-
requires = ["setuptools >= 42.0", "wheel", "setuptools_scm[toml] >= 3.4", "setuptools_scm_git_archive"]
2+
requires = ["setuptools >= 45", "setuptools_scm[toml]>=6.2"]
3+
build-backend = "setuptools.build_meta"
34

45
[tool.setuptools_scm]
56
write_to = "nitransforms/_version.py"

setup.cfg

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ classifiers =
66
Intended Audience :: Science/Research
77
Topic :: Scientific/Engineering :: Image Recognition
88
License :: OSI Approved :: BSD License
9-
Programming Language :: Python :: 3.7
109
Programming Language :: Python :: 3.8
1110
Programming Language :: Python :: 3.9
11+
Programming Language :: Python :: 3.10
12+
Programming Language :: Python :: 3.11
1213
description = NiTransforms -- Neuroimaging spatial transforms in Python.
1314
license = MIT License
1415
long_description = file:README.md
@@ -20,7 +21,7 @@ project_urls =
2021
url = https://github.com/nipy/nitransforms
2122

2223
[options]
23-
python_requires = >= 3.7
24+
python_requires = >= 3.8
2425
install_requires =
2526
numpy >= 1.21.0
2627
scipy >= 1.6.0

0 commit comments

Comments
 (0)