-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.py
More file actions
112 lines (104 loc) · 3.76 KB
/
setup.py
File metadata and controls
112 lines (104 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
try:
import numpy
import scipy
except ImportError:
raise ImportError("py-sdm requires numpy and scipy to be installed")
# Don't do this in the setup() requirements, because otherwise pip and
# friends get too eager about updating numpy/scipy.
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
setup_args = {}
# Handle the _np_divs_cy cython extension. It has enough specific handling that
# it's not worth breaking out into a function.
name = "_np_divs_cy"
try:
from Cython.Distutils import build_ext
except ImportError:
import os
try:
pyx_time = os.path.getmtime('sdm/{}.pyx'.format(name))
c_time = os.path.getmtime('sdm/{}.c'.format(name))
if pyx_time >= c_time:
import datetime
msg = "{name}.pyx file has mtime {pyx_time}, {name}.c has {c_time}"
raise ValueError(msg.format(
name=name,
pyx_time=datetime.datetime.fromtimestamp(pyx_time),
c_time=datetime.datetime.fromtimestamp(c_time),
))
except (OSError, ValueError) as e:
msg = "{} extension needs to be compiled but cython isn't available:"
raise ImportError(msg.format(name) + '\n' + str(e))
else:
source_file = "sdm/{}.c".format(name)
else:
try:
from cyflann.extensions import FLANNExtension
except ImportError as e:
msg = \
"""The Cython extension requires cyflann to be installed before compilation.
Install cyflann (e.g. `pip install cyflann`), and then try again:
{}"""
raise ImportError(msg.format(e))
source_file = "sdm/{}.pyx".format(name)
setup_args['cmdclass'] = {'build_ext': build_ext}
ext_modules = [
FLANNExtension("sdm.{}".format(name), [source_file],
include_dirs=[numpy.get_include()],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'])
]
setup(
name='py-sdm',
version='0.1.0dev',
author='Dougal J. Sutherland',
author_email='dougal@gmail.com',
packages=['sdm', 'sdm.tests'],
package_data={
'sdm.tests': ['data/*'],
},
url='https://github.com/dougalsutherland/py-sdm',
description='An implementation of nonparametric divergence estimators and '
'their use in SVMs.',
long_description=open('README.rst').read(),
license='LICENSE.txt',
install_requires=[
'h5py',
'progressbar',
'scikit-learn >= 0.18',
'nose',
'cyflann >= 0.2',
# only for image feat extraction; should be "extras"
'scikit-image >= 0.6',
'vlfeat-ctypes',
],
ext_modules=ext_modules,
entry_points={
'console_scripts': [
'extract_image_features = sdm.extract_image_features:main',
'proc_image_features = sdm.proc_image_features:main',
'estimate_divs = sdm.np_divs:main',
'sdm = sdm.sdm:main',
],
},
zip_safe=False,
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 2 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering :: Information Analysis",
],
**setup_args
)
# TODO: use "extras" to make some of the dependencies optional
# but figure out how to make it work with distribute, etc...