-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_setup.py
More file actions
41 lines (36 loc) · 1 KB
/
build_setup.py
File metadata and controls
41 lines (36 loc) · 1 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
import sys, os, shutil
from setuptools import Extension, setup
ext_modules = [
Extension(
"bpe",
sources=[
"src/bpe_module.c",
"src/_tree_core.c",
"src/bpe_common.c",
"src/bpe_trainer.c",
"src/bpe_tokenizer.c",
],
depends=[
"src/_tree_core.h",
"src/bpe_common.h",
"src/bpe_trainer.h",
"src/bpe_tokenizer.h",
],
extra_compile_args={"win32": []}.get(sys.platform, ["-Werror", "-std=c99"]),
)
]
setup(
name="tinybpe",
ext_modules=ext_modules
)
bpe_dylib_path = None
for root, dirs, files in os.walk("build"):
for file in files:
if (file.endswith(".pyd") or file.endswith(".so") or file.endswith(".dylib")) \
and file.startswith("bpe"):
bpe_dylib_path = os.path.join(root, file)
break
if bpe_dylib_path is not None:
shutil.copy(bpe_dylib_path, "tinybpe")
else:
raise RuntimeError("Error ...")