forked from bakwc/JamSpell
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
85 lines (76 loc) · 2.46 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
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__))
jamspell = Extension(
name='_jamspell',
include_dirs=['.', 'jamspell'],
sources=[
os.path.join('jamspell', 'lang_model.cpp'),
os.path.join('jamspell', 'spell_corrector.cpp'),
os.path.join('jamspell', 'utils.cpp'),
os.path.join('jamspell', 'perfect_hash.cpp'),
os.path.join('jamspell', 'bloom_filter.cpp'),
os.path.join('contrib', 'cityhash', 'city.cc'),
os.path.join('contrib', 'phf', 'phf.cc'),
os.path.join('jamspell.i'),
],
extra_compile_args=['-std=c++11', '-O2'],
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 Swig3Ext(build_ext):
def find_swig(self):
swigBinary = find_executable('swig3.0') or find_executable('swig')
assert swigBinary is not None
assert subprocess.check_output([swigBinary, "-version"]).find(b'SWIG Version 3') != -1
return swigBinary
VERSION = '1.0.0'
##
# Original Credit
#
# name='jamspell',
# author='Filipp Ozinov',
# author_email='[email protected]',
# url='https://github.com/bakwc/JamSpell',
# download_url='https://github.com/bakwc/JamSpell/tarball/' + VERSION,
##
setup(
name='medSpellCheck',
version=VERSION,
author='Jack Neil',
author_email='[email protected]',
url='https://github.com/hank-ai/medSpellCheck/',
download_url='https://github.com/hank-ai/medSpellCheck/tarball/' + VERSION,
description='spell checker',
long_description='context-based spell checker',
keywords=['nlp', 'spell', 'spell-checker', 'jamspell', 'hankai'],
classifiers=[
'Programming Language :: Python :: 2.7',
'License :: OSI Approved :: MIT License',
],
## TODO Update to be "medSpellCheck"
py_modules=['jamspell'],
ext_modules=[jamspell],
zip_safe=False,
cmdclass={
'build': CustomBuild,
'install': CustomInstall,
'build_ext': Swig3Ext,
},
include_package_data=True,
)