RapidFuzz/setup.py

102 lines
3.4 KiB
Python
Raw Normal View History

2020-02-29 17:17:00 +00:00
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import sys
from os import path
2020-08-22 19:07:08 +00:00
from io import open
this_dir = path.abspath(path.dirname(__file__))
with open(path.join(this_dir, "VERSION"), encoding='utf-8') as version_file:
2020-02-29 17:17:00 +00:00
version = version_file.read().strip()
with open(path.join(this_dir, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
2020-02-29 17:17:00 +00:00
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
2020-11-21 17:21:21 +00:00
'msvc': ['/EHsc', '/O2', '/std:c++11'],
'unix': ['-O3', '-std=c++11', '-Wextra', '-Wall'],
2020-02-29 17:17:00 +00:00
}
l_opts = {
'msvc': [],
'unix': [],
}
if sys.platform == 'darwin':
darwin_opts = ['-stdlib=libc++', '-mmacosx-version-min=10.9']
2020-02-29 17:17:00 +00:00
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:
2021-03-03 14:20:31 +00:00
ext.extra_compile_args += opts
ext.extra_link_args += link_opts
2020-02-29 17:17:00 +00:00
build_ext.build_extensions(self)
setup(
name='rapidfuzz',
version=version,
author='Max Bachmann',
author_email='contact@maxbachmann.de',
2020-04-08 22:12:44 +00:00
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.cpp_process', [
'src/cpp_process.cpp',
'src/rapidfuzz-cpp/rapidfuzz/details/unicode.cpp'],
include_dirs=["src/rapidfuzz-cpp/"],
language='c++',
),
Extension(
'rapidfuzz.cpp_fuzz', [
'src/cpp_fuzz.cpp',
'src/rapidfuzz-cpp/rapidfuzz/details/unicode.cpp'],
include_dirs=["src/rapidfuzz-cpp/"],
language='c++',
),
Extension(
'rapidfuzz.cpp_string_metric', [
'src/cpp_string_metric.cpp',
'src/rapidfuzz-cpp/rapidfuzz/details/unicode.cpp'],
include_dirs=["src/rapidfuzz-cpp/"],
language='c++',
),
Extension(
'rapidfuzz.cpp_utils', [
'src/cpp_utils.cpp',
'src/rapidfuzz-cpp/rapidfuzz/details/unicode.cpp'],
include_dirs=["src/rapidfuzz-cpp/"],
language='c++',
),
],
cmdclass={'build_ext': BuildExt},
package_data={'': ['LICENSE', 'VERSION']},
2020-04-13 05:43:34 +00:00
package_dir={'': 'src'},
packages=['rapidfuzz'],
include_package_data=True,
2020-02-29 17:17:00 +00:00
zip_safe=False,
classifiers=[
2020-08-22 19:07:08 +00:00
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
2020-08-14 12:08:38 +00:00
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: MIT License",
],
2020-08-22 19:07:08 +00:00
python_requires=">=2.7",
)