forked from facebookresearch/fastText
-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
94 lines (81 loc) · 2.75 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
88
89
90
91
92
93
94
#!/usr/bin/env python
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
import os
import sysconfig
import io
from pybind11.setup_helpers import Pybind11Extension, ParallelCompile
from setuptools import setup
ParallelCompile().install()
__version__ = '0.9.2.4'
FASTTEXT_SRC = "src"
WIN = sys.platform.startswith("win32") and "mingw" not in sysconfig.get_platform()
fasttext_src_files = map(str, os.listdir(FASTTEXT_SRC))
fasttext_src_cc = list(filter(lambda x: x.endswith('.cc'), fasttext_src_files))
fasttext_src_cc = list(
map(lambda x: str(os.path.join(FASTTEXT_SRC, x)), fasttext_src_cc)
)
extra_compile_args = []
if WIN:
extra_compile_args.append('/DVERSION_INFO=\\"%s\\"' % __version__)
else:
extra_compile_args.append('-DVERSION_INFO="%s"' % __version__)
extra_compile_args.extend(["-O3", "-flto"])
def _get_readme():
"""
Use pandoc to generate rst from md.
pandoc --from=markdown --to=rst --output=python/README.rst python/README.md
"""
with io.open("README.rst", encoding='utf-8') as fid:
return fid.read()
setup(
name='fasttext-predict',
version=__version__,
author='Alexandre Flament',
author_email='alex.andre@al-f.net',
keywords=['fasttext', 'language detection', 'language identification'],
description='fasttext with wheels and no external dependency, but only the predict method (<1MB)',
long_description=_get_readme(),
url='https://github.com/searxng/fasttext-predict/',
license='MIT',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
],
packages=[
'fasttext',
],
package_dir={
'': 'python/fasttext_module'
},
zip_safe=False,
ext_modules=[
Pybind11Extension(
"fasttext_pybind",
["python/fasttext_module/fasttext/pybind/fasttext_pybind.cc"] + fasttext_src_cc,
include_dirs=[
FASTTEXT_SRC,
],
cxx_std=17,
extra_compile_args=extra_compile_args,
)
],
)