forked from mit-nlp/MITIE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
69 lines (59 loc) · 2.24 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
import os.path
from distutils.core import setup
from distutils.command.build import build
import os
import platform
import sys
import re
import subprocess
from distutils.version import LooseVersion
class BuildMITIE(build):
def run(self):
if platform.system() == "Windows":
if LooseVersion(self.get_cmake_version()) < '3.1.0':
raise RuntimeError("CMake >= 3.1.0 is required on Windows")
if not os.path.exists('mitielib/build'):
os.makedirs('mitielib/build')
os.chdir('mitielib/build')
if sys.maxsize > 2**32:
subprocess.check_call(['cmake', '..', '-A', 'x64'])
else:
subprocess.check_call(['cmake', '..'])
subprocess.check_call(['cmake', '--build', '.', '--config', 'Release', '--target', 'install'])
os.chdir('../..')
build.run(self)
self.copy_file(
'mitielib/mitie.dll',
os.path.join(self.build_lib, 'mitie/mitie.dll'))
else:
subprocess.check_call(['make', 'mitielib'])
build.run(self)
self.copy_file(
'mitielib/libmitie.so',
os.path.join(self.build_lib, 'mitie/libmitie.so'))
def get_cmake_version(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
return re.search(r'version\s*([\d.]+)', out.decode()).group(1)
setup(
version='0.5.0',
name='mitie',
packages=['mitie'],
package_dir={'mitie': 'mitielib'},
cmdclass={'build': BuildMITIE},
classifiers=[
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'License :: Boost License',
]
)