_configtool.py 1007 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import argparse
  2. import sys
  3. from pathlib import Path
  4. from .lib._utils_impl import get_include
  5. from .version import __version__
  6. def main() -> None:
  7. parser = argparse.ArgumentParser()
  8. parser.add_argument(
  9. "--version",
  10. action="version",
  11. version=__version__,
  12. help="Print the version and exit.",
  13. )
  14. parser.add_argument(
  15. "--cflags",
  16. action="store_true",
  17. help="Compile flag needed when using the NumPy headers.",
  18. )
  19. parser.add_argument(
  20. "--pkgconfigdir",
  21. action="store_true",
  22. help=("Print the pkgconfig directory in which `numpy.pc` is stored "
  23. "(useful for setting $PKG_CONFIG_PATH)."),
  24. )
  25. args = parser.parse_args()
  26. if not sys.argv[1:]:
  27. parser.print_help()
  28. if args.cflags:
  29. print("-I" + get_include())
  30. if args.pkgconfigdir:
  31. _path = Path(get_include()) / '..' / 'lib' / 'pkgconfig'
  32. print(_path.resolve())
  33. if __name__ == "__main__":
  34. main()