Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ign-math6' into ahcorde/6/mecanu…
Browse files Browse the repository at this point in the history
…mDriveOdometry_pytohn
  • Loading branch information
ahcorde committed Oct 16, 2023
2 parents d1c70f2 + 9a5ad69 commit f23425e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
30 changes: 23 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,32 @@ endif()
if (SKIP_PYBIND11)
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
else()
include(IgnPython)
find_package(PythonLibs QUIET)
if (NOT PYTHONLIBS_FOUND)
IGN_BUILD_WARNING("Python is missing: Python interfaces are disabled.")
message (STATUS "Searching for Python - not found.")
#include(IgnPython) TODO: allow to specify for what it should search and then
# the code below can be removed; e.g. pybind needs Interpreter and Development components
# see https://pybind11.readthedocs.io/en/stable/cmake/index.html#new-findpython-mode
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
set(IGN_PYTHON_VERSION "3")
find_package(PythonInterp ${IGN_PYTHON_VERSION} QUIET)
if(PYTHONINTERP_FOUND)
set(Python3_FOUND ${PYTHONINTERP_FOUND})
set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND})
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
find_package(PythonLibs QUIET)
# we found the interpreter but did we also find the libs? both are required
set(Python3_FOUND ${PYTHONLIBS_FOUND})
set(Python3_VERSION ${PYTHONLIBS_VERSION_STRING})
endif()
else()
find_package(Python3 QUIET COMPONENTS Interpreter Development)
endif()

if (NOT Python3_FOUND)
IGN_BUILD_WARNING("Python3 is missing: Python interfaces are disabled.")
message (STATUS "Searching for Python3 - not found.")
else()
message (STATUS "Searching for Python - found version ${PYTHONLIBS_VERSION_STRING}.")
message (STATUS "Searching for Python3 - found version ${Python3_VERSION}.")

set(PYBIND11_PYTHON_VERSION 3)
find_package(Python3 QUIET COMPONENTS Interpreter Development)
find_package(pybind11 2.2 QUIET)

if (${pybind11_FOUND})
Expand Down
5 changes: 4 additions & 1 deletion include/gz/math/Helpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,10 @@ namespace ignition
dayString.erase(dayString.length() - 1);
try
{
std::stoi(dayString);
// We are only checking if it sucessfully parses,
// and are not concerned with the actual value.
auto day = std::stoi(dayString);
(void) day;
}
catch (const std::out_of_range &)
{
Expand Down
21 changes: 11 additions & 10 deletions src/python_pybind11/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# pybind11 logic for setting up a debug build when both a debug and release
# python interpreter are present in the system seems to be pretty much broken.
# This works around the issue.
set(PYTHON_LIBRARIES "${PYTHON_DEBUG_LIBRARIES}")
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
# TODO: remove once the minimum CMake version is increased
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# pybind11 logic for setting up a debug build when both a debug and release
# python interpreter are present in the system seems to be pretty much broken.
# This works around the issue.
set(PYTHON_LIBRARIES "${PYTHON_DEBUG_LIBRARIES}")
endif()
endif()

message(STATUS "Building pybind11 interfaces")
Expand Down Expand Up @@ -57,17 +60,15 @@ target_link_libraries(math PRIVATE
)

if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
# Get install variable from Python3 module
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
# Python3_SITEARCH is available via FindPython3 from 3.12 on, workaround if needed
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "if True:
COMMAND "${Python3_EXECUTABLE}" -c "if True:
from distutils import sysconfig as sc
print(sc.get_python_lib(plat_specific=True))"
OUTPUT_VARIABLE Python3_SITEARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
# Get install variable from Python3 module
# Python3_SITEARCH is available from 3.12 on, workaround if needed:
find_package(Python3 COMPONENTS Interpreter)
endif()

if(USE_DIST_PACKAGES_FOR_PYTHON)
Expand Down

0 comments on commit f23425e

Please sign in to comment.