Skip to content

Commit 983e359

Browse files
authored
ENH: Modernize package setup (#56)
* ENH: Modernize package setup Modernize packate setup: - Adopt PEP621 to store project metadata in `pyproject.toml`. Remove the `setup.py` file. - Adopt PEP518 to specify the build system requirements for the package. - Adopt PEP631 to specify the package dependencies in the `pyproject.toml` file, and remove the `requirements,txt`. - Transition to `setuptools_scm` dynamic versioning system. Change the GHA package test workflow file accordingly. Add the `_version.py` file to the `.gitignore` file list. Documentation: https://peps.python.org/pep-0621/ https://packaging.python.org/en/latest/specifications/pyproject-toml/#pyproject-toml-spec https://peps.python.org/pep-0518/ https://peps.python.org/pep-0631/ https://setuptools.pypa.io/en/latest/index.html https://setuptools-scm.readthedocs.io/en/latest/ * ENH: Require a more recent version of `NumPy` Require a more recent version of `NumPy`: require any version greater or equal to 1.19.5 but lower than 2.0.0. `NumPy` 1.19.5 was the first release supporting Python 3.9. Fixes: ``` from distutils.msvccompiler import get_build_version as get_build_msvc_version ModuleNotFoundError: No module named 'distutils.msvccompiler' ``` raised for example at: https://github.com/demianw/tract_querier/actions/runs/12145326696/job/33866697673#step:5:806
1 parent 7b3e979 commit 983e359

File tree

5 files changed

+74
-70
lines changed

5 files changed

+74
-70
lines changed

.github/workflows/test_package.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Set min. dependencies
3737
if: matrix.requires == 'minimal'
3838
run: |
39-
python -c "req = open('requirements.txt').read().replace('>=', '==') ; open('requirements.txt', 'w').write(req)"
39+
sed -E -i '/dependencies = \[/,/]/ s/>=([^,<]+)/==\1/g' pyproject.toml
4040
4141
# - name: Cache pip
4242
# uses: actions/cache@v2
@@ -52,13 +52,11 @@ jobs:
5252
# if: steps.cache.outputs.cache-hit != 'true'
5353
run: |
5454
python -m pip install --upgrade --user pip setuptools coverage
55-
pip install -r requirements.txt
55+
pip install -e .[test]
5656
python --version
5757
pip --version
5858
pip list
5959
6060
- name: Run tests
6161
run: |
62-
# tox --sitepackages
63-
python setup.py build_ext --inplace
6462
nosetests -v

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ htmlcov
1414
.idea
1515
build
1616
cover
17+
18+
# Version file
19+
tract_querier/_version.py

pyproject.toml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[build-system]
2+
requires = [
3+
"setuptools",
4+
"setuptools_scm",
5+
"wheel",
6+
]
7+
build-backend = "setuptools.build_meta"
8+
9+
[project]
10+
name = "tract_querier"
11+
description = "WMQL: Query language for automatic tract extraction from full-brain tractographies with a registered template on top of them"
12+
readme = "README.md"
13+
license = {file = "license.rst"}
14+
authors = [
15+
{name = "Demian Wassermann"}, {email = "[email protected]"}
16+
]
17+
classifiers = [
18+
"Intended Audience :: Science/Research",
19+
"Programming Language :: Python :: 3",
20+
"Topic :: Scientific/Engineering",
21+
"Operating System :: Microsoft :: Windows",
22+
"Operating System :: POSIX",
23+
"Operating System :: Unix",
24+
"Operating System :: MacOS"
25+
]
26+
dependencies = [
27+
"numpy>=1.19.5,<2.0.0",
28+
"nibabel>=2.0,<3.0",
29+
"six>=1.10",
30+
"vtk"
31+
]
32+
dynamic = ["version"]
33+
requires-python = ">=3.9"
34+
35+
[project.optional-dependencies]
36+
doc = [
37+
"numpydoc",
38+
]
39+
test = [
40+
"coverage",
41+
"nose",
42+
]
43+
44+
[project.urls]
45+
documentation = "http://demianw.github.io/tract_querier"
46+
homepage = "http://demianw.github.io/tract_querier"
47+
repository = "https://github.com/demianw/tract_querier"
48+
49+
[project.scripts]
50+
tract_math = "scripts.tract_math:main"
51+
tract_querier = "scripts.tract_querier:main"
52+
53+
[tool.setuptools]
54+
include-package-data = true
55+
56+
[tool.setuptools.package-data]
57+
tract_querier = [
58+
"data/FreeSurfer.qry",
59+
"data/JHU_MNI_SS_WMPM_Type_I.qry",
60+
"data/JHU_MNI_SS_WMPM_Type_II.qry",
61+
"data/freesurfer_queries.qry",
62+
"data/mori_queries.qry",
63+
]
64+
65+
[tool.setuptools.packages]
66+
find = {} # Scanning implicit namespaces is active by default
67+
68+
[tool.setuptools_scm]
69+
write_to = "tract_querier/_version.py"

requirements.txt

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

setup.py

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

0 commit comments

Comments
 (0)