Skip to content

Commit 19ec7f3

Browse files
authored
Merge pull request #764 from effigies/maint/setuptools
MAINT: Move fully to setuptools
2 parents 935079b + 2345bb4 commit 19ec7f3

File tree

9 files changed

+103
-159
lines changed

9 files changed

+103
-159
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ matrix:
3333
# Absolute minimum dependencies
3434
- python: 2.7
3535
env:
36-
- DEPENDS="numpy==1.8"
36+
- DEPENDS="numpy==1.8 setuptools==30.3.0"
3737
# Absolute minimum dependencies
3838
- python: 2.7
3939
env:

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ recursive-include tools *
66
# put this stuff back into setup.py (package_data) once I'm enlightened
77
# enough to accomplish this herculean task
88
recursive-include nibabel/tests/data *
9+
recursive-include nibabel/externals/tests/data *
910
recursive-include nibabel/nicom/tests/data *
1011
recursive-include nibabel/gifti/tests/data *
1112
include nibabel/COMMIT_INFO.txt

doc/source/conf.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
import sys
2323
import os
24+
try:
25+
from configparser import ConfigParser
26+
except ImportError:
27+
from ConfigParser import ConfigParser # PY2
2428

2529
# Check for external Sphinx extensions we depend on
2630
try:
@@ -53,7 +57,15 @@
5357

5458
# Write long description from info
5559
with open('_long_description.inc', 'wt') as fobj:
56-
fobj.write(rel['LONG_DESCRIPTION'])
60+
fobj.write(rel['long_description'])
61+
62+
# Load metadata from setup.cfg
63+
config = ConfigParser()
64+
config.read(os.path.join('..', '..', 'setup.cfg'))
65+
try:
66+
metadata = config['metadata']
67+
except AttributeError:
68+
metadata = dict(config.items('metadata')) # PY2
5769

5870
# Add any Sphinx extension module names here, as strings. They can be
5971
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
@@ -87,7 +99,7 @@
8799

88100
# General information about the project.
89101
project = u'NiBabel'
90-
copyright = u'2006-2019, %(MAINTAINER)s <%(AUTHOR_EMAIL)s>' % rel
102+
copyright = u'2006-2019, %(maintainer)s <%(author_email)s>' % metadata
91103

92104
# The version info for the project you're documenting, acts as replacement for
93105
# |version| and |release|, also used in various other places throughout the

nibabel/info.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ def cmp_pkg_version(version_str, pkg_version_str=__version__):
8484
else _cmp(extra, pkg_extra))
8585

8686

