-
Notifications
You must be signed in to change notification settings - Fork 22
/
setup.py
executable file
·109 lines (95 loc) · 3.66 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
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
#!/usr/bin/env python
"""Divisi2: Commonsense Reasoning over Semantic Networks
Divisi2 is a library for reasoning by analogy and association over
semantic networks, including common sense knowledge. Divisi uses a
sparse higher-order SVD and can help find related concepts, features,
and relation types in any knowledge base that can be represented as a
semantic network. By including common sense knowledge from ConceptNet,
the results can include relationships not expressed in the original
data but related by common sense. See http://divisi.media.mit.edu/ for
more info."""
VERSION = "2.2.5"
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
import os.path, sys
from stat import ST_MTIME
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: C',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Topic :: Scientific/Engineering',
'Topic :: Software Development',
'Topic :: Text Processing :: Linguistic',]
### Check for the existence of NumPy.
try:
import numpy
except ImportError:
print >>sys.stderr, """This package requires NumPy.
On a Debian / Ubuntu system, you can run:
sudo apt-get install python-numpy python-dev
Otherwise it will probably suffice to:
sudo easy_install numpy
"""
sys.exit(1)
CYTHON_OUT = 'svdlib/_svdlib.c'
CYTHON_SRC = 'svdlib/_svdlib.pyx'
### Update the Cython file, if necessary.
def get_modification_time(filename):
return os.stat(filename)[ST_MTIME]
try:
if not os.path.exists(CYTHON_OUT) or get_modification_time(CYTHON_SRC) > get_modification_time(CYTHON_OUT):
try:
# Try building the Cython file
print 'Building Cython source'
from Cython.Compiler.Main import compile
res = compile(CYTHON_SRC)
if res.num_errors > 0:
print >>sys.stderr, "Error building the Cython file."
sys.exit(1)
except ImportError:
print >>sys.stderr, 'Warning: Skipped building the Cython file.'
print >>sys.stderr, ' The svdlib source file is more recent than the Cython output file, but'
print >>sys.stderr, ' you seem to lack Cython, so skipping rebuilding it.'
raw_input('Press Enter to acknowledge. ')
except OSError:
print >>sys.stderr, 'Warning: Skipped building the Cython file.'
svdlibc = Extension(
name='divisi2._svdlib',
sources=[
CYTHON_OUT,
'svdlib/svdwrapper.c',
'svdlib/las2.c',
'svdlib/svdlib.c',
'svdlib/svdutil.c',
],
include_dirs=[numpy.get_include(), 'svdlib'],
extra_compile_args=['-g'],
extra_link_args=['-g'],
)
doclines = __doc__.split("\n")
setup(
name="Divisi2",
version = VERSION,
maintainer='MIT Media Lab, Software Agents group',
maintainer_email='conceptnet@media.mit.edu',
url='http://divisi.media.mit.edu/',
license = "http://www.gnu.org/copyleft/gpl.html",
platforms = ["any"],
description = doclines[0],
classifiers = classifiers,
long_description = "\n".join(doclines[2:]),
ext_modules = [svdlibc],
packages=['divisi2', 'divisi2.algorithms', 'divisi2.test', 'divisi2.test.eval'],
package_data = {'divisi2': ['data/graphs/*', 'data/eval/*', 'data/matrices/*']},
install_requires=['csc-utils >= 0.6.1', 'networkx', 'csc-pysparse'],
)