From 58122a84a177633410973b06522e591727d82904 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sun, 4 Sep 2022 10:42:00 -0400 Subject: [PATCH 1/3] MNT: Move most setup metadata into pyproject.toml --- pyproject.toml | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 58 ----------------------------------------------- setup.py | 33 +++++++++++++++------------ 3 files changed, 80 insertions(+), 72 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..39329568bf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta:__legacy__" + +[project] +name = "nibabel" +description = "Access a multitude of neuroimaging data formats" +authors = [ + { name = "nibabel developers", email = "neuroimaging@python.org" }, +] +maintainers = [ + { name = "Christopher Markiewicz" }, +] +readme = "README.rst" +license = { text="MIT License" } +requires-python = ">=3.7" +dependencies = ["numpy >=1.17", "packaging >=17", "setuptools"] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Scientific/Engineering", +] +# Version from versioneer +# optional-dependencies from setup.cfg (using ConfigParser features) +dynamic = ["version", "optional-dependencies"] + +[project.urls] +"Homepage" = "https://nipy.org/nibabel" +"Development" = "https://github.com/nipy/nibabel" + +[project.scripts] +nib-conform = "nibabel.cmdline.conform:main" +nib-convert = "nibabel.cmdline.convert:main" +nib-ls = "nibabel.cmdline.ls:main" +nib-dicomfs = "nibabel.cmdline.dicomfs:main" +nib-diff = "nibabel.cmdline.diff:main" +nib-stats = "nibabel.cmdline.stats:main" +nib-nifti-dx = "nibabel.cmdline.nifti_dx:main" +nib-tck2trk = "nibabel.cmdline.tck2trk:main" +nib-trk2tck = "nibabel.cmdline.trk2tck:main" +nib-roi = "nibabel.cmdline.roi:main" +parrec2nii = "nibabel.cmdline.parrec2nii:main" + +[tool.setuptools] +platforms = ["OS Independent"] +provides = ["nibabel", "nisext"] +zip-safe = false + +[tool.setuptools.packages] +find = {} + +[tool.setuptools.package-data] +nibabel = ["tests/data/*", "*/tests/data/*", "benchmarks/pytest.benchmark.ini"] diff --git a/setup.cfg b/setup.cfg index 47a7317088..03e6e41171 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,41 +1,3 @@ -[metadata] -name = nibabel -url = https://nipy.org/nibabel -download_url = https://github.com/nipy/nibabel -author = nibabel developers -author_email = neuroimaging@python.org -maintainer = Chris Markiewicz -maintainer_email = neuroimaging@python.org -classifiers = - Development Status :: 4 - Beta - Environment :: Console - Intended Audience :: Science/Research - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Topic :: Scientific/Engineering -license = MIT License -description = Access a multitude of neuroimaging data formats -long_description = file:README.rst -long_description_content_type = text/x-rst; charset=UTF-8 -platforms = OS Independent -provides = - nibabel - nisext - -[options] -python_requires = >=3.7 -install_requires = - numpy >=1.17 - packaging >=17.0 - setuptools -zip_safe = False -packages = find: - [options.extras_require] dicom = pydicom >=1.0.0 @@ -74,26 +36,6 @@ all = %(test)s %(zstd)s -[options.entry_points] -console_scripts = - nib-conform=nibabel.cmdline.conform:main - nib-convert=nibabel.cmdline.convert:main - nib-ls=nibabel.cmdline.ls:main - nib-dicomfs=nibabel.cmdline.dicomfs:main - nib-diff=nibabel.cmdline.diff:main - nib-stats=nibabel.cmdline.stats:main - nib-nifti-dx=nibabel.cmdline.nifti_dx:main - nib-tck2trk=nibabel.cmdline.tck2trk:main - nib-trk2tck=nibabel.cmdline.trk2tck:main - nib-roi=nibabel.cmdline.roi:main - parrec2nii=nibabel.cmdline.parrec2nii:main - -[options.package_data] -nibabel = - tests/data/* - */tests/data/* - benchmarks/pytest.benchmark.ini - [flake8] max-line-length = 100 ignore = D100,D101,D102,D103,D104,D105,D200,D201,D202,D204,D205,D208,D209,D210,D300,D301,D400,D401,D403,E24,E121,E123,E126,E226,E266,E402,E704,E731,F821,I100,I101,I201,N802,N803,N804,N806,W503,W504,W605 diff --git a/setup.py b/setup.py index 29fb3642da..4b9bde35b0 100755 --- a/setup.py +++ b/setup.py @@ -7,22 +7,27 @@ # copyright and license terms. # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## -"""Build helper.""" +""" +Setuptools entrypoint -import sys +This file is a basic stub needed to integrate with versioneer, which allows the +version to be retrieved from git and set statically in a built package. + +This file should not be run directly. To install, use: + + pip install . + +To build a package for distribution, use: + + pip install --upgrade build + python -m build + +""" from setuptools import setup import versioneer -# Give setuptools a hint to complain if it's too old a version -# 30.3.0 allows us to put most metadata in setup.cfg -# Should match pyproject.toml -SETUP_REQUIRES = ['setuptools >= 30.3.0'] -# This enables setuptools to install wheel on-the-fly -SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else [] - -if __name__ == "__main__": - setup(name='nibabel', - setup_requires=SETUP_REQUIRES, - version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass()) +setup( + version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), +) From 58c86855d4c050d35bbcd3eb6114b6ff5c5be695 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sun, 4 Sep 2022 10:59:54 -0400 Subject: [PATCH 2/3] MNT: Mark as stable --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 39329568bf..01d06cdfbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ license = { text="MIT License" } requires-python = ">=3.7" dependencies = ["numpy >=1.17", "packaging >=17", "setuptools"] classifiers = [ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", From 7ee63272b2e346e4d0c3c1f790c64ba737ddc31f Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sun, 4 Sep 2022 15:15:49 -0400 Subject: [PATCH 3/3] MNT: Build requirements files from pyproject.toml --- min-requirements.txt | 2 +- requirements.txt | 2 +- tools/update_requirements.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/min-requirements.txt b/min-requirements.txt index ac8baf97f6..8308f6e076 100644 --- a/min-requirements.txt +++ b/min-requirements.txt @@ -1,4 +1,4 @@ # Auto-generated by tools/update_requirements.py numpy ==1.17 -packaging ==17.0 +packaging ==17 setuptools diff --git a/requirements.txt b/requirements.txt index 5466c4e508..2c77ae1e0d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ # Auto-generated by tools/update_requirements.py numpy >=1.17 -packaging >=17.0 +packaging >=17 setuptools diff --git a/tools/update_requirements.py b/tools/update_requirements.py index 551424994c..b167438c6f 100755 --- a/tools/update_requirements.py +++ b/tools/update_requirements.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import sys -from configparser import ConfigParser +import tomli from pathlib import Path if sys.version_info < (3, 6): @@ -8,13 +8,13 @@ sys.exit(1) repo_root = Path(__file__).parent.parent -setup_cfg = repo_root / "setup.cfg" +pyproject_toml = repo_root / "pyproject.toml" reqs = repo_root / "requirements.txt" min_reqs = repo_root / "min-requirements.txt" -config = ConfigParser() -config.read(setup_cfg) -requirements = config.get("options", "install_requires").strip().splitlines() +with open(pyproject_toml, 'rb') as fobj: + config = tomli.load(fobj) +requirements = config["project"]["dependencies"] script_name = Path(__file__).relative_to(repo_root)