Skip to content

Commit

Permalink
[pybind11] update to v2.10.4 (microsoft#32194)
Browse files Browse the repository at this point in the history
* [pybind11] update to v2.10.4, clean-up redundant dependency, add usage
  • Loading branch information
yurybura authored Jul 10, 2023
1 parent 34869a0 commit 1ec3d05
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 39 deletions.
14 changes: 4 additions & 10 deletions ports/pybind11/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pybind/pybind11
REF "v${VERSION}"
SHA512 3894400f04cd08e2dbb14b3d696339f0364434f1d6f8bb057338ac88157ec7491b2df1e1e46ebd5abccdcd5775c5e9238de6404f0db87f64f5a1802db3a5b18c
SHA512 7970defbb6d057a44468ed707c80bfa6ef8c9578528fbc084b03aeea20a52dbd681581f82d55ff90af11ee89693379bd79e2ab6603239ba05b0aa8da29dd93c7
HEAD_REF master
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DPYBIND11_TEST=OFF
-DPYBIND11_FINDPYTHON=ON
OPTIONS_RELEASE
-DPYTHON_IS_DEBUG=OFF
OPTIONS_DEBUG
-DPYTHON_IS_DEBUG=ON
# Disable all Python searching, Python required only for tests
-DPYBIND11_NOPYTHON=ON
)

vcpkg_cmake_install()
Expand All @@ -23,8 +20,5 @@ vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/")

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/pybind11/pybind11Tools.cmake"
[=[find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})]=]
[=[find_package(PythonLibs ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})]=]) # CMake's PythonLibs works better with vcpkg

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
23 changes: 23 additions & 0 deletions ports/pybind11/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pybind11 provides CMake targets. There are two modes provided; classic, which is built on the old Python
discovery packages in CMake, or the new FindPython mode, which uses FindPython
from 3.12+ forward (3.15+ _highly_ recommended).

New FindPython mode:

find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG)

# pybind11 method:
pybind11_add_module(MyModule1 src1.cpp)

# Python method:
Python_add_library(MyModule2 src2.cpp)
target_link_libraries(MyModule2 pybind11::headers)
set_target_properties(MyModule2 PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ON
CXX_VISIBILITY_PRESET ON
VISIBILITY_INLINES_HIDDEN ON
)

For more information see here:
https://pybind11.readthedocs.io/en/latest/compiling.html#building-with-cmake
3 changes: 1 addition & 2 deletions ports/pybind11/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "pybind11",
"version": "2.10.3",
"version": "2.10.4",
"description": "pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code",
"homepage": "https://github.com/pybind/pybind11",
"license": "BSD-3-Clause",
"supports": "!(arm & windows)",
"dependencies": [
"python3",
{
"name": "vcpkg-cmake",
"host": true
Expand Down
25 changes: 25 additions & 0 deletions ports/shiva/find_python_and_no_copy_dll.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt
index eef14ee..30130ba 100644
--- a/modules/python/CMakeLists.txt
+++ b/modules/python/CMakeLists.txt
@@ -1,10 +1,10 @@
include(CMakeSources.cmake)
set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

+find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG REQUIRED)

-
-if (WIN32)
+if (FALSE)
## We need pyton dll
file(GLOB PYTHON_DLL ${PYTHON_LIBRARIES}/../*.dll)

@@ -19,6 +19,6 @@ endif ()

CREATE_MODULE(shiva::pyscripting "${MODULE_SOURCES}" ${MODULE_PATH} "python")

-target_link_libraries(pyscripting INTERFACE shiva::ecs shiva::input pybind11::embed pybind11::module)
+target_link_libraries(pyscripting INTERFACE shiva::ecs shiva::input pybind11::embed pybind11::module Python::Module)

AUTO_TARGETS_MODULE_INSTALL(pyscripting)
13 changes: 0 additions & 13 deletions ports/shiva/no_copy_dll.patch

This file was deleted.

17 changes: 8 additions & 9 deletions ports/shiva/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Milerius/shiva
REF 1.0
SHA512 d1ce33e89b17fa8f82e21b51dfa1308e38c617fea52c34a20b7b6c8643318280df24c043238ddd73ba2dbc139c5b5de1c2cb3add1f5629a54694c78b415d73d1
HEAD_REF master
PATCHES no_copy_dll.patch
OUT_SOURCE_PATH SOURCE_PATH
REPO Milerius/shiva
REF ${VERSION}
SHA512 d1ce33e89b17fa8f82e21b51dfa1308e38c617fea52c34a20b7b6c8643318280df24c043238ddd73ba2dbc139c5b5de1c2cb3add1f5629a54694c78b415d73d1
HEAD_REF master
PATCHES find_python_and_no_copy_dll.patch
)

find_library(PYTHON_RELEASE NAMES python310 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
Expand All @@ -23,8 +23,7 @@ vcpkg_cmake_configure(
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/shiva")
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug" "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/shiva")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/shiva/LICENSE" "${CURRENT_PACKAGES_DIR}/share/shiva/copyright")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
5 changes: 4 additions & 1 deletion ports/shiva/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "shiva",
"version": "1.0",
"port-version": 5,
"port-version": 6,
"description": "Modern C++ Game Engine",
"homepage": "https://github.com/Milerius/shiva",
"license": "MIT",
"supports": "!(static & windows)",
"dependencies": [
"boost-dll",
"boost-filesystem",
Expand All @@ -16,6 +18,7 @@
},
"nlohmann-json",
"pybind11",
"python3",
"sol2",
"spdlog",
{
Expand Down
2 changes: 0 additions & 2 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1378,8 +1378,6 @@ septag-sx:x64-uwp=fail
sfml:arm-neon-android=fail
sfml:arm64-android=fail
sfml:x64-android=fail
shiva:x64-windows-static=fail
shiva:x64-windows-static-md=fail
shiva-sfml:x64-linux=fail
shiva-sfml:x64-osx=fail
shiva-sfml:arm64-osx=fail
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6545,7 +6545,7 @@
"port-version": 0
},
"pybind11": {
"baseline": "2.10.3",
"baseline": "2.10.4",
"port-version": 0
},
"pystring": {
Expand Down Expand Up @@ -7506,7 +7506,7 @@
},
"shiva": {
"baseline": "1.0",
"port-version": 5
"port-version": 6
},
"shiva-sfml": {
"baseline": "1.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/pybind11.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "ed50c1b3263ecefd48d008f522bf966c9e4347d1",
"version": "2.10.4",
"port-version": 0
},
{
"git-tree": "a3b13210bfd5f8dcbab60336dd54f0ed7230c5c3",
"version": "2.10.3",
Expand Down
5 changes: 5 additions & 0 deletions versions/s-/shiva.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1f99562a0a906db852e4ff3a7caf03ad4c4fbcab",
"version": "1.0",
"port-version": 6
},
{
"git-tree": "821cf61c76079cfd5c7a635dc36e01c0f33c38f5",
"version": "1.0",
Expand Down

0 comments on commit 1ec3d05

Please sign in to comment.