mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 01:15:52 +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>
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
# pylint: disable=missing-function-docstring
|
|
|
|
import argparse
|
|
import sys
|
|
import sysconfig
|
|
|
|
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
|
|
|
|
|
|
def print_includes() -> None:
|
|
dirs = [
|
|
sysconfig.get_path("include"),
|
|
sysconfig.get_path("platinclude"),
|
|
get_include(),
|
|
]
|
|
|
|
# Make unique but preserve order
|
|
unique_dirs = []
|
|
for d in dirs:
|
|
if d and d not in unique_dirs:
|
|
unique_dirs.append(d)
|
|
|
|
print(" ".join("-I" + d for d in unique_dirs))
|
|
|
|
|
|
def main() -> None:
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"--includes",
|
|
action="store_true",
|
|
help="Include flags for both pybind11 and Python headers.",
|
|
)
|
|
parser.add_argument(
|
|
"--cmakedir",
|
|
action="store_true",
|
|
help="Print the CMake module directory, ideal for setting -Dpybind11_ROOT in CMake.",
|
|
)
|
|
parser.add_argument(
|
|
"--pkgconfigdir",
|
|
action="store_true",
|
|
help="Print the pkgconfig directory, ideal for setting $PKG_CONFIG_PATH.",
|
|
)
|
|
args = parser.parse_args()
|
|
if not sys.argv[1:]:
|
|
parser.print_help()
|
|
if args.includes:
|
|
print_includes()
|
|
if args.cmakedir:
|
|
print(get_cmake_dir())
|
|
if args.pkgconfigdir:
|
|
print(get_pkgconfig_dir())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|