-
Notifications
You must be signed in to change notification settings - Fork 103
/
setup.py
82 lines (73 loc) · 2.5 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
import os
import sys
from setuptools.command.build import build
from setuptools.command.build_ext import build_ext
from setuptools.command.install import install
from shutil import which as find_executable
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++', '-py3'],
)
if sys.platform == 'darwin':
jamspell.extra_compile_args.append('-stdlib=libc++')
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')
install.run(self)
class Swig4Ext(build_ext):
def find_swig(self):
swigBinary = find_executable('swig4.0') or find_executable('swig')
assert swigBinary is not None
assert subprocess.check_output([swigBinary, "-version"]).find(b'SWIG Version 4') != -1
return swigBinary
VERSION = '0.0.12'
setup(
name='jamspell',
version=VERSION,
author='Filipp Ozinov',
author_email='fippo@mail.ru',
url='https://github.com/bakwc/JamSpell',
download_url='https://github.com/bakwc/JamSpell/tarball/' + VERSION,
description='spell checker',
long_description='context-based spell checker',
keywords=['nlp', 'spell', 'spell-checker', 'jamspell'],
classifiers=[
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'License :: OSI Approved :: MIT License',
],
python_requires='>=3.6',
py_modules=['jamspell'],
ext_modules=[jamspell],
zip_safe=False,
cmdclass={
'build': CustomBuild,
'install': CustomInstall,
'build_ext': Swig4Ext,
},
include_package_data=True,
)