From 412918d12c12dca5acca813b37328bb280b68660 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 20 Oct 2022 10:35:18 -0400 Subject: [PATCH] feat: add entrypoint for cmake modules dir (#4258) Signed-off-by: Henry Schreiner Signed-off-by: Henry Schreiner --- setup.py | 2 ++ tests/extra_python_package/test_files.py | 2 ++ tools/setup_main.py.in | 3 +++ 3 files changed, 7 insertions(+) diff --git a/setup.py b/setup.py index 68573519c..9097440bf 100644 --- a/setup.py +++ b/setup.py @@ -144,6 +144,8 @@ with remove_output("pybind11/include", "pybind11/share"): stdout=sys.stdout, stderr=sys.stderr, ) + if not global_sdist: + Path("pybind11/share/cmake/pybind11/__init__.py").touch() txt = get_and_replace(setup_py, version=version, extra_cmd=extra_cmd) code = compile(txt, setup_py, "exec") diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index 8e1ddd850..caf320671 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -160,6 +160,7 @@ def test_build_sdist(monkeypatch, tmpdir): files |= {f"pybind11{n}" for n in local_sdist_files} files.add("pybind11.egg-info/entry_points.txt") files.add("pybind11.egg-info/requires.txt") + files.add("pybind11/share/cmake/pybind11/__init__.py") assert simpler == files with open(os.path.join(MAIN_DIR, "tools", "setup_main.py.in"), "rb") as f: @@ -246,6 +247,7 @@ def tests_build_wheel(monkeypatch, tmpdir): "dist-info/entry_points.txt", "dist-info/top_level.txt", } + files.add("pybind11/share/cmake/pybind11/__init__.py") with zipfile.ZipFile(str(wheel)) as z: names = z.namelist() diff --git a/tools/setup_main.py.in b/tools/setup_main.py.in index 65198bdb6..92ba04a95 100644 --- a/tools/setup_main.py.in +++ b/tools/setup_main.py.in @@ -36,6 +36,9 @@ setup( ], "pipx.run": [ "pybind11 = pybind11.__main__:main", + ], + "cmake.modules": [ + "pybind11 = pybind11.share.cmake.pybind11", ] }, cmdclass=cmdclass