From 20f37d8ff886c0f325a429a7ffaa29a0f390be6a Mon Sep 17 00:00:00 2001 From: Nikul Patel Date: Sun, 8 Sep 2024 13:08:53 +0100 Subject: [PATCH 1/2] fix docs build command on different global and venv python versions --- docs/basics.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basics.rst b/docs/basics.rst index cd97c100ec..74b24cfe10 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -142,7 +142,7 @@ On Linux, the above example can be compiled using the following command: .. code-block:: bash - $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) + $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))') .. note:: From 8ccca8d333aec6150b843b74fd33a40c0f3ee3a3 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 27 Sep 2024 17:15:38 -0400 Subject: [PATCH 2/2] feat: add --extension-suffix Signed-off-by: Henry Schreiner --- docs/basics.rst | 2 +- pybind11/__main__.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/basics.rst b/docs/basics.rst index 74b24cfe10..c7a0208c4c 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -142,7 +142,7 @@ On Linux, the above example can be compiled using the following command: .. code-block:: bash - $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))') + $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3 -m pybind11 --extension-suffix) .. note:: diff --git a/pybind11/__main__.py b/pybind11/__main__.py index 0abc7e2117..28be9f165b 100644 --- a/pybind11/__main__.py +++ b/pybind11/__main__.py @@ -71,6 +71,11 @@ def main() -> None: action="store_true", help="Print the pkgconfig directory, ideal for setting $PKG_CONFIG_PATH.", ) + parser.add_argument( + "--extension-suffix", + action="store_true", + help="Print the extension for a Python module", + ) args = parser.parse_args() if not sys.argv[1:]: parser.print_help() @@ -80,6 +85,8 @@ def main() -> None: print(quote(get_cmake_dir())) if args.pkgconfigdir: print(quote(get_pkgconfig_dir())) + if args.extension_suffix: + print(sysconfig.get_config_var("EXT_SUFFIX")) if __name__ == "__main__":