From 5038bbaf68233c23919a6e5703f9a70b590e5c4a Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Thu, 6 Mar 2025 00:42:35 -0500 Subject: [PATCH] Add pkgconf-pypi entrypoint - This allows `pkgconf --cflags pybind11` and similar commands to work as expected if pkgconf is installed from pypi --- setup.py | 4 ++++ tests/extra_python_package/test_files.py | 2 ++ tools/setup_main.py.in | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 96563c1a59..c65bbc6274 100644 --- a/setup.py +++ b/setup.py @@ -144,6 +144,10 @@ def remove_output(*sources: str) -> Generator[None, None, None]: stderr=sys.stderr, ) + # pkgconf-pypi needs pybind11/share/pkgconfig to be importable + Path("pybind11/share/__init__.py").touch() + Path("pybind11/share/pkgconfig/__init__.py").touch() + txt = get_and_replace(setup_py, version=version, extra_cmd=extra_cmd) code = compile(txt, setup_py, "exec") exec(code, {"SDist": SDist}) diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index b01b49867f..5d7299c2ac 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -106,6 +106,8 @@ "commands.py", "py.typed", "setup_helpers.py", + "share/__init__.py", + "share/pkgconfig/__init__.py", } headers = main_headers | conduit_headers | detail_headers | eigen_headers | stl_headers diff --git a/tools/setup_main.py.in b/tools/setup_main.py.in index eb7b84ed6a..e04dc82049 100644 --- a/tools/setup_main.py.in +++ b/tools/setup_main.py.in @@ -18,6 +18,7 @@ setup( "pybind11.include.pybind11.detail", "pybind11.include.pybind11.eigen", "pybind11.include.pybind11.stl", + "pybind11.share", "pybind11.share.cmake.pybind11", "pybind11.share.pkgconfig", ], @@ -40,7 +41,10 @@ setup( ], "pipx.run": [ "pybind11 = pybind11.__main__:main", - ] + ], + "pkg_config": [ + "pybind11 = pybind11.share.pkgconfig", + ], }, cmdclass=cmdclass )