Skip to content

Commit

Permalink
Rename python library as gz.sim7 (#1716)
Browse files Browse the repository at this point in the history
* Rename python bindings to gz.sim7
* Update imports of tests to use versioned

Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero authored Sep 16, 2022
1 parent 22b7852 commit 0df8e9e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 64 deletions.
6 changes: 5 additions & 1 deletion Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ message's header.
* `GZ_<PROJECT>_<VISIBLE/HIDDEN>`
* CMake `-config` files
* Paths that depend on the project name
* Python library `ignition` namespaces should be replaced with `gz`.

* Python library imports such `import ignition.gazebo` and `from ignition import
gazebo` should be replaced with `import gz.sim7` and `from gz import sim7`.
Note the change from `ignition` to `gz` and the addition of the major version
number as a suffix to the package name.

## Gazebo Sim 6.1 to 6.2

Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/python_api/testFixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import os

from gz.common import set_verbosity
from gz.sim import TestFixture, World, world_entity
from gz.math import Vector3d
from gz.sim7 import TestFixture, World, world_entity
from gz.math7 import Vector3d

set_verbosity(4)

Expand Down
51 changes: 6 additions & 45 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,10 @@ function(configure_build_install_location _library_name)
install(TARGETS ${_library_name}
DESTINATION "${GZ_PYTHON_INSTALL_PATH}"
)

# TODO(CH3): Deprecated. Remove on tock.
# Install Python library symlinks
if(${GZ_PYTHON_INSTALL_PATH} MATCHES "gz$")
cmake_policy(SET CMP0087 NEW) # Allow evaluation of generator expressions in install(CODE )
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/ignition")

string(REGEX REPLACE "gz$" "ignition" IGN_PYTHON_INSTALL_PATH ${GZ_PYTHON_INSTALL_PATH})
if (WIN32) # Windows requires copy instead of symlink
install(TARGETS ${_library_name}
DESTINATION "${IGN_PYTHON_INSTALL_PATH}"
)
else()
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
../gz/$<TARGET_FILE_NAME:${_library_name}> \
${PROJECT_BINARY_DIR}\/ignition/$<TARGET_FILE_NAME:${_library_name}>)")
install(FILES ${PROJECT_BINARY_DIR}\/ignition/$<TARGET_FILE_NAME:${_library_name}>
DESTINATION "${IGN_PYTHON_INSTALL_PATH}/"
)
endif()
endif()

endfunction()

# TODO(CH3): Deprecated. Remove on tock. Duplicating to reduce work...
pybind11_add_module(gazebo SHARED
set(BINDINGS_MODULE_NAME "sim${PROJECT_VERSION_MAJOR}")
pybind11_add_module(${BINDINGS_MODULE_NAME} SHARED
src/gz/sim/_gz_sim_pybind11.cc
src/gz/sim/EntityComponentManager.cc
src/gz/sim/EventManager.cc
Expand All @@ -73,28 +51,13 @@ pybind11_add_module(gazebo SHARED
src/gz/sim/World.cc
)

# TODO(CH3): Deprecated. Remove on tock. Duplicating to reduce work...
target_link_libraries(gazebo PRIVATE
target_link_libraries(${BINDINGS_MODULE_NAME} PRIVATE
${PROJECT_LIBRARY_TARGET_NAME}
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
)

pybind11_add_module(sim SHARED
src/gz/sim/_gz_sim_pybind11.cc
src/gz/sim/EntityComponentManager.cc
src/gz/sim/EventManager.cc
src/gz/sim/TestFixture.cc
src/gz/sim/Server.cc
src/gz/sim/ServerConfig.cc
src/gz/sim/UpdateInfo.cc
src/gz/sim/Util.cc
src/gz/sim/World.cc
)

target_link_libraries(sim PRIVATE
${PROJECT_LIBRARY_TARGET_NAME}
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
)
target_compile_definitions(${BINDINGS_MODULE_NAME} PRIVATE
BINDINGS_MODULE_NAME=${BINDINGS_MODULE_NAME})

# TODO(ahcorde): Move this module to gz-common
pybind11_add_module(common SHARED
Expand All @@ -106,8 +69,7 @@ target_link_libraries(common PRIVATE
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
)

configure_build_install_location(gazebo) # TODO(CH3): Deprecated. Remove on tock.
configure_build_install_location(sim)
configure_build_install_location(${BINDINGS_MODULE_NAME})
configure_build_install_location(common)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
Expand All @@ -117,7 +79,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(${pybind11_VERSION} VERSION_LESS "2.4.4")
target_compile_options(common PRIVATE -fsized-deallocation)
target_compile_options(sim PRIVATE -fsized-deallocation)
target_compile_options(gazebo PRIVATE -fsized-deallocation) # TODO(CH3): Deprecated. Remove on tock.
endif()
endif()

Expand Down
15 changes: 1 addition & 14 deletions python/src/gz/sim/_gz_sim_pybind11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,7 @@
#include "Util.hh"
#include "World.hh"

PYBIND11_MODULE(sim, m) {
m.doc() = "Gazebo Sim Python Library.";

gz::sim::python::defineSimEntityComponentManager(m);
gz::sim::python::defineSimEventManager(m);
gz::sim::python::defineSimServer(m);
gz::sim::python::defineSimServerConfig(m);
gz::sim::python::defineSimTestFixture(m);
gz::sim::python::defineSimUpdateInfo(m);
gz::sim::python::defineSimWorld(m);
gz::sim::python::defineSimUtil(m);
}

PYBIND11_MODULE(gazebo, m) { // TODO(CH3): Deprecated. Remove on tock.
PYBIND11_MODULE(BINDINGS_MODULE_NAME, m) {
m.doc() = "Gazebo Sim Python Library.";

gz::sim::python::defineSimEntityComponentManager(m);
Expand Down
4 changes: 2 additions & 2 deletions python/test/testFixture_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import unittest

from gz.common import set_verbosity
from gz.sim import TestFixture, World, world_entity
from gz.math import Vector3d
from gz.sim7 import TestFixture, World, world_entity
from gz.math7 import Vector3d

post_iterations = 0
iterations = 0
Expand Down

0 comments on commit 0df8e9e

Please sign in to comment.