This repository has been archived by the owner on May 30, 2024. It is now read-only.
forked from flupke/pypotrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
58 lines (47 loc) · 1.48 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import subprocess
import shlex
from setuptools import Extension
from Cython.Build import cythonize
import numpy as np
def pkg_config(pkg_name, command):
return subprocess.check_output(["pkg-config", command, pkg_name]).decode(
"utf8"
)
def build(setup_kwargs):
"""Needed for the poetry building interface."""
extra_compile_args = pkg_config("libagg", '--cflags')
extra_link_args = pkg_config("libagg", '--libs')
extra_compile_args = shlex.split(extra_compile_args)
extra_link_args = shlex.split(extra_link_args)
print(extra_compile_args)
print(extra_link_args)
extensions = [
Extension(
"potrace._potrace",
sources=["potrace/_potrace.pyx"],
include_dirs=[np.get_include()],
libraries=["potrace"],
),
Extension(
"potrace.bezier",
sources=["potrace/bezier.pyx"],
include_dirs=[np.get_include()],
language="c++",
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
"potrace.agg.curves",
sources=["potrace/agg/curves.pyx"],
language="c++",
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
]
extensions = cythonize(extensions)
setup_kwargs.update(
{
"ext_modules": extensions,
"include_dirs": [np.get_include()],
}
)