mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 13:45:10 +00:00
5bdd3d59be
* add installation support for pkg-config dependency detection pkg-config is a buildsystem-agnostic alternative to `pybind11Config.cmake` that can be used from build systems other than cmake. Fixes #230 * tests: add test for pkg config Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import os
|
|
|
|
DIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
def get_include(user: bool = False) -> str: # pylint: disable=unused-argument
|
|
"""
|
|
Return the path to the pybind11 include directory. The historical "user"
|
|
argument is unused, and may be removed.
|
|
"""
|
|
installed_path = os.path.join(DIR, "include")
|
|
source_path = os.path.join(os.path.dirname(DIR), "include")
|
|
return installed_path if os.path.exists(installed_path) else source_path
|
|
|
|
|
|
def get_cmake_dir() -> str:
|
|
"""
|
|
Return the path to the pybind11 CMake module directory.
|
|
"""
|
|
cmake_installed_path = os.path.join(DIR, "share", "cmake", "pybind11")
|
|
if os.path.exists(cmake_installed_path):
|
|
return cmake_installed_path
|
|
|
|
msg = "pybind11 not installed, installation required to access the CMake files"
|
|
raise ImportError(msg)
|
|
|
|
|
|
def get_pkgconfig_dir() -> str:
|
|
"""
|
|
Return the path to the pybind11 pkgconfig directory.
|
|
"""
|
|
pkgconfig_installed_path = os.path.join(DIR, "share", "pkgconfig")
|
|
if os.path.exists(pkgconfig_installed_path):
|
|
return pkgconfig_installed_path
|
|
|
|
msg = "pybind11 not installed, installation required to access the pkgconfig files"
|
|
raise ImportError(msg)
|