-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathsetup.py
More file actions
88 lines (78 loc) · 2.7 KB
/
setup.py
File metadata and controls
88 lines (78 loc) · 2.7 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
import os
import re
from distutils.command.build import build
from distutils.command.build_ext import build_ext
from setuptools.command.install import install
from distutils.spawn import find_executable
from distutils.version import LooseVersion
from setuptools import setup
from setuptools.extension import Extension
import subprocess
this_dir = os.path.dirname(os.path.abspath(__file__))
openspell = Extension(
name='_openspell',
include_dirs=['.', 'openspell'],
sources=[
os.path.join('openspell', 'lang_model.cpp'),
os.path.join('openspell', 'spell_corrector.cpp'),
os.path.join('openspell', 'utils.cpp'),
os.path.join('openspell.i'),
],
extra_compile_args=['-std=c++11'],
swig_opts=['-c++'],
)
class CustomBuild(build):
def run(self):
self.run_command('build_ext')
build.run(self)
class CustomInstall(install):
def run(self):
self.run_command('build_ext')
self.do_egg_install()
class Build_Ext_find_swig3(build_ext):
def find_swig(self):
return get_swig_executable()
def get_swig_executable():
# stolen from https://github.com/FEniCS/ffc/blob/master/setup.py
"Get SWIG executable"
# Find SWIG executable
swig_executable = None
swig_minimum_version = "3.0.2"
for executable in ["swig", "swig3.0"]:
swig_executable = find_executable(executable)
if swig_executable is not None:
# Check that SWIG version is ok
output = subprocess.check_output([swig_executable, "-version"]).decode('utf-8')
swig_version = re.findall(r"SWIG Version ([0-9.]+)", output)[0]
if LooseVersion(swig_version) >= LooseVersion(swig_minimum_version):
break
swig_executable = None
if swig_executable is None:
raise OSError("Unable to find SWIG version %s or higher." % swig_minimum_version)
print("Found SWIG: %s (version %s)" % (swig_executable, swig_version))
return swig_executable
VERSION = '0.0.5'
setup(
name='openspell',
version=VERSION,
author='Filipp Ozinov',
author_email='fippo@mail.ru',
url='https://github.com/bakwc/OpenSpell',
download_url='https://github.com/bakwc/OpenSpell/tarball/' + VERSION,
description='spell checker',
long_description='context-based spell checker',
keywords=['nlp', 'spell', 'spell-checker'],
classifiers=[
'Programming Language :: Python :: 2.7',
'License :: OSI Approved :: MIT License',
],
py_modules=['openspell'],
ext_modules=[openspell],
zip_safe=False,
cmdclass={
'build': CustomBuild,
'install': CustomInstall,
'build_ext': Build_Ext_find_swig3,
},
include_package_data=True,
)