mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-12 13:41:48 +00:00
46 lines
911 B
Python
46 lines
911 B
Python
from distutils import sysconfig
|
|
import subprocess as subp
|
|
import os
|
|
import sys
|
|
from glob import glob
|
|
from pprint import pprint
|
|
pj = os.path.join
|
|
ex = os.path.exists
|
|
|
|
config = sysconfig.get_config_vars()
|
|
|
|
def fail():
|
|
pprint("no library found, dumping config:")
|
|
pprint(config)
|
|
raise SystemExit(1)
|
|
|
|
bindir = config.get("BINDIR")
|
|
|
|
python_config = pj(bindir, "python-config")
|
|
if not ex(python_config):
|
|
fail()
|
|
|
|
args = subp.check_output([python_config, "--ldflags"]).split()
|
|
|
|
libdir = []
|
|
lib = []
|
|
|
|
so_ext = config.get("SO")
|
|
|
|
for arg in args:
|
|
if arg.startswith("-L"):
|
|
libdir.append(arg[2:])
|
|
if arg.startswith("-l"):
|
|
lib.append(arg[2:])
|
|
|
|
for d in libdir:
|
|
for l in lib:
|
|
pattern = pj(d, "*" + l + "*" + so_ext)
|
|
match = glob(pattern)
|
|
if match:
|
|
assert len(match) == 1
|
|
sys.stdout.write(match[0])
|
|
raise SystemExit
|
|
|
|
fail()
|