File indexing completed on 2025-01-18 10:17:50
0001
0002
0003 import argparse
0004 import sys
0005 import sysconfig
0006
0007 from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
0008
0009
0010 def print_includes() -> None:
0011 dirs = [
0012 sysconfig.get_path("include"),
0013 sysconfig.get_path("platinclude"),
0014 get_include(),
0015 ]
0016
0017
0018 unique_dirs = []
0019 for d in dirs:
0020 if d and d not in unique_dirs:
0021 unique_dirs.append(d)
0022
0023 print(" ".join("-I" + d for d in unique_dirs))
0024
0025
0026 def main() -> None:
0027
0028 parser = argparse.ArgumentParser()
0029 parser.add_argument(
0030 "--includes",
0031 action="store_true",
0032 help="Include flags for both pybind11 and Python headers.",
0033 )
0034 parser.add_argument(
0035 "--cmakedir",
0036 action="store_true",
0037 help="Print the CMake module directory, ideal for setting -Dpybind11_ROOT in CMake.",
0038 )
0039 parser.add_argument(
0040 "--pkgconfigdir",
0041 action="store_true",
0042 help="Print the pkgconfig directory, ideal for setting $PKG_CONFIG_PATH.",
0043 )
0044 args = parser.parse_args()
0045 if not sys.argv[1:]:
0046 parser.print_help()
0047 if args.includes:
0048 print_includes()
0049 if args.cmakedir:
0050 print(get_cmake_dir())
0051 if args.pkgconfigdir:
0052 print(get_pkgconfig_dir())
0053
0054
0055 if __name__ == "__main__":
0056 main()