-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
103 lines (87 loc) · 2.94 KB
/
setup.py
File metadata and controls
103 lines (87 loc) · 2.94 KB
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
103
# -*- coding: utf-8 -*-
import os
import re
import sys
from collections import defaultdict
from Cython.Build import cythonize
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
BUILD_ARGS = defaultdict(lambda: ["-O3", "-g0"])
for compiler, args in [
("msvc", ["/EHsc", "/DHUNSPELL_STATIC", "/Oi", "/O2", "/Ot"]),
("gcc", ["-O3", "-g0"]),
]:
BUILD_ARGS[compiler] = args
class build_ext_compiler_check(build_ext):
def build_extensions(self):
compiler = self.compiler.compiler_type
args = BUILD_ARGS[compiler]
for ext in self.extensions:
ext.extra_compile_args = args
super().build_extensions()
extensions = [
Extension(
"simdutf._simdutf",
["simdutf/_simdutf.pyx"],
include_dirs=[f"./dep/include", "./dep/include/simdutf"],
)
]
def get_dis():
with open("README.markdown", "r", encoding="utf-8") as f:
return f.read()
def get_version() -> str:
path = os.path.join(
os.path.abspath(os.path.dirname(__file__)), "simdutf", "__init__.py"
)
with open(path, "r", encoding="utf-8") as f:
data = f.read()
result = re.findall(r"(?<=__version__ = \")\S+(?=\")", data)
return result[0]
packages = find_packages(exclude=("test", "tests.*", "test*"))
def main():
version: str = get_version()
dis = get_dis()
setup(
name="simdutf",
version=version,
url="https://github.com/synodriver/simdutf",
packages=packages,
keywords=["simdutf"],
description="simdutf",
long_description_content_type="text/markdown",
long_description=dis,
author="synodriver",
author_email="diguohuangjiajinweijun@gmail.com",
python_requires=">=3.6",
install_requires=["cython"],
license="BSD",
classifiers=[
"Development Status :: 4 - Beta",
"Operating System :: OS Independent",
"License :: OSI Approved :: BSD License",
"Programming Language :: C++",
"Programming Language :: Cython",
"Programming Language :: Python",
"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",
"Programming Language :: Python :: Implementation :: CPython",
],
include_package_data=True,
zip_safe=False,
cmdclass={"build_ext": build_ext_compiler_check},
ext_modules=cythonize(
extensions,
compiler_directives={
"cdivision": True,
"embedsignature": True,
"boundscheck": False,
"wraparound": False,
},
),
)
if __name__ == "__main__":
main()