mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Guess include and lib directory using capnp executable
This commit is contained in:
parent
a7efe4e3f8
commit
722579d671
2 changed files with 10 additions and 3 deletions
|
@ -148,7 +148,7 @@ def detect_version(basedir, compiler=None, **compiler_attrs):
|
|||
return props
|
||||
|
||||
|
||||
def test_build():
|
||||
def test_build(**compiler_attrs):
|
||||
"""do a test build of libcapnp"""
|
||||
tmp_dir = tempfile.mkdtemp()
|
||||
|
||||
|
@ -156,7 +156,7 @@ def test_build():
|
|||
# info("Configure: Autodetecting Cap'n Proto settings...")
|
||||
# info(" Custom Cap'n Proto dir: %s" % prefix)
|
||||
try:
|
||||
detected = detect_version(tmp_dir)
|
||||
detected = detect_version(tmp_dir, None, **compiler_attrs)
|
||||
finally:
|
||||
erase_dir(tmp_dir)
|
||||
|
||||
|
|
9
setup.py
9
setup.py
|
@ -11,6 +11,7 @@ import sys
|
|||
from distutils.command.clean import clean as _clean
|
||||
from distutils.errors import CompileError
|
||||
from distutils.extension import Extension
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
|
@ -113,10 +114,16 @@ class build_libcapnp_ext(build_ext_c):
|
|||
elif force_system_libcapnp:
|
||||
need_build = False
|
||||
else:
|
||||
# Try to use capnp executable to find include and lib path
|
||||
capnp_executable = find_executable("capnp")
|
||||
if capnp_executable:
|
||||
self.include_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'include')]
|
||||
self.library_dirs += [os.path.join(os.path.dirname(capnp_executable), '..', 'lib')]
|
||||
|
||||
# Try to autodetect presence of library. Requires compile/run
|
||||
# step so only works for host (non-cross) compliation
|
||||
try:
|
||||
test_build()
|
||||
test_build(include_dirs=self.include_dirs, library_dirs=self.library_dirs)
|
||||
need_build = False
|
||||
except CompileError:
|
||||
need_build = True
|
||||
|
|
Loading…
Add table
Reference in a new issue