__main__.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- coding: utf-8 -*-
  2. from __future__ import print_function
  3. import argparse
  4. import sys
  5. import sysconfig
  6. from .commands import get_include, get_cmake_dir
  7. def print_includes():
  8. # type: () -> None
  9. dirs = [
  10. sysconfig.get_path("include"),
  11. sysconfig.get_path("platinclude"),
  12. get_include(),
  13. ]
  14. # Make unique but preserve order
  15. unique_dirs = []
  16. for d in dirs:
  17. if d and d not in unique_dirs:
  18. unique_dirs.append(d)
  19. print(" ".join("-I" + d for d in unique_dirs))
  20. def main():
  21. # type: () -> None
  22. parser = argparse.ArgumentParser()
  23. parser.add_argument(
  24. "--includes",
  25. action="store_true",
  26. help="Include flags for both pybind11 and Python headers.",
  27. )
  28. parser.add_argument(
  29. "--cmakedir",
  30. action="store_true",
  31. help="Print the CMake module directory, ideal for setting -Dpybind11_ROOT in CMake.",
  32. )
  33. args = parser.parse_args()
  34. if not sys.argv[1:]:
  35. parser.print_help()
  36. if args.includes:
  37. print_includes()
  38. if args.cmakedir:
  39. print(get_cmake_dir())
  40. if __name__ == "__main__":
  41. main()