87-
CLASSIFIERS = ["Development Status :: 4 - Beta",
88-
"Environment :: Console",
89-
"Intended Audience :: Science/Research",
90-
"License :: OSI Approved :: MIT License",
91-
"Operating System :: OS Independent",
92-
"Programming Language :: Python",
93-
"Topic :: Scientific/Engineering"]
94-
95-
description = 'Access a multitude of neuroimaging data formats'
96-
9787
# Note: this long_description is the canonical place to edit this text.
9888
# It also appears in README.rst, but it should get there by running
9989
# ``tools/refresh_readme.py`` which pulls in this version.
@@ -184,33 +174,4 @@ def cmp_pkg_version(version_str, pkg_version_str=__version__):
184174
.. _Digital Object Identifier: https://en.wikipedia.org/wiki/Digital_object_identifier
185175
"""
186176

187-
# versions for dependencies. Check these against:
188-
# doc/source/installation.rst
189-
# requirements.txt
190-
# .travis.yml
191-
NUMPY_MIN_VERSION = '1.8'
192-
PYDICOM_MIN_VERSION = '0.9.9'
193-
SIX_MIN_VERSION = '1.3'
194-
195-
# Main setup parameters
196-
NAME = 'nibabel'
197-
MAINTAINER = "Chris Markiewicz"
198-
MAINTAINER_EMAIL = "[email protected]"
199-
DESCRIPTION = description
200-
LONG_DESCRIPTION = long_description
201-
URL = "http://nipy.org/nibabel"
202-
DOWNLOAD_URL = "https://github.com/nipy/nibabel"
203-
LICENSE = "MIT license"
204-
CLASSIFIERS = CLASSIFIERS
205-
AUTHOR = "nibabel developers"
206-
AUTHOR_EMAIL = "[email protected]"
207-
PLATFORMS = "OS Independent"
208-
MAJOR = _version_major
209-
MINOR = _version_minor
210-
MICRO = _version_micro
211-
ISRELEASE = _version_extra == ''
212177
VERSION = __version__
213-
PROVIDES = ["nibabel", 'nisext']
214-
REQUIRES = ["numpy>=%s" % NUMPY_MIN_VERSION,
215-
"six>=%s" % SIX_MIN_VERSION,
216-
'bz2file; python_version < "3.0"']

nibabel/tests/scriptrunner.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ def run_command(self, cmd, check_code=True):
129129
# the script through the Python interpreter
130130
cmd = [sys.executable,
131131
pjoin(self.local_script_dir, cmd[0])] + cmd[1:]
132-
elif os.name == 'nt':
133-
# Need .bat file extension for windows
134-
cmd[0] += '.bat'
135132
if os.name == 'nt':
136133
# Quote any arguments with spaces. The quotes delimit the arguments
137134
# on Windows, and the arguments might be file paths with spaces.

setup.cfg

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[metadata]
2+
name = nibabel
3+
url = https://nipy.org/nibabel
4+
download_url = https://github.com/nipy/nibabel
5+
author = nibabel developers
6+
author_email = [email protected]
7+
maintainer = Chris Markiewicz
8+
maintainer_email = [email protected]
9+
classifiers =
10+
Development Status :: 4 - Beta
11+
Environment :: Console
12+
Intended Audience :: Science/Research
13+
License :: OSI Approved :: MIT License
14+
Operating System :: OS Independent
15+
Programming Language :: Python
16+
Programming Language :: Python :: 2.7
17+
Programming Language :: Python :: 3.4
18+
Programming Language :: Python :: 3.5
19+
Programming Language :: Python :: 3.6
20+
Programming Language :: Python :: 3.7
21+
Topic :: Scientific/Engineering
22+
license = MIT License
23+
description = Access a multitude of neuroimaging data formats
24+
long_description = file:README.rst
25+
long_description_content_type = text/x-rst; charset=UTF-8
26+
platforms = OS Independent
27+
provides =
28+
nibabel
29+
nisext
30+
31+
[options]
32+
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
33+
install_requires =
34+
numpy >=1.8
35+
six >=1.3
36+
bz2file ; python_version < "3.0"
37+
tests_require = nose
38+
test_suite = nose.collector
39+
zip_safe = False
40+
packages = find:
41+
include_package_data = True
42+
43+
[options.extras_require]
44+
dicom =
45+
dicom >=0.9.9
46+
doc =
47+
sphinx >=0.3
48+
test =
49+
nose >=0.10.1
50+
all =
51+
%(dicom)s
52+
%(doc)s
53+
%(test)s
54+
55+
[options.entry_points]
56+
console_scripts =
57+
nib-ls=nibabel.cmdline.ls:main
58+
nib-dicomfs=nibabel.cmdline.dicomfs:main
59+
nib-diff=nibabel.cmdline.diff:main
60+
nib-nifti-dx=nibabel.cmdline.nifti_dx:main
61+
nib-tck2trk=nibabel.cmdline.tck2trk:main
62+
nib-trk2tck=nibabel.cmdline.trk2tck:main
63+
parrec2nii=nibabel.cmdline.parrec2nii:main
64+
65+
[options.package_data]
66+
nibabel =
67+
tests/data/*
68+
*/tests/data/*
69+
70+
[flake8]
71+
max-line-length = 100
72+
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
73+
exclude =
74+
*test*
75+
*sphinx*
76+
nibabel/externals/*
77+
*/__init__.py
78+

setup.py

Lines changed: 8 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -10,116 +10,16 @@
1010
"""Build helper."""
1111

1212
import os
13-
from os.path import join as pjoin
14-
import sys
15-
from functools import partial
1613

17-
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
18-
# update it when the contents of directories change.
19-
if os.path.exists('MANIFEST'):
20-
os.remove('MANIFEST')
14+
import setuptools
2115

22-
from setuptools import setup
23-
24-
# Commit hash writing, and dependency checking
25-
from nisext.sexts import (get_comrec_build, package_check, install_scripts_bat,
26-
read_vars_from)
27-
cmdclass = {'build_py': get_comrec_build('nibabel'),
28-
'install_scripts': install_scripts_bat}
29-
30-
# Get project related strings.
31-
INFO = read_vars_from(pjoin('nibabel', 'info.py'))
32-
33-
# Prepare setuptools args
34-
if 'setuptools' in sys.modules:
35-
extra_setuptools_args = dict(
36-
tests_require=['nose'],
37-
test_suite='nose.collector',
38-
zip_safe=False,
39-
extras_require=dict(
40-
doc='Sphinx>=0.3',
41-
test='nose>=0.10.1'),
42-
)
43-
pkg_chk = partial(package_check, setuptools_args = extra_setuptools_args)
44-
else:
45-
extra_setuptools_args = {}
46-
pkg_chk = package_check
47-
48-
# Do dependency checking
49-
pkg_chk('numpy', INFO.NUMPY_MIN_VERSION)
50-
pkg_chk('six', INFO.SIX_MIN_VERSION)
51-
custom_pydicom_messages = {'missing opt': 'Missing optional package "%s"'
52-
' provided by package "pydicom"'
53-
}
54-
pkg_chk('dicom',
55-
INFO.PYDICOM_MIN_VERSION,
56-
optional='dicom',
57-
messages = custom_pydicom_messages)
58-
59-
def main(**extra_args):
60-
setup(name='nibabel',
61-
maintainer=INFO.MAINTAINER,
62-
maintainer_email=INFO.MAINTAINER_EMAIL,
63-
description=INFO.DESCRIPTION,
64-
long_description=INFO.LONG_DESCRIPTION,
65-
url=INFO.URL,
66-
download_url=INFO.DOWNLOAD_URL,
67-
license=INFO.LICENSE,
68-
classifiers=INFO.CLASSIFIERS,
69-
author=INFO.AUTHOR,
70-
author_email=INFO.AUTHOR_EMAIL,
71-
platforms=INFO.PLATFORMS,
72-
version=INFO.VERSION,
73-
provides=INFO.PROVIDES,
74-
install_requires=INFO.REQUIRES,
75-
packages = ['nibabel',
76-
'nibabel.externals',
77-
'nibabel.externals.tests',
78-
'nibabel.gifti',
79-
'nibabel.gifti.tests',
80-
'nibabel.cifti2',
81-
'nibabel.cifti2.tests',
82-
'nibabel.cmdline',
83-
'nibabel.cmdline.tests',
84-
'nibabel.nicom',
85-
'nibabel.freesurfer',
86-
'nibabel.freesurfer.tests',
87-
'nibabel.nicom.tests',
88-
'nibabel.testing',
89-
'nibabel.tests',
90-
'nibabel.benchmarks',
91-
'nibabel.streamlines',
92-
'nibabel.streamlines.tests',
93-
# install nisext as its own package
94-
'nisext',
95-
'nisext.tests'],
96-
# The package_data spec has no effect for me (on python 2.6) -- even
97-
# changing to data_files doesn't get this stuff included in the source
98-
# distribution -- not sure if it has something to do with the magic
99-
# above, but distutils is surely the worst piece of code in all of
100-
# python -- duplicating things into MANIFEST.in but this is admittedly
101-
# only a workaround to get things started -- not a solution
102-
package_data = {'nibabel':
103-
[pjoin('tests', 'data', '*'),
104-
pjoin('externals', 'tests', 'data', '*'),
105-
pjoin('nicom', 'tests', 'data', '*'),
106-
pjoin('gifti', 'tests', 'data', '*'),
107-
pjoin('streamlines', 'tests', 'data', '*'),
108-
]},
109-
scripts = [pjoin('bin', 'parrec2nii'),
110-
pjoin('bin', 'nib-ls'),
111-
pjoin('bin', 'nib-dicomfs'),
112-
pjoin('bin', 'nib-nifti-dx'),
113-
pjoin('bin', 'nib-tck2trk'),
114-
pjoin('bin', 'nib-trk2tck'),
115-
pjoin('bin', 'nib-diff'),
116-
],
117-
cmdclass = cmdclass,
118-
**extra_args
119-
)
16+
# Commit hash writing
17+
from nisext.sexts import get_comrec_build, read_vars_from
12018

19+
INFO = read_vars_from(os.path.join('nibabel', 'info.py'))
12120

12221
if __name__ == "__main__":
123-
# Do not use nisext's dynamically updated install_requires
124-
extra_setuptools_args.pop('install_requires', None)
125-
main(**extra_setuptools_args)
22+
setuptools.setup(name='nibabel',
23+
version=INFO.VERSION,
24+
setup_requires=['setuptools>=30.3.0'],
25+
cmdclass={'build_py': get_comrec_build('nibabel')})

tools/refresh_readme.py

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

2020
rel = runpy.run_path(os.path.join('nibabel', 'info.py'))
2121

22-
readme = ''.join(readme_lines) + '\n' + rel['LONG_DESCRIPTION']
22+
readme = ''.join(readme_lines) + '\n' + rel['long_description']
2323

2424
with open('README.rst', 'wt') as fobj:
2525
fobj.write(readme)

tox.ini

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,3 @@ deps =
1818
deps =
1919
[testenv:np-1.2.1]
2020
deps =
21-
[flake8]
22-
max-line-length=100
23-
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
24-
exclude=*test*,*sphinx*,nibabel/externals/*,*/__init__.py
25-

0 commit comments

Comments
 (0)