diff --git a/.gitmodules b/.gitmodules index ced1d11..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +0,0 @@ -[submodule "pybind11"] - path = pybind11 - url = https://github.com/pybind/pybind11.git - branch = master diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23dc004..30e5773 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: - id: mypy files: "setup.py" args: [] - additional_dependencies: [types-setuptools] + additional_dependencies: [types-setuptools, pybind11] # Changes tabs to spaces - repo: https://github.com/Lucas-C/pre-commit-hooks diff --git a/CMakeLists.txt b/CMakeLists.txt index 69122df..8eb2c68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.4...3.18) project(cmake_example) -add_subdirectory(pybind11) +find_package(pybind11) pybind11_add_module(cmake_example src/main.cpp) # EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a diff --git a/MANIFEST.in b/MANIFEST.in index 71dbebb..a1240fd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,3 @@ -include README.md LICENSE pybind11/LICENSE -graft pybind11/include -graft pybind11/tools +include README.md LICENSE graft src global-include CMakeLists.txt *.cmake diff --git a/pybind11 b/pybind11 deleted file mode 160000 index 914c06f..0000000 --- a/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 914c06fb252b6cc3727d0eedab6736e88a3fcb01 diff --git a/pyproject.toml b/pyproject.toml index fd92373..1dabc68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ requires = [ "wheel", "ninja", "cmake>=3.12", + "pybind11>=2.9.2", ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 03f97fb..3037bce 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ import sys from pathlib import Path +from pybind11 import get_cmake_dir from setuptools import Extension, setup from setuptools.command.build_ext import build_ext @@ -46,6 +47,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # from Python. cmake_args = [ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", + f"-Dpybind11_DIR={get_cmake_dir()}", f"-DPYTHON_EXECUTABLE={sys.executable}", f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm ]