Skip to content

fix: the Python package had a hard coded path #3144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ if(PYBIND11_INSTALL)
"${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}"
CACHE STRING "install path for pybind11Config.cmake")

if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(pybind11_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
else()
set(pybind11_INCLUDEDIR "\$\{PACKAGE_PREFIX_DIR\}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()

configure_package_config_file(
tools/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
Expand Down
14 changes: 12 additions & 2 deletions tests/extra_python_package/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ def test_build_sdist(monkeypatch, tmpdir):
) as f:
pyproject_toml = f.read()

with contextlib.closing(
tar.extractfile(
tar.getmember(
start + "pybind11/share/cmake/pybind11/pybind11Config.cmake"
)
)
) as f:
contents = f.read().decode("utf8")
assert 'set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")' in contents

files = {"pybind11/{}".format(n) for n in all_files}
files |= sdist_files
files |= {"pybind11{}".format(n) for n in local_sdist_files}
Expand All @@ -151,11 +161,11 @@ def test_build_sdist(monkeypatch, tmpdir):
.substitute(version=version, extra_cmd="")
.encode()
)
assert setup_py == contents
assert setup_py == contents

with open(os.path.join(MAIN_DIR, "tools", "pyproject.toml"), "rb") as f:
contents = f.read()
assert pyproject_toml == contents
assert pyproject_toml == contents


def test_build_global_dist(monkeypatch, tmpdir):
Expand Down
3 changes: 2 additions & 1 deletion tools/pybind11Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ Using ``find_package`` with version info is not recommended except for release v
@PACKAGE_INIT@

# Location of pybind11/pybind11.h
set(pybind11_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
# This will be relative unless explicitly set as absolute
set(pybind11_INCLUDE_DIR "@pybind11_INCLUDEDIR@")

set(pybind11_LIBRARY "")
set(pybind11_DEFINITIONS USING_pybind11)
Expand Down