Skip to content

Commit e8964ea

Browse files
authored
Merge branch 'gz-math7' into scpeters/tutorial_install_macos_binary
2 parents 17218f4 + 860c546 commit e8964ea

59 files changed

Lines changed: 205 additions & 203 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ find_package(gz-cmake3 REQUIRED)
1717
set(CMAKE_CXX_STANDARD 17)
1818
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1919

20-
gz_configure_project(VERSION_SUFFIX pre1)
20+
gz_configure_project(VERSION_SUFFIX pre2)
2121

2222
#============================================================================
2323
# Set project-specific options

Migration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ release will remove the deprecated code.
1919
* CMake `-config` files
2020
* Paths that depend on the project name
2121

22+
1. Python library imports such `import ignition.math` and `from ignition import math` should be replaced with `import gz.math7` and `from gz import math7`. Note the change from `ignition` to `gz` and the addition of the major version number as a suffix to the package name.
23+
2224
### Deprecations
2325

2426
1. **Angle.hh**
@@ -89,7 +91,6 @@ release will remove the deprecated code.
8991
1. `IGN_MASSMATRIX3_DEFAULT_TOLERANCE`
9092
1. All `IGN_*_SIZE_T` variables are deprecated and will be removed in future versions.
9193
Please use `GZ_*_SIZE_T` instead.
92-
1. Python library `ignition` namespaces should be replaced with `gz`.
9394

9495

9596
### Modifications

examples/angle_example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
# $ export PYTHONPATH=/usr/lib/python:$PYTHONPATH
2222
#
2323

24-
import gz.math
24+
import gz.math7
2525

26-
print("PI in degrees = {}\n".format(gz.math.Angle.PI.degree()))
26+
print("PI in degrees = {}\n".format(gz.math7.Angle.PI.degree()))
2727

