Skip to content
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

Fix find Python3 logic and macOS workflow #1367

Merged
merged 3 commits into from
Jan 31, 2024
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
14 changes: 7 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
# Workaround for https://github.com/actions/setup-python/issues/577
- name: Clean up python binaries
run: |
rm -f /usr/local/bin/2to3*;
rm -f /usr/local/bin/idle3*;
rm -f /usr/local/bin/pydoc3*;
rm -f /usr/local/bin/python3*;
rm -f /usr/local/bin/python3*-config;
rm -f $(brew --prefix)/bin/2to3*;
rm -f $(brew --prefix)/bin/idle3*;
rm -f $(brew --prefix)/bin/pydoc3*;
rm -f $(brew --prefix)/bin/python3*;
rm -f $(brew --prefix)/bin/python3*-config;
- name: Install base dependencies
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
Expand All @@ -50,8 +50,8 @@ jobs:
- name: cmake
working-directory: build
run: |
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/${PACKAGE}/HEAD
export PYTHONPATH=$PYTHONPATH:$(brew --prefix)/lib/python
cmake .. -DCMAKE_INSTALL_PREFIX=$(brew --prefix)/Cellar/${PACKAGE}/HEAD -DPython3_EXECUTABLE=$(brew --prefix)/bin/python3
- run: make
working-directory: build
- run: make test
Expand Down
49 changes: 25 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,33 @@ if (BUILD_SDF)
# available during build time
set(GZ_TOOLS_VER 2)

#################################################
# Find python
if (SKIP_PYBIND11)
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
find_package(Python3 REQUIRED COMPONENTS Interpreter)
else()
find_package(Python3 REQUIRED
COMPONENTS Interpreter
OPTIONAL_COMPONENTS Development
)
if (NOT Python3_Development_FOUND)
GZ_BUILD_WARNING("Python development libraries are missing: Python interfaces are disabled.")
else()
set(PYBIND11_PYTHON_VERSION 3)
find_package(pybind11 2.4 CONFIG QUIET)

if (pybind11_FOUND)
message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION}.")
else()
GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled.")
message (STATUS "Searching for pybind11 - not found.")
endif()
endif()
endif()

#################################################
# Copied from catkin/cmake/empy.cmake
include(GzPython)
function(find_python_module module)
# cribbed from http://www.cmake.org/pipermail/cmake/2011-January/041666.html
string(TOUPPER ${module} module_upper)
Expand Down Expand Up @@ -121,29 +145,6 @@ if (BUILD_SDF)
gz_find_package(gz-utils3 REQUIRED COMPONENTS cli)
set(GZ_UTILS_VER ${gz-utils3_VERSION_MAJOR})

########################################
# Python interfaces
if (NOT PYTHON3_FOUND)
GZ_BUILD_ERROR("Python is missing - Needed to build/embed xml schemas")
else()
message (STATUS "Searching for Python - found version ${Python3_VERSION}.")

if (SKIP_PYBIND11)
message(STATUS "SKIP_PYBIND11 set - disabling python bindings")
else()
set(PYBIND11_PYTHON_VERSION 3)
find_package(pybind11 2.4 QUIET)

if (${pybind11_FOUND})
find_package(Python3 ${GZ_PYTHON_VERSION} REQUIRED COMPONENTS Development)
message (STATUS "Searching for pybind11 - found version ${pybind11_VERSION}.")
else()
GZ_BUILD_WARNING("pybind11 is missing: Python interfaces are disabled.")
message (STATUS "Searching for pybind11 - not found.")
endif()
endif()
endif()

gz_configure_build(QUIT_IF_BUILD_ERRORS)

gz_create_packages()
Expand Down
Loading