forked from pypa/auditwheel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
42 lines (33 loc) · 1.2 KB
/
Copy pathsetup.py
File metadata and controls
42 lines (33 loc) · 1.2 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
42
from __future__ import annotations
import os
import subprocess
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
USE_DTAGS = os.getenv("DTAG") != "none"
class BuildExt(build_ext):
def run(self) -> None:
use_runpath = os.getenv("DTAG") == "runpath"
dtags_kind_flag = "--enable-new-dtags" if use_runpath else "--disable-new-dtags"
dtags = f"-Wl,{dtags_kind_flag} -Wl,-rpath=$ORIGIN/../b" if USE_DTAGS else ""
cmd = f"gcc -fPIC -shared -o b/libb.so {dtags} b/b.c"
subprocess.check_call(cmd.split())
dtags = f"-Wl,{dtags_kind_flag} -Wl,-rpath=$ORIGIN/../b" if USE_DTAGS else ""
cmd = f"gcc -fPIC -shared -o a/liba.so {dtags} -Ib a/a.c -Lb -lb"
subprocess.check_call(cmd.split())
super().run()
setup(
name="testrpath",
version="0.0.1",
packages=["testrpath"],
package_dir={"": "src"},
cmdclass={"build_ext": BuildExt},
ext_modules=[
Extension(
"testrpath/testrpath",
sources=["src/testrpath/testrpath.c"],
include_dirs=["a"],
libraries=["a"],
library_dirs=["a"] if USE_DTAGS else ["a", "b"],
),
],
)