forked from jiaaro/pydub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
37 lines (29 loc) · 872 Bytes
/
build.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
import shutil
from pathlib import Path
from Cython.Build import cythonize
from setuptools import Distribution, Extension
from setuptools.command.build_ext import build_ext
def build() -> None:
extensions = [
Extension(
"*",
sources=["pydub/*.pyx"],
include_dirs=[],
extra_compile_args=["-march=native", "-O3"],
)
]
ext_modules = cythonize(
module_list=extensions,
compiler_directives={
"language_level": "3",
},
)
distribution = Distribution({"ext_modules": ext_modules})
cmd = build_ext(distribution)
cmd.finalize_options()
cmd.run()
for output in cmd.get_outputs():
relative_extension = Path(output).relative_to(cmd.build_lib)
shutil.copyfile(output, relative_extension)
if __name__ == "__main__":
build()