-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
70 lines (61 loc) · 2.1 KB
/
setup.py
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
from distutils.core import setup
from distutils.extension import Extension
try:
from Cython.Distutils import build_ext
HAS_CYTHON = True
except ImportError:
from distutils.command.build_ext import build_ext
HAS_CYTHON = False
def make_cython_extension__nef_map_pi_d_K():
ext = Extension(
"pc_toolbox.model_slda.est_local_params__single_doc_map.calc_nef_map_pi_d_K__cython",
["pc_toolbox/model_slda/est_local_params__single_doc_map/calc_nef_map_pi_d_K__cython.pyx"],
libraries=["m"],
extra_compile_args = ["-O3", "-ffast-math"])
return add_directives_to_cython_ext(ext)
def make_extensions():
''' Assemble C++/Cython extension objects for compilation.
Warns user if required prerequisites are not specified.
Returns
-------
ext_list : list of extension objects
'''
ext_list = list()
if HAS_CYTHON:
ext_list.append(make_cython_extension__nef_map_pi_d_K())
return ext_list
def add_directives_to_cython_ext(ext):
''' Improve speed of cython code extensions
References
----------
http://docs.cython.org/src/reference/compilation.html#compiler-directives
'''
ext.cython_directives = {
'embedsignature':True,
'boundscheck':False,
'nonecheck':False,
'wraparound':False,
'cdivision':True}
return ext
def read_version(txtpath):
with open(txtpath, 'r') as f:
version = f.readline().strip()
return version
setup(
name='pc_toolbox',
version=read_version('version.txt'),
description='Prediction-constrained training for supervised topic models',
long_description='Support code for Hughes et al AISTATS 2018',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
],
url='https://github.com/dtak/prediction-constrained-topic-models',
author='Michael C. Hughes',
author_email='[email protected]',
license='MIT',
setup_requires=["Cython>=0.25"],
cmdclass = {"build_ext": build_ext},
ext_modules = make_extensions(),
)