28-
a1 = gz.math.Angle(1.5707)
29-
a2 = gz.math.Angle(0.7854)
28+
a1 = gz.math7.Angle(1.5707)
29+
a2 = gz.math7.Angle(0.7854)
3030
print("a1 = {} radians, {} degrees\n".format(a1.radian(), a1.degree()))
3131
print("a2 = {} radians, {} degrees\n".format(a2.radian(), a2.degree()))
3232
print("a1 * a2 = {} radians, {} degrees\n".format((a1 * a2).radian(),
@@ -36,7 +36,7 @@
3636
print("a1 - a2 = {} radians, {} degrees\n".format((a1 - a2).radian(),
3737
(a1 - a2).degree()))
3838

39-
a3 = gz.math.Angle(15.707)
39+
a3 = gz.math7.Angle(15.707)
4040
print("a3 = {} radians, {} degrees\n".format(a3.radian(), a3.degree()))
4141
a3.normalize()
4242
print("a3.Normalize = {} radians, {} degrees\n".format(a3.radian(),

examples/diff_drive_odometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import datetime
2424
import math
2525

26-
from gz.math import Angle, DiffDriveOdometry
26+
from gz.math7 import Angle, DiffDriveOdometry
2727

2828
odom = DiffDriveOdometry()
2929

examples/gauss_markov_process_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# 2. Use gnuplot to create a plot:
2727
# gnuplot -e 'set terminal jpeg; plot "plot.data" with lines' > out.jpg
2828
import datetime
29-
from gz.math import GaussMarkovProcess
29+
from gz.math7 import GaussMarkovProcess
3030

3131
# Create the process with:
3232
# * Start value of 20.2

examples/kmeans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515

16-
from gz.math import Kmeans, Vector3d
16+
from gz.math7 import Kmeans, Vector3d
1717

1818
# Create some observations.
1919
obs = list([])

examples/rand_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# 2. Use gnuplot to create a plot:
2323
# gnuplot -c rand_view_normal.gp > normal.jpg
2424
# gnuplot -c rand_view_uniform.gp > uniform.jpg
25-
from gz.math import Rand
25+
from gz.math7 import Rand
2626
import sys
2727

2828
if (len(sys.argv) < 2):

examples/vector2_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
#
2121
# $ export PYTHONPATH=/usr/lib/python:$PYTHONPATH
2222
#
23-
import gz.math
23+
import gz.math7
2424

25-
va = gz.math.Vector2d(1, 2)
26-
vb = gz.math.Vector2d(3, 4)
27-
vc = gz.math.Vector2d(vb)
25+
va = gz.math7.Vector2d(1, 2)
26+
vb = gz.math7.Vector2d(3, 4)
27+
vc = gz.math7.Vector2d(vb)
2828

2929
print("va = {} {}\n".format(va.x(), va.y()))
3030
print("vb = {} {}\n".format(vb.x(), vb.y()))

examples/vector3_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#
2121
# $ export PYTHONPATH=/usr/lib/python:$PYTHONPATH
2222
#
23-
import gz.math
23+
import gz.math7
2424

25-
v1 = gz.math.Vector3d(0, 0, 3)
25+
v1 = gz.math7.Vector3d(0, 0, 3)
2626
print("v =: {} {} {}\n".format(v1.x(), v1.y(), v1.z()))
2727

28-
v2 = gz.math.Vector3d(4, 0, 0)
28+
v2 = gz.math7.Vector3d(4, 0, 0)
2929
print("v2 = {} {} {}\n".format(v2.x(), v2.y(), v2.z()))
3030

3131
v3 = v1 + v2

src/python_pybind11/CMakeLists.txt

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
66
endif()
77

88
message(STATUS "Building pybind11 interfaces")
9+
set(BINDINGS_MODULE_NAME "math${PROJECT_VERSION_MAJOR}")
910
# Split from main extension and converted to pybind11
10-
pybind11_add_module(math MODULE
11+
pybind11_add_module(${BINDINGS_MODULE_NAME} MODULE
1112
src/_gz_math_pybind11.cc
1213
src/Angle.cc
1314
src/AxisAlignedBox.cc
@@ -51,21 +52,24 @@ pybind11_add_module(math MODULE
5152
src/Vector3Stats.cc
5253
)
5354

54-
target_link_libraries(math PRIVATE
55+
target_link_libraries(${BINDINGS_MODULE_NAME} PRIVATE
5556
${PROJECT_LIBRARY_TARGET_NAME}
5657
)
5758

59+
target_compile_definitions(${BINDINGS_MODULE_NAME} PRIVATE
60+
BINDINGS_MODULE_NAME=${BINDINGS_MODULE_NAME})
61+
5862
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
5963
# Workaround for Clang and pybind11 on Focal
6064
# https://github.com/pybind/pybind11/issues/1604
6165
# Resolved by newer versions of pybind11
6266
if(${pybind11_VERSION} VERSION_LESS "2.4.4")
63-
target_compile_options(math PRIVATE -fsized-deallocation)
67+
target_compile_options(${BINDINGS_MODULE_NAME} PRIVATE -fsized-deallocation)
6468
endif()
6569

6670
# Suppress warnings that clang misidentifies:
6771
# https://github.com/pybind/pybind11/issues/1893
68-
target_compile_options(math PRIVATE -Wno-self-assign-overloaded)
72+
target_compile_options(${BINDINGS_MODULE_NAME} PRIVATE -Wno-self-assign-overloaded)
6973
endif()
7074

7175
if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
@@ -107,31 +111,9 @@ function(configure_build_install_location _library_name)
107111
install(TARGETS ${_library_name}
108112
DESTINATION "${GZ_PYTHON_INSTALL_PATH}/"
109113
)
110-
111-
# TODO(CH3): Deprecated. Remove on tock.
112-
# Install Python library symlinks
113-
if(${GZ_PYTHON_INSTALL_PATH} MATCHES "gz$")
114-
cmake_policy(SET CMP0087 NEW) # Allow evaluation of generator expressions in install(CODE )
115-
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/ignition")
116-
117-
string(REGEX REPLACE "gz$" "ignition" IGN_PYTHON_INSTALL_PATH ${GZ_PYTHON_INSTALL_PATH})
118-
if (WIN32) # Windows requires copy instead of symlink
119-
install(TARGETS ${_library_name}
120-
DESTINATION "${IGN_PYTHON_INSTALL_PATH}/"
121-
)
122-
else()
123-
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
124-
../gz/$<TARGET_FILE_NAME:${_library_name}> \
125-
${PROJECT_BINARY_DIR}\/ignition/$<TARGET_FILE_NAME:${_library_name}>)")
126-
install(FILES ${PROJECT_BINARY_DIR}\/ignition/$<TARGET_FILE_NAME:${_library_name}>
127-
DESTINATION "${IGN_PYTHON_INSTALL_PATH}/"
128-
)
129-
endif()
130-
endif()
131-
132114
endfunction()
133115

134-
configure_build_install_location(math)
116+
configure_build_install_location(${BINDINGS_MODULE_NAME})
135117

136118
if (BUILD_TESTING)
137119
# Add the Python tests

0 commit comments

Comments
 (0)