Skip to content

Commit f76de82

Browse files
fixing setup to be like regreg
1 parent c17d689 commit f76de82

File tree

2 files changed

+343
-140
lines changed

2 files changed

+343
-140
lines changed

Diff for: setup.py

+25-75
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,43 @@
33

44
import os
55
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
87

98
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
109
# update it when the contents of directories change.
11-
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
10+
if exists('MANIFEST'): os.remove('MANIFEST')
1211

13-
import numpy as np
12+
# Unconditionally require setuptools
13+
import setuptools
1414

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
1917

20-
from distutils.command import install
18+
# Import distutils _after_ setuptools import, and after removing
19+
# MANIFEST
2120
from distutils.core import setup
2221
from distutils.extension import Extension
2322

2423
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
2628
info = read_vars_from(pjoin('selection', 'info.py'))
2729

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+
2843
# Define extensions
2944
EXTS = []
3045
for modulename, other_sources in (
@@ -34,70 +49,5 @@
3449
):
3550
pyx_src = pjoin(*modulename.split('.')) + '.pyx'
3651
EXTS.append(Extension(modulename,[pyx_src] + other_sources,
37-
include_dirs = [np.get_include(),
38-
"src"],
3952
libraries=['m']),
4053
)
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

Comments
 (0)