forked from rapidfuzz/RapidFuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
87 lines (80 loc) · 2.76 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
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import sys
from os import path
this_dir = path.abspath(path.dirname(__file__))
with open(path.join(this_dir, "VERSION"), encoding='utf-8') as version_file:
version = version_file.read().strip()
with open(path.join(this_dir, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
'msvc': ['/EHsc', '/O2', '/std:c++14'],
'unix': ['-O3', '-std=c++14'],
}
l_opts = {
'msvc': [],
'unix': [],
}
if sys.platform == 'darwin':
darwin_opts = ['-stdlib=libc++', '-mmacosx-version-min=10.9']
c_opts['unix'] += darwin_opts
l_opts['unix'] += darwin_opts
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
link_opts = self.l_opts.get(ct, [])
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = link_opts
build_ext.build_extensions(self)
setup(
name='rapidfuzz',
version=version,
author='Max Bachmann',
author_email='contact@maxbachmann.de',
url='https://github.com/maxbachmann/rapidfuzz',
description='rapid fuzzy string matching',
long_description=long_description,
long_description_content_type='text/markdown',
ext_modules = [
Extension(
'rapidfuzz.levenshtein',
['python/src/py_levenshtein.cpp'],
include_dirs=["cpp/src", "cpp/extern"],
language='c++',
),
Extension(
'rapidfuzz._fuzz',
['python/src/py_fuzz.cpp'],
include_dirs=["cpp/src", "cpp/extern"],
language='c++',
),
Extension(
'rapidfuzz._utils',
['python/src/py_utils.cpp'],
include_dirs=["cpp/src", "cpp/extern"],
language='c++',
),
],
cmdclass={'build_ext': BuildExt},
package_data={'': ['LICENSE', 'VERSION']},
package_dir={'': 'python/src'},
packages=['rapidfuzz'],
include_package_data=True,
zip_safe=False,
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
],
python_requires=">=3.5",
)