-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.py
36 lines (27 loc) · 997 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
# pylint: disable=missing-function-docstring
import pathlib
from subprocess import check_call
from torch.utils.cpp_extension import BuildExtension, CppExtension
def build_libjpeg():
check_call("cd src/libjpeg && ./configure --enable-static --with-pic && make", shell=True)
def build(setup_kwargs):
build_libjpeg()
libjpeg_dir = pathlib.Path(__file__).parent.absolute() / "src" / "libjpeg"
setup_kwargs.update(
{
"ext_modules": [
CppExtension(
"torchjpeg.codec._codec_ops",
[
"src/torchjpeg/codec/codec_ops.cpp",
],
include_dirs=[str(libjpeg_dir)],
extra_objects=[str(libjpeg_dir / ".libs" / "libjpeg.a")],
extra_compile_args=["-std=c++17"],
)
],
"cmdclass": {"build_ext": BuildExtension},
}
)
if __name__ == "__main__":
build_libjpeg()