load("//tools/install:install.bzl", "install", "install_files")
load("//tools/jupyter:jupyter_py.bzl", "drake_jupyter_py_binary")
load("//tools/lint:lint.bzl", "add_lint_tests")
load("//tools/skylark:drake_py.bzl", "drake_py_test")

drake_jupyter_py_binary(
    name = "index",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "mathematical_program",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "solver_parameters",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "debug_mathematical_program",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "licensed_solvers_deepnote",
    add_test_rule = 0,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "linear_program",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "nonlinear_program",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "quadratic_program",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "dynamical_systems",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "authoring_leaf_systems",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "working_with_diagrams",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "authoring_multibody_simulation",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "hydroelastic_contact_basics",
    add_test_rule = 1,
    test_timeout = "moderate",
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "hydroelastic_contact_nonconvex_mesh",
    add_test_rule = 1,
    data = [
        "@drake_models//:dishes",
        "@drake_models//:veggies",
    ],
    # TODO(#21380) Revisit timeout value when deferred reification is
    # implemented.
    test_timeout = "moderate",
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "rendering_multibody_plant",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "mathematical_program_multibody_plant",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "pyplot_animation_multibody_plant",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "sum_of_squares_optimization",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "updating_costs_and_constraints",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

drake_jupyter_py_binary(
    name = "multibody_plant_autodiff_mass",
    add_test_rule = 1,
    deps = [
        "//bindings/pydrake",
    ],
)

_NOTEBOOKS = glob(
    ["*.ipynb"],
    allow_empty = False,
)

drake_py_test(
    name = "notebook_lint_test",
    args = _NOTEBOOKS,
    data = _NOTEBOOKS,
    tags = ["lint"],
    deps = [
        "@rules_python//python/runfiles",
    ],
)

install_files(
    name = "install_notebooks",
    dest = "share/drake/tutorials",
    files = _NOTEBOOKS,
)

install(
    name = "install",
    visibility = ["//:__subpackages__"],
    deps = [
        ":install_notebooks",
    ],
)

add_lint_tests()
