-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
40 lines (37 loc) · 1.1 KB
/
setup.py
File metadata and controls
40 lines (37 loc) · 1.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
"""setup.py: Set configurations of setuptools."""
import itertools
import sys
from pathlib import Path
from subprocess import check_output
from setuptools import Extension, setup
if sys.platform == "darwin":
C_EXT_PATH = Path("csrc")
BREW_PATH = Path("/opt/homebrew/bin/brew")
LIBFFI_PREFIX = (
check_output(
["/opt/homebrew/bin/brew", "--prefix", "libffi"],
text=True,
).removesuffix("\n")
if Path("/opt/homebrew/bin/brew").is_file()
else None
)
setup(
ext_modules=[
Extension(
name="objctypes",
sources=itertools.chain(
C_EXT_PATH.glob("*.c"),
C_EXT_PATH.glob("*.cc"),
),
include_dirs=None
if LIBFFI_PREFIX is None
else [f"{LIBFFI_PREFIX}/include"],
library_dirs=None
if LIBFFI_PREFIX is None
else [f"{LIBFFI_PREFIX}/lib"],
libraries=None if LIBFFI_PREFIX is None else ["ffi"],
),
],
)
else:
setup()