2022-02-15 22:48:33 +00:00
|
|
|
# pylint: disable=missing-function-docstring
|
2024-06-22 04:55:00 +00:00
|
|
|
from __future__ import annotations
|
2022-02-15 22:48:33 +00:00
|
|
|
|
2017-06-23 16:40:43 +00:00
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
import sysconfig
|
|
|
|
|
2023-02-23 05:59:14 +00:00
|
|
|
from ._version import __version__
|
2022-08-09 04:02:45 +00:00
|
|
|
from .commands import get_cmake_dir, get_include, get_pkgconfig_dir
|
2017-06-23 16:40:43 +00:00
|
|
|
|
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
def print_includes() -> None:
|
2020-09-16 21:13:41 +00:00
|
|
|
dirs = [
|
|
|
|
sysconfig.get_path("include"),
|
|
|
|
sysconfig.get_path("platinclude"),
|
|
|
|
get_include(),
|
|
|
|
]
|
2017-08-23 14:59:10 +00:00
|
|
|
|
|
|
|
# Make unique but preserve order
|
|
|
|
unique_dirs = []
|
|
|
|
for d in dirs:
|
2020-10-14 18:08:41 +00:00
|
|
|
if d and d not in unique_dirs:
|
2017-08-23 14:59:10 +00:00
|
|
|
unique_dirs.append(d)
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
print(" ".join("-I" + d for d in unique_dirs))
|
2017-06-23 16:40:43 +00:00
|
|
|
|
|
|
|
|
2022-02-11 02:28:08 +00:00
|
|
|
def main() -> None:
|
2020-09-16 21:13:41 +00:00
|
|
|
parser = argparse.ArgumentParser()
|
2023-02-23 05:59:14 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--version",
|
|
|
|
action="version",
|
|
|
|
version=__version__,
|
|
|
|
help="Print the version and exit.",
|
|
|
|
)
|
2020-09-16 21:13:41 +00:00
|
|
|
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.",
|
|
|
|
)
|
2022-08-09 04:02:45 +00:00
|
|
|
parser.add_argument(
|
|
|
|
"--pkgconfigdir",
|
|
|
|
action="store_true",
|
|
|
|
help="Print the pkgconfig directory, ideal for setting $PKG_CONFIG_PATH.",
|
|
|
|
)
|
2017-06-23 16:40:43 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
if not sys.argv[1:]:
|
|
|
|
parser.print_help()
|
|
|
|
if args.includes:
|
|
|
|
print_includes()
|
2020-09-16 21:13:41 +00:00
|
|
|
if args.cmakedir:
|
|
|
|
print(get_cmake_dir())
|
2022-08-09 04:02:45 +00:00
|
|
|
if args.pkgconfigdir:
|
|
|
|
print(get_pkgconfig_dir())
|
2017-06-23 16:40:43 +00:00
|
|
|
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
if __name__ == "__main__":
|
2017-06-23 16:40:43 +00:00
|
|
|
main()
|