Skip to content

Commit 275d441

Browse files
committed
NF - added setuptools commands
1 parent 630dacf commit 275d441

File tree

2 files changed

+62
-27
lines changed

2 files changed

+62
-27
lines changed

setup.py

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,47 @@
1111

1212
__docformat__ = 'restructuredtext'
1313

14-
from numpy.distutils.core import setup
15-
from glob import glob
1614
import os
15+
import sys
16+
from glob import glob
17+
18+
# For some commands, use setuptools.
19+
if len(set(('develop', 'bdist_egg', 'bdist_rpm', 'bdist', 'bdist_dumb',
20+
'bdist_wininst', 'install_egg_info', 'egg_info', 'easy_install',
21+
)).intersection(sys.argv)) > 0:
22+
# setup_egg imports setuptools setup, thus monkeypatching distutils. Note
23+
# that we have to import our own setup after this so we catch the
24+
# monkeypatched version
25+
from setup_egg import extra_setuptools_args
26+
27+
# extra_setuptools_args can be defined from the line above, but it can
28+
# also be defined here because setup.py has been exec'ed from
29+
# setup_egg.py.
30+
if not 'extra_setuptools_args' in globals():
31+
extra_setuptools_args = dict()
32+
33+
34+
def main(**extra_args):
35+
# Import late so we catch setuptools monkeypatched distutils setup
36+
from numpy.distutils.core import setup
37+
setup(name = 'nibabel',
38+
version = '1.0.0',
39+
author = 'Matthew Brett and Michael Hanke',
40+
author_email = 'NiBabel List <pkg-exppsy-pynifti@lists.alioth.debian.org>',
41+
license = 'MIT License',
42+
url = 'http://niftilib.sf.net/pynifti',
43+
description = 'Access a multitude of neuroimaging data formats',
44+
long_description = "",
45+
packages = ['nibabel',
46+
'nibabel.externals',
47+
'nibabel.testing',
48+
'nibabel.tests'],
49+
data_files = [('nibabel/tests/data',
50+
glob(os.path.join('nibabel', 'tests', 'data', '*')))],
51+
scripts = [os.path.join('bin', 'parrec2nii')],
52+
**extra_args
53+
)
54+
1755

18-
setup(name = 'nibabel',
19-
version = '1.0.0',
20-
author = 'Matthew Brett and Michael Hanke',
21-
author_email = 'NiBabel List <pkg-exppsy-pynifti@lists.alioth.debian.org>',
22-
license = 'MIT License',
23-
url = 'http://niftilib.sf.net/pynifti',
24-
description = 'Access a multitude of neuroimaging data formats',
25-
long_description = "",
26-
packages = ['nibabel',
27-
'nibabel.externals',
28-
'nibabel.testing',
29-
'nibabel.tests'],
30-
data_files = [('nibabel/tests/data',
31-
glob(os.path.join('nibabel', 'tests', 'data', '*')))],
32-
scripts = [os.path.join('bin', 'parrec2nii')]
33-
)
56+
if __name__ == "__main__":
57+
main(**extra_setuptools_args)

setup_egg.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
# emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
1+
#!/usr/bin/env python
2+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
23
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
4-
#
5-
# See COPYING file distributed along with the NiBabel package for the
6-
# copyright and license terms.
7-
#
8-
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
from setuptools import setup
10-
execfile('setup.py')
4+
"""Wrapper to run setup.py using setuptools."""
5+
6+
from setuptools import setup
7+
8+
################################################################################
9+
# Call the setup.py script, injecting the setuptools-specific arguments.
10+
11+
extra_setuptools_args = dict(
12+
tests_require=['nose'],
13+
test_suite='nose.collector',
14+
zip_safe=False,
15+
)
16+
17+
18+
if __name__ == '__main__':
19+
execfile('setup.py', dict(__name__='__main__',
20+
extra_setuptools_args=extra_setuptools_args))
21+
1122

1223

0 commit comments

Comments
 (0)