|
11 | 11 | # update it when the contents of directories change.
|
12 | 12 | if exists('MANIFEST'): os.remove('MANIFEST')
|
13 | 13 |
|
14 |
| -# Import build helpers |
15 |
| -try: |
16 |
| - from nisext.sexts import package_check |
17 |
| -except ImportError: |
18 |
| - raise RuntimeError('Need nisext package from nibabel installation' |
19 |
| - ' - please install nibabel first') |
20 |
| - |
21 | 14 | from setup_helpers import (generate_a_pyrex_source, get_comrec_build,
|
22 |
| - cmdclass, INFO_VARS) |
| 15 | + cmdclass, INFO_VARS, get_pkg_version, |
| 16 | + version_error_msg) |
23 | 17 |
|
24 | 18 | # monkey-patch numpy distutils to use Cython instead of Pyrex
|
25 | 19 | from numpy.distutils.command.build_src import build_src
|
@@ -60,42 +54,28 @@ def configuration(parent_package='',top_path=None):
|
60 | 54 | if not 'extra_setuptools_args' in globals():
|
61 | 55 | extra_setuptools_args = dict()
|
62 | 56 |
|
63 |
| - |
64 | 57 | # Hard and soft dependency checking
|
65 |
| -package_check('numpy', INFO_VARS['NUMPY_MIN_VERSION']) |
66 |
| -package_check('scipy', INFO_VARS['SCIPY_MIN_VERSION']) |
67 |
| -package_check('nibabel', INFO_VARS['NIBABEL_MIN_VERSION']) |
68 |
| -package_check('sympy', INFO_VARS['SYMPY_MIN_VERSION']) |
69 |
| -def _mayavi_version(pkg_name): |
70 |
| - """Mayavi2 pruned enthought. namespace at 4.0.0 |
71 |
| - """ |
72 |
| - v = '' |
73 |
| - try: |
74 |
| - from mayavi import version |
75 |
| - v = version.version |
76 |
| - if v == '': |
77 |
| - v = '4.0.0' # must be the one in Debian |
78 |
| - except ImportError: |
79 |
| - from enthought.mayavi import version |
80 |
| - v = version.version |
81 |
| - return v |
82 |
| -package_check('mayavi', |
83 |
| - INFO_VARS['MAYAVI_MIN_VERSION'], |
84 |
| - optional=True, |
85 |
| - version_getter=_mayavi_version) |
86 |
| -# Cython can be a build dependency |
87 |
| -def _cython_version(pkg_name): |
88 |
| - from Cython.Compiler.Version import version |
89 |
| - return version |
90 |
| -package_check('cython', |
91 |
| - INFO_VARS['CYTHON_MIN_VERSION'], |
92 |
| - optional=True, |
93 |
| - version_getter=_cython_version, |
94 |
| - messages={'opt suffix': ' - you will not be able ' |
95 |
| - 'to rebuild Cython source files into C files', |
96 |
| - 'missing opt': 'Missing optional build-time ' |
97 |
| - 'package "%s"'} |
98 |
| - ) |
| 58 | +DEPS = ( |
| 59 | + ('numpy', INFO_VARS['NUMPY_MIN_VERSION'], 'setup_requires', True), |
| 60 | + ('scipy', INFO_VARS['SCIPY_MIN_VERSION'], 'install_requires', True), |
| 61 | + ('nibabel', INFO_VARS['NIBABEL_MIN_VERSION'], 'install_requires', False), |
| 62 | + ('sympy', INFO_VARS['SYMPY_MIN_VERSION'], 'install_requires', False)) |
| 63 | + |
| 64 | +using_setuptools = 'setuptools' in sys.modules |
| 65 | + |
| 66 | +for name, min_ver, req_type, heavy in DEPS: |
| 67 | + found_ver = get_pkg_version(name) |
| 68 | + ver_err_msg = version_error_msg(name, found_ver, min_ver) |
| 69 | + if not using_setuptools: |
| 70 | + if ver_err_msg != None: |
| 71 | + raise RuntimeError(ver_err_msg) |
| 72 | + else: # Using setuptools |
| 73 | + # Add packages to given section of setup/install_requires |
| 74 | + if ver_err_msg != None or not heavy: |
| 75 | + new_req = '{0}>={1}'.format(name, min_ver) |
| 76 | + old_reqs = extra_setuptools_args.get(req_type, []) |
| 77 | + extra_setuptools_args[req_type] = old_reqs + [new_req] |
| 78 | + |
99 | 79 |
|
100 | 80 | ################################################################################
|
101 | 81 | # commands for installing the data
|
|
0 commit comments