|
3 | 3 |
|
4 | 4 | import os
|
5 | 5 | import sys
|
6 |
| -from os.path import join as pjoin, dirname |
7 |
| -from setup_helpers import package_check |
| 6 | +from os.path import join as pjoin, dirname, exists |
8 | 7 |
|
9 | 8 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
|
10 | 9 | # update it when the contents of directories change.
|
11 |
| -if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
| 10 | +if exists('MANIFEST'): os.remove('MANIFEST') |
12 | 11 |
|
13 |
| -import numpy as np |
| 12 | +# Unconditionally require setuptools |
| 13 | +import setuptools |
14 | 14 |
|
15 |
| -# Get version and release info, which is all stored in regreg/info.py |
16 |
| -ver_file = os.path.join('selection', 'info.py') |
17 |
| -# Use exec for compabibility with Python 3 |
18 |
| -exec(open(ver_file).read()) |
| 15 | +# Package for getting versions from git tags |
| 16 | +import versioneer |
19 | 17 |
|
20 |
| -from distutils.command import install |
| 18 | +# Import distutils _after_ setuptools import, and after removing |
| 19 | +# MANIFEST |
21 | 20 | from distutils.core import setup
|
22 | 21 | from distutils.extension import Extension
|
23 | 22 |
|
24 | 23 | from cythexts import cyproc_exts, get_pyx_sdist
|
25 |
| -from setup_helpers import package_check, read_vars_from |
| 24 | +from setup_helpers import (SetupDependency, read_vars_from, |
| 25 | + make_np_ext_builder) |
| 26 | + |
| 27 | +# Get various parameters for this version, stored in selection/info.py |
26 | 28 | info = read_vars_from(pjoin('selection', 'info.py'))
|
27 | 29 |
|
| 30 | +# Try to preempt setuptools monkeypatching of Extension handling when Pyrex |
| 31 | +# is missing. Otherwise the monkeypatched Extension will change .pyx |
| 32 | +# filenames to .c filenames, and we probably don't have the .c files. |
| 33 | +sys.path.insert(0, pjoin(dirname(__file__), 'fake_pyrex')) |
| 34 | +# Set setuptools extra arguments |
| 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>=1.0'], |
| 41 | + test=['nose>=0.10.1'])) |
| 42 | + |
28 | 43 | # Define extensions
|
29 | 44 | EXTS = []
|
30 | 45 | for modulename, other_sources in (
|
|
34 | 49 | ):
|
35 | 50 | pyx_src = pjoin(*modulename.split('.')) + '.pyx'
|
36 | 51 | EXTS.append(Extension(modulename,[pyx_src] + other_sources,
|
37 |
| - include_dirs = [np.get_include(), |
38 |
| - "src"], |
39 | 52 | libraries=['m']),
|
40 | 53 | )
|
41 |
| -extbuilder = cyproc_exts(EXTS, CYTHON_MIN_VERSION, 'pyx-stamps') |
42 |
| - |
43 |
| -extra_setuptools_args = {} |
44 |
| - |
45 |
| -class installer(install.install): |
46 |
| - def run(self): |
47 |
| - package_check('numpy', info.NUMPY_MIN_VERSION) |
48 |
| - package_check('scipy', info.SCIPY_MIN_VERSION) |
49 |
| - package_check('sklearn', info.SKLEARN_MIN_VERSION) |
50 |
| - package_check('mpmath', info.MPMATH_MIN_VERSION) |
51 |
| - install.install.run(self) |
52 |
| - |
53 |
| -cmdclass = dict( |
54 |
| - build_ext=extbuilder, |
55 |
| - install=installer, |
56 |
| - sdist=get_pyx_sdist() |
57 |
| -) |
58 |
| - |
59 |
| - |
60 |
| -def main(**extra_args): |
61 |
| - setup(name=NAME, |
62 |
| - maintainer=MAINTAINER, |
63 |
| - maintainer_email=MAINTAINER_EMAIL, |
64 |
| - description=DESCRIPTION, |
65 |
| - long_description=LONG_DESCRIPTION, |
66 |
| - url=URL, |
67 |
| - download_url=DOWNLOAD_URL, |
68 |
| - license=LICENSE, |
69 |
| - classifiers=CLASSIFIERS, |
70 |
| - author=AUTHOR, |
71 |
| - author_email=AUTHOR_EMAIL, |
72 |
| - platforms=PLATFORMS, |
73 |
| - version=VERSION, |
74 |
| - requires=REQUIRES, |
75 |
| - provides=PROVIDES, |
76 |
| - packages = ['selection', |
77 |
| - 'selection.utils', |
78 |
| - 'selection.truncated', |
79 |
| - 'selection.truncated.tests', |
80 |
| - 'selection.constraints', |
81 |
| - 'selection.constraints.tests', |
82 |
| - 'selection.distributions', |
83 |
| - 'selection.distributions.tests', |
84 |
| - 'selection.algorithms', |
85 |
| - 'selection.algorithms.tests', |
86 |
| - 'selection.sampling', |
87 |
| - 'selection.sampling.tests', |
88 |
| - 'selection.randomized', |
89 |
| - 'selection.randomized.tests', |
90 |
| - 'selection.tests' |
91 |
| - ], |
92 |
| - ext_modules = EXTS, |
93 |
| - package_data = {}, |
94 |
| - data_files=[], |
95 |
| - scripts= [], |
96 |
| - cmdclass = cmdclass, |
97 |
| - **extra_args |
98 |
| - ) |
99 |
| - |
100 |
| -#simple way to test what setup will do |
101 |
| -#python setup.py install --prefix=/tmp |
102 |
| -if __name__ == "__main__": |
103 |
| - main(**extra_setuptools_args) |
0 commit comments