diff --git a/bindings/pydrake/BUILD.bazel b/bindings/pydrake/BUILD.bazel index b360d2cce14d..c566574bf1ab 100644 --- a/bindings/pydrake/BUILD.bazel +++ b/bindings/pydrake/BUILD.bazel @@ -118,43 +118,6 @@ drake_pybind_library( ], ) -drake_pybind_library( - name = "geometry_py", - cc_deps = [ - "//bindings/pydrake:documentation_pybind", - "//bindings/pydrake/common:default_scalars_pybind", - "//bindings/pydrake/common:deprecation_pybind", - "//bindings/pydrake/common:identifier_pybind", - "//bindings/pydrake/common:monostate_pybind", - "//bindings/pydrake/common:serialize_pybind", - "//bindings/pydrake/common:type_pack", - "//bindings/pydrake/common:type_safe_index_pybind", - "//bindings/pydrake/common:value_pybind", - ], - cc_srcs = [ - "geometry_py.cc", - "geometry_py.h", - "geometry_py_common.cc", - "geometry_py_hydro.cc", - "geometry_py_optimization.cc", - "geometry_py_render.cc", - "geometry_py_scene_graph.cc", - "geometry_py_visualizers.cc", - ], - package_info = PACKAGE_INFO, - py_data = [ - "//setup:deepnote", - ], - py_deps = [ - ":math_py", - ":module_py", - "//bindings/pydrake/solvers", - "//bindings/pydrake/systems:framework_py", - "//bindings/pydrake/systems:lcm_py", - ], - py_srcs = ["_geometry_extra.py"], -) - drake_pybind_library( name = "lcm_py", cc_deps = [ @@ -301,6 +264,7 @@ drake_py_library( PYBIND_SUBPACKAGES_FOR_COVERAGE = [ "//bindings/pydrake/common", + "//bindings/pydrake/geometry", "//bindings/pydrake/manipulation", "//bindings/pydrake/multibody", "//bindings/pydrake/planning", @@ -311,7 +275,6 @@ PYBIND_SUBPACKAGES_FOR_COVERAGE = [ PY_LIBRARIES_WITH_INSTALL = [ ":autodiffutils_py", - ":geometry_py", ":lcm_py", ":math_py", ":perception_py", @@ -491,98 +454,6 @@ drake_py_unittest( ], ) -drake_py_unittest( - name = "frame_id_test", - deps = [ - ":geometry_py", - ], -) - -drake_py_unittest( - name = "geometry_common_test", - deps = [ - ":geometry_py", - "//bindings/pydrake/common", - "//bindings/pydrake/common/test_utilities", - "//bindings/pydrake/multibody:parsing_py", - "//bindings/pydrake/multibody:plant_py", - ], -) - -drake_py_unittest( - name = "geometry_hydro_test", - data = [ - "//geometry:test_obj_files", - ], - deps = [ - ":geometry_py", - "//bindings/pydrake/common/test_utilities", - ], -) - -drake_py_unittest( - name = "geometry_optimization_test", - deps = [ - ":geometry_py", - ":math_py", - "//bindings/pydrake/common/test_utilities:deprecation_py", - "//bindings/pydrake/common/test_utilities:pickle_compare_py", - "//bindings/pydrake/multibody:inverse_kinematics_py", - "//bindings/pydrake/multibody:parsing_py", - "//bindings/pydrake/multibody:plant_py", - "//bindings/pydrake/solvers", - ], -) - -drake_py_unittest( - name = "geometry_render_test", - deps = [ - ":geometry_py", - "//bindings/pydrake/common/test_utilities", - "//bindings/pydrake/systems:sensors_py", - ], -) - -drake_py_unittest( - name = "geometry_render_engine_gl_test", - deps = [ - ":geometry_py", - "//bindings/pydrake/common/test_utilities", - ], -) - -drake_py_unittest( - name = "geometry_render_engine_subclass_test", - flaky = True, - deps = [ - ":geometry_py", - "//bindings/pydrake/common/test_utilities", - "//bindings/pydrake/systems:sensors_py", - ], -) - -drake_py_unittest( - name = "geometry_scene_graph_test", - deps = [ - ":geometry_py", - "//bindings/pydrake/common/test_utilities", - "//bindings/pydrake/systems:sensors_py", - ], -) - -drake_py_unittest( - name = "geometry_visualizers_test", - deps = [ - ":geometry_py", - ":lcm_py", - ":perception_py", - "//bindings/pydrake/common/test_utilities", - "//bindings/pydrake/multibody:plant_py", - "//bindings/pydrake/systems:analysis_py", - "//bindings/pydrake/systems:lcm_py", - ], -) - drake_py_unittest( name = "lcm_test", deps = [ @@ -720,7 +591,7 @@ PYI_FILES = [ "pydrake/examples/rimless_wheel.pyi", "pydrake/examples/van_der_pol.pyi", "pydrake/forwarddiff.pyi", - "pydrake/geometry.pyi", + "pydrake/geometry/__init__.pyi", "pydrake/lcm.pyi", "pydrake/manipulation/__init__.pyi", "pydrake/manipulation/all.pyi", diff --git a/bindings/pydrake/geometry/BUILD.bazel b/bindings/pydrake/geometry/BUILD.bazel new file mode 100644 index 000000000000..83fb0e2cdb6d --- /dev/null +++ b/bindings/pydrake/geometry/BUILD.bazel @@ -0,0 +1,164 @@ +# -*- python -*- + +load("@drake//tools/install:install.bzl", "install") +load( + "@drake//tools/skylark:drake_py.bzl", + "drake_py_unittest", +) +load( + "@drake//tools/skylark:pybind.bzl", + "add_pybind_coverage_data", + "drake_pybind_library", + "get_drake_py_installs", + "get_pybind_package_info", +) +load("//bindings/pydrake:pydrake.bzl", "add_lint_tests_pydrake") + +package(default_visibility = [ + "//bindings:__subpackages__", +]) + +# This determines how `PYTHONPATH` is configured, and how to install the +# bindings. +PACKAGE_INFO = get_pybind_package_info(base_package = "//bindings") + +drake_pybind_library( + name = "geometry", + cc_deps = [ + "//bindings/pydrake:documentation_pybind", + "//bindings/pydrake/common:default_scalars_pybind", + "//bindings/pydrake/common:deprecation_pybind", + "//bindings/pydrake/common:identifier_pybind", + "//bindings/pydrake/common:monostate_pybind", + "//bindings/pydrake/common:serialize_pybind", + "//bindings/pydrake/common:type_pack", + "//bindings/pydrake/common:type_safe_index_pybind", + "//bindings/pydrake/common:value_pybind", + ], + cc_so_name = "__init__", + cc_srcs = [ + "geometry_py.cc", + "geometry_py.h", + "geometry_py_common.cc", + "geometry_py_hydro.cc", + "geometry_py_optimization.cc", + "geometry_py_render.cc", + "geometry_py_scene_graph.cc", + "geometry_py_visualizers.cc", + ], + package_info = PACKAGE_INFO, + py_data = [ + "//setup:deepnote", + ], + py_deps = [ + "//bindings/pydrake:math_py", + "//bindings/pydrake:module_py", + "//bindings/pydrake/solvers", + "//bindings/pydrake/systems:framework_py", + "//bindings/pydrake/systems:lcm_py", + ], + py_srcs = ["_geometry_extra.py"], +) + +install( + name = "install", + targets = [":geometry"], + py_dest = PACKAGE_INFO.py_dest, + deps = get_drake_py_installs([":geometry"]), +) + +drake_py_unittest( + name = "frame_id_test", + deps = [ + ":geometry", + ], +) + +drake_py_unittest( + name = "common_test", + deps = [ + ":geometry", + "//bindings/pydrake/common", + "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/multibody:parsing_py", + "//bindings/pydrake/multibody:plant_py", + ], +) + +drake_py_unittest( + name = "hydro_test", + data = [ + "//geometry:test_obj_files", + ], + deps = [ + ":geometry", + "//bindings/pydrake/common/test_utilities", + ], +) + +drake_py_unittest( + name = "optimization_test", + deps = [ + ":geometry", + "//bindings/pydrake:math_py", + "//bindings/pydrake/common/test_utilities:deprecation_py", + "//bindings/pydrake/common/test_utilities:pickle_compare_py", + "//bindings/pydrake/multibody:inverse_kinematics_py", + "//bindings/pydrake/multibody:parsing_py", + "//bindings/pydrake/multibody:plant_py", + "//bindings/pydrake/solvers", + ], +) + +drake_py_unittest( + name = "render_test", + deps = [ + ":geometry", + "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/systems:sensors_py", + ], +) + +drake_py_unittest( + name = "render_engine_gl_test", + deps = [ + ":geometry", + "//bindings/pydrake/common/test_utilities", + ], +) + +drake_py_unittest( + name = "render_engine_subclass_test", + flaky = True, + deps = [ + ":geometry", + "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/systems:sensors_py", + ], +) + +drake_py_unittest( + name = "scene_graph_test", + deps = [ + ":geometry", + "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/systems:sensors_py", + ], +) + +drake_py_unittest( + name = "visualizers_test", + deps = [ + ":geometry", + "//bindings/pydrake:lcm_py", + "//bindings/pydrake:perception_py", + "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/multibody:plant_py", + "//bindings/pydrake/systems:analysis_py", + "//bindings/pydrake/systems:lcm_py", + ], +) + +add_pybind_coverage_data() + +add_lint_tests_pydrake() diff --git a/bindings/pydrake/_geometry_extra.py b/bindings/pydrake/geometry/_geometry_extra.py similarity index 100% rename from bindings/pydrake/_geometry_extra.py rename to bindings/pydrake/geometry/_geometry_extra.py diff --git a/bindings/pydrake/geometry_py.cc b/bindings/pydrake/geometry/geometry_py.cc similarity index 91% rename from bindings/pydrake/geometry_py.cc rename to bindings/pydrake/geometry/geometry_py.cc index cafbf3957a90..1f53a885a56d 100644 --- a/bindings/pydrake/geometry_py.cc +++ b/bindings/pydrake/geometry/geometry_py.cc @@ -1,4 +1,4 @@ -#include "drake/bindings/pydrake/geometry_py.h" +#include "drake/bindings/pydrake/geometry/geometry_py.h" #include "pybind11/eval.h" @@ -31,7 +31,7 @@ PYBIND11_MODULE(geometry, m) { DefineGeometryOptimization(m.def_submodule("optimization")); DefineGeometryVisualizers(m); - ExecuteExtraPythonCode(m); + ExecuteExtraPythonCode(m, true); def_geometry_all(m.def_submodule("all")); } diff --git a/bindings/pydrake/geometry_py.h b/bindings/pydrake/geometry/geometry_py.h similarity index 100% rename from bindings/pydrake/geometry_py.h rename to bindings/pydrake/geometry/geometry_py.h diff --git a/bindings/pydrake/geometry_py_common.cc b/bindings/pydrake/geometry/geometry_py_common.cc similarity index 100% rename from bindings/pydrake/geometry_py_common.cc rename to bindings/pydrake/geometry/geometry_py_common.cc diff --git a/bindings/pydrake/geometry_py_hydro.cc b/bindings/pydrake/geometry/geometry_py_hydro.cc similarity index 100% rename from bindings/pydrake/geometry_py_hydro.cc rename to bindings/pydrake/geometry/geometry_py_hydro.cc diff --git a/bindings/pydrake/geometry_py_optimization.cc b/bindings/pydrake/geometry/geometry_py_optimization.cc similarity index 99% rename from bindings/pydrake/geometry_py_optimization.cc rename to bindings/pydrake/geometry/geometry_py_optimization.cc index 28a9d60bde89..04182993d10c 100644 --- a/bindings/pydrake/geometry_py_optimization.cc +++ b/bindings/pydrake/geometry/geometry_py_optimization.cc @@ -6,7 +6,7 @@ #include "drake/bindings/pydrake/common/deprecation_pybind.h" #include "drake/bindings/pydrake/common/identifier_pybind.h" #include "drake/bindings/pydrake/documentation_pybind.h" -#include "drake/bindings/pydrake/geometry_py.h" +#include "drake/bindings/pydrake/geometry/geometry_py.h" #include "drake/geometry/optimization/cartesian_product.h" #include "drake/geometry/optimization/graph_of_convex_sets.h" #include "drake/geometry/optimization/hpolyhedron.h" diff --git a/bindings/pydrake/geometry_py_render.cc b/bindings/pydrake/geometry/geometry_py_render.cc similarity index 100% rename from bindings/pydrake/geometry_py_render.cc rename to bindings/pydrake/geometry/geometry_py_render.cc diff --git a/bindings/pydrake/geometry_py_scene_graph.cc b/bindings/pydrake/geometry/geometry_py_scene_graph.cc similarity index 100% rename from bindings/pydrake/geometry_py_scene_graph.cc rename to bindings/pydrake/geometry/geometry_py_scene_graph.cc diff --git a/bindings/pydrake/geometry_py_visualizers.cc b/bindings/pydrake/geometry/geometry_py_visualizers.cc similarity index 100% rename from bindings/pydrake/geometry_py_visualizers.cc rename to bindings/pydrake/geometry/geometry_py_visualizers.cc diff --git a/bindings/pydrake/test/geometry_common_test.py b/bindings/pydrake/geometry/test/common_test.py similarity index 100% rename from bindings/pydrake/test/geometry_common_test.py rename to bindings/pydrake/geometry/test/common_test.py diff --git a/bindings/pydrake/test/frame_id_test.py b/bindings/pydrake/geometry/test/frame_id_test.py similarity index 100% rename from bindings/pydrake/test/frame_id_test.py rename to bindings/pydrake/geometry/test/frame_id_test.py diff --git a/bindings/pydrake/test/geometry_hydro_test.py b/bindings/pydrake/geometry/test/hydro_test.py similarity index 100% rename from bindings/pydrake/test/geometry_hydro_test.py rename to bindings/pydrake/geometry/test/hydro_test.py diff --git a/bindings/pydrake/test/geometry_optimization_test.py b/bindings/pydrake/geometry/test/optimization_test.py similarity index 100% rename from bindings/pydrake/test/geometry_optimization_test.py rename to bindings/pydrake/geometry/test/optimization_test.py diff --git a/bindings/pydrake/test/geometry_render_engine_gl_test.py b/bindings/pydrake/geometry/test/render_engine_gl_test.py similarity index 100% rename from bindings/pydrake/test/geometry_render_engine_gl_test.py rename to bindings/pydrake/geometry/test/render_engine_gl_test.py diff --git a/bindings/pydrake/test/geometry_render_engine_subclass_test.py b/bindings/pydrake/geometry/test/render_engine_subclass_test.py similarity index 100% rename from bindings/pydrake/test/geometry_render_engine_subclass_test.py rename to bindings/pydrake/geometry/test/render_engine_subclass_test.py diff --git a/bindings/pydrake/test/geometry_render_test.py b/bindings/pydrake/geometry/test/render_test.py similarity index 100% rename from bindings/pydrake/test/geometry_render_test.py rename to bindings/pydrake/geometry/test/render_test.py diff --git a/bindings/pydrake/test/geometry_scene_graph_test.py b/bindings/pydrake/geometry/test/scene_graph_test.py similarity index 100% rename from bindings/pydrake/test/geometry_scene_graph_test.py rename to bindings/pydrake/geometry/test/scene_graph_test.py diff --git a/bindings/pydrake/test/geometry_visualizers_test.py b/bindings/pydrake/geometry/test/visualizers_test.py similarity index 100% rename from bindings/pydrake/test/geometry_visualizers_test.py rename to bindings/pydrake/geometry/test/visualizers_test.py diff --git a/bindings/pydrake/multibody/BUILD.bazel b/bindings/pydrake/multibody/BUILD.bazel index e6018b9ac11f..f7e30ef10d52 100644 --- a/bindings/pydrake/multibody/BUILD.bazel +++ b/bindings/pydrake/multibody/BUILD.bazel @@ -141,7 +141,7 @@ drake_pybind_library( ":math_py", ":module_py", ":tree_py", - "//bindings/pydrake:geometry_py", + "//bindings/pydrake/geometry", "//bindings/pydrake/common:cpp_template_py", ], py_srcs = [ @@ -296,7 +296,7 @@ drake_jupyter_py_binary( ":jupyter_widgets_py", ":parsing_py", ":plant_py", - "//bindings/pydrake:geometry_py", + "//bindings/pydrake/geometry", "//bindings/pydrake/systems:analysis_py", "//bindings/pydrake/systems:framework_py", "//bindings/pydrake/systems:rendering_py", diff --git a/bindings/pydrake/planning/BUILD.bazel b/bindings/pydrake/planning/BUILD.bazel index 3d70b0357343..be92158954be 100644 --- a/bindings/pydrake/planning/BUILD.bazel +++ b/bindings/pydrake/planning/BUILD.bazel @@ -40,7 +40,7 @@ drake_pybind_library( package_info = PACKAGE_INFO, py_deps = [ "//bindings/pydrake/common:cpp_template_py", - "//bindings/pydrake:geometry_py", + "//bindings/pydrake/geometry", "//bindings/pydrake/multibody:parsing_py", "//bindings/pydrake/multibody:plant_py", ], diff --git a/bindings/pydrake/systems/BUILD.bazel b/bindings/pydrake/systems/BUILD.bazel index cc27f19ad843..53c48fd40f43 100644 --- a/bindings/pydrake/systems/BUILD.bazel +++ b/bindings/pydrake/systems/BUILD.bazel @@ -175,7 +175,7 @@ drake_pybind_library( "//bindings/pydrake/common:cpp_template_py", "//bindings/pydrake/common:eigen_geometry_py", "//bindings/pydrake/common:schema_py", - "//bindings/pydrake:geometry_py", + "//bindings/pydrake/geometry", ], ) @@ -386,7 +386,7 @@ drake_jupyter_py_binary( ":analysis_py", ":framework_py", ":jupyter_widgets_py", - "//bindings/pydrake:geometry_py", + "//bindings/pydrake/geometry", "//bindings/pydrake/multibody:parsing_py", "//bindings/pydrake/multibody:plant_py", ], @@ -509,8 +509,8 @@ drake_py_unittest( ":analysis_py", ":framework_py", ":planar_scenegraph_visualizer_py", - "//bindings/pydrake:geometry_py", "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/geometry", "//bindings/pydrake/multibody", ], ) @@ -561,8 +561,8 @@ drake_py_unittest( tags = vtk_test_tags(), deps = [ ":sensors_py", - "//bindings/pydrake:geometry_py", "//bindings/pydrake/common/test_utilities", + "//bindings/pydrake/geometry", "//bindings/pydrake/multibody:plant_py", ], ) diff --git a/bindings/pydrake/visualization/BUILD.bazel b/bindings/pydrake/visualization/BUILD.bazel index 511b03d18118..9c382ae11677 100644 --- a/bindings/pydrake/visualization/BUILD.bazel +++ b/bindings/pydrake/visualization/BUILD.bazel @@ -41,7 +41,7 @@ drake_pybind_library( "//bindings/pydrake/multibody", "//bindings/pydrake/solvers", "//bindings/pydrake/systems", - "//bindings/pydrake:geometry_py", + "//bindings/pydrake/geometry", "//bindings/pydrake:lcm_py", "//bindings/pydrake:symbolic_py", "//lcmtypes:lcmtypes_drake_py",