forked from dleemiller/WordLlama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
102 lines (94 loc) · 3.36 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
95
96
97
98
99
100
101
102
from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy as np
import platform
numpy_include = np.get_include()
extra_compile_args = []
extra_link_args = []
if platform.system() == "Darwin":
if platform.machine() == "arm64":
extra_compile_args.extend(["-arch", "arm64", "-O3", "-ffast-math"])
extra_link_args.extend(["-arch", "arm64"])
else:
extra_compile_args.extend(["-arch", "x86_64", "-O3", "-ffast-math"])
extra_link_args.extend(["-arch", "x86_64"])
elif platform.system() == "Windows":
extra_compile_args.extend(["/O2"])
else: # Linux and others
if platform.machine().startswith("arm"):
if platform.architecture()[0] == "32bit":
extra_compile_args.extend(["-march=armv7-a", "-mfpu=neon"])
extra_link_args.extend(["-march=armv7-a", "-mfpu=neon"])
else: # 64-bit ARM
extra_compile_args.extend(["-march=armv8-a"])
extra_link_args.extend(["-march=armv8-a"])
elif platform.machine() in ["x86_64", "AMD64"]:
extra_compile_args.extend(["-march=native", "-mpopcnt"])
extra_link_args.extend(["-march=native", "-mpopcnt"])
extra_compile_args.extend(["-O3", "-ffast-math"])
extensions = [
Extension(
"wordllama.algorithms.splitter",
["wordllama/algorithms/splitter.pyx"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"wordllama.algorithms.deduplicate_helpers",
["wordllama/algorithms/deduplicate_helpers.pyx"],
include_dirs=[numpy_include],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"wordllama.algorithms.kmeans",
["wordllama/algorithms/kmeans.pyx"],
include_dirs=[numpy_include],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"wordllama.algorithms.splitter",
["wordllama/algorithms/splitter.pyx"],
include_dirs=[],
define_macros=[],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
language="c++"
),
Extension(
"wordllama.algorithms.find_local_minima",
["wordllama/algorithms/find_local_minima.pyx"],
include_dirs=[numpy_include],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
language="c++"
),
Extension(
"wordllama.algorithms.vector_similarity",
["wordllama/algorithms/vector_similarity.pyx"],
include_dirs=[numpy_include],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
]
setup(
name="Embedding and lightweight NLP utility.",
use_scm_version=True,
setup_requires=['setuptools_scm'],
ext_modules=cythonize(
extensions,
compiler_directives={
"language_level": "3",
"boundscheck": False,
"wraparound": False,
},
annotate=True,
),
zip_safe=False,
install_requires=["numpy"],
)