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

Deprecate GzPython.cmake #431

Merged
merged 2 commits into from
Jun 1, 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
3 changes: 3 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ release will remove the deprecated code.
The change deprecates the HIDDEN_SYMBOLS_BY_DEFAULT flag that can be
removed.

1. **Deprecated**: `GzPython.cmake`
**Replacement**: Use `find_package(Python3)` to find Python3 and the
`Python3_EXECUTABLE` variable instead of `PYTHON_EXECUTABLE`.

## Gazebo CMake 2.X to 3.X

Expand Down
4 changes: 3 additions & 1 deletion cmake/GzBuildTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ macro(gz_build_tests)

# Find the Python interpreter for running the
# check_test_ran.py script
include(GzPython)
if(NOT Python3_Interpreter_FOUND)
find_package(Python3 COMPONENTS Interpreter)
endif()

# Build all the tests
foreach(target_name ${test_list})
Expand Down
4 changes: 3 additions & 1 deletion cmake/GzCodeCheck.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Setup the codecheck target, which will run cppcheck and cppplint.
# This function is private to gz-cmake.
function(_gz_setup_target_for_codecheck)
include(GzPython)
if(NOT Python3_Interpreter_FOUND)
find_package(Python3 COMPONENTS Interpreter)
endif()

find_program(CPPCHECK_PATH cppcheck)
find_program(FIND_PATH find)
Expand Down
27 changes: 4 additions & 23 deletions cmake/GzPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
set(GZ_PYTHON_VERSION "" CACHE STRING
"Specify specific Python3 version to use ('major.minor' or 'versionMin...[<]versionMax')")
message(WARNING "GzPython is deprecated, use find_package(Python3) instead.")

find_package(Python3 ${GZ_PYTHON_VERSION} QUIET)
elseif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")
# no support for finding specific versions
find_package(Python3 QUIET)
else()
# TODO: remove this block as soon as the CMake version can safely be bumped to => 3.12
set(GZ_PYTHON_VERSION "" CACHE STRING
"Specify specific Python version to use ('major.minor' or 'major')")
set(GZ_PYTHON_VERSION "" CACHE STRING
"Specify specific Python3 version to use ('major.minor' or 'versionMin...[<]versionMax')")

# if not specified otherwise use Python 3
if(NOT GZ_PYTHON_VERSION)
set(GZ_PYTHON_VERSION "3")
endif()

find_package(PythonInterp ${GZ_PYTHON_VERSION} QUIET)

if(PYTHONINTERP_FOUND)
set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND})
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
endif()
find_package(Python3 ${GZ_PYTHON_VERSION} QUIET)

# Tick-tock PYTHON_EXECUTABLE until Python3_EXECUTABLE is released
# TODO(jrivero) gz-cmake4: start the deprecation cycle of PYTHON_EXECUTABLE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed some uses of PYTHON_EXECUTABLE; I'll clean those up before merging this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primarily here: https://github.com/gazebosim/gz-sim/blob/main/python/CMakeLists.txt#L12

that's old cmake code that will be removed as part of #350, so actually it shouldn't be a problem

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be removed in gazebosim/gz-sim#2420

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that has been merged, so I'll merge this as well

Expand Down