load("//bindings/pydrake:pydrake.bzl", "add_lint_tests_pydrake")
load("//tools/install:install.bzl", "install")
load(
    "//tools/skylark:drake_cc.bzl",
    "drake_cc_library",
)
load(
    "//tools/skylark:drake_py.bzl",
    "drake_py_unittest",
)
load(
    "//tools/skylark:pybind.bzl",
    "drake_pybind_library",
    "get_drake_py_installs",
    "get_pybind_package_info",
)

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_cc_library(
    name = "optimization_pybind",
    hdrs = ["optimization_pybind.h"],
    declare_installed_headers = 0,
)

drake_pybind_library(
    name = "geometry",
    cc_deps = [
        ":optimization_pybind",
        "//bindings/pydrake:documentation_pybind",
        "//bindings/pydrake:polynomial_types_pybind",
        "//bindings/pydrake/common:default_scalars_pybind",
        "//bindings/pydrake/common:deprecation_pybind",
        "//bindings/pydrake/common:identifier_pybind",
        "//bindings/pydrake/common:serialize_pybind",
        "//bindings/pydrake/common:sorted_pair_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_meshes.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: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/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 = "meshes_test",
    data = [
        "//geometry:test_obj_files",
    ],
    deps = [
        ":geometry",
        "//bindings/pydrake/common/test_utilities",
    ],
)

drake_py_unittest(
    name = "optimization_test",
    deps = [
        ":geometry",
        "//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",
    allow_network = ["render_gltf_client"],
    data = [
        "//geometry/render:test_models",
    ],
    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_lint_tests_pydrake()
