Skip to content

Commit

Permalink
pybind: Generalize get_drake_pybind_installs to `get_drake_py_insta…
Browse files Browse the repository at this point in the history
…lls`.
  • Loading branch information
EricCousineau-TRI committed Jan 30, 2018
1 parent 6face65 commit c0e71fe
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
8 changes: 4 additions & 4 deletions bindings/pydrake/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ load(
load(
"//tools/skylark:pybind.bzl",
"drake_pybind_library",
"get_drake_pybind_installs",
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
Expand Down Expand Up @@ -126,7 +126,7 @@ alias(
actual = "//bindings/pydrake/util",
)

PYBIND_LIBRARIES = adjust_labels_for_drake_hoist([
PY_LIBRARIES_WITH_INSTALL = adjust_labels_for_drake_hoist([
":autodiffutils_py",
":common_py",
":parsers_py",
Expand All @@ -146,13 +146,13 @@ install(
targets = PY_LIBRARIES,
py_dest = PACKAGE_INFO.py_dest,
visibility = ["//visibility:public"],
deps = get_drake_pybind_installs(PYBIND_LIBRARIES),
deps = get_drake_py_installs(PY_LIBRARIES_WITH_INSTALL),
)

drake_py_library(
name = "pydrake",
visibility = ["//visibility:public"],
deps = PYBIND_LIBRARIES + PY_LIBRARIES,
deps = PY_LIBRARIES_WITH_INSTALL + PY_LIBRARIES,
)

# Test ODR (One Definition Rule).
Expand Down
8 changes: 4 additions & 4 deletions bindings/pydrake/examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("//tools/lint:lint.bzl", "add_lint_tests")
load(
"//tools/skylark:pybind.bzl",
"drake_pybind_library",
"get_drake_pybind_installs",
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
Expand Down Expand Up @@ -56,7 +56,7 @@ drake_pybind_library(
],
)

PYBIND_LIBRARIES = [
PY_LIBRARIES_WITH_INSTALL = [
":pendulum_py",
]

Expand All @@ -67,14 +67,14 @@ PY_LIBRARIES = [
drake_py_library(
name = "examples",
imports = PACKAGE_INFO.py_imports,
deps = PYBIND_LIBRARIES + PY_LIBRARIES,
deps = PY_LIBRARIES_WITH_INSTALL + PY_LIBRARIES,
)

install(
name = "install",
targets = PY_LIBRARIES,
py_dest = PACKAGE_INFO.py_dest,
deps = get_drake_pybind_installs(PYBIND_LIBRARIES),
deps = get_drake_py_installs(PY_LIBRARIES_WITH_INSTALL),
)

drake_py_test(
Expand Down
8 changes: 4 additions & 4 deletions bindings/pydrake/solvers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("//tools/skylark:test_tags.bzl", "gurobi_test_tags", "mosek_test_tags")
load(
"//tools/skylark:pybind.bzl",
"drake_pybind_library",
"get_drake_pybind_installs",
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
Expand Down Expand Up @@ -88,7 +88,7 @@ drake_pybind_library(
py_deps = [":mathematicalprogram_py"],
)

PYBIND_LIBRARIES = [
PY_LIBRARIES_WITH_INSTALL = [
":gurobi_py",
":ik_py",
":ipopt_py",
Expand All @@ -102,14 +102,14 @@ PY_LIBRARIES = [

drake_py_library(
name = "solvers",
deps = PYBIND_LIBRARIES + PY_LIBRARIES,
deps = PY_LIBRARIES_WITH_INSTALL + PY_LIBRARIES,
)

install(
name = "install",
targets = PY_LIBRARIES,
py_dest = PACKAGE_INFO.py_dest,
deps = get_drake_pybind_installs(PYBIND_LIBRARIES),
deps = get_drake_py_installs(PY_LIBRARIES_WITH_INSTALL),
)

drake_py_test(
Expand Down
8 changes: 4 additions & 4 deletions bindings/pydrake/systems/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("//tools/lint:lint.bzl", "add_lint_tests")
load(
"//tools/skylark:pybind.bzl",
"drake_pybind_library",
"get_drake_pybind_installs",
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
Expand Down Expand Up @@ -111,7 +111,7 @@ drake_py_library(
],
)

PYBIND_LIBRARIES = [
PY_LIBRARIES_WITH_INSTALL = [
":analysis_py",
":framework_py",
":primitives_py",
Expand All @@ -127,14 +127,14 @@ PY_LIBRARIES = [
drake_py_library(
name = "systems",
imports = PACKAGE_INFO.py_imports,
deps = PYBIND_LIBRARIES + PY_LIBRARIES,
deps = PY_LIBRARIES_WITH_INSTALL + PY_LIBRARIES,
)

install(
name = "install",
targets = PY_LIBRARIES,
py_dest = PACKAGE_INFO.py_dest,
deps = get_drake_pybind_installs(PYBIND_LIBRARIES),
deps = get_drake_py_installs(PY_LIBRARIES_WITH_INSTALL),
)

drake_py_test(
Expand Down
8 changes: 4 additions & 4 deletions bindings/pydrake/util/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ load(
load(
"//tools/skylark:pybind.bzl",
"drake_pybind_cc_googletest",
"get_drake_pybind_installs",
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
Expand Down Expand Up @@ -112,7 +112,7 @@ drake_cc_library(
hdrs = ["drake_optional_pybind.h"],
)

PYBIND_LIBRARIES = []
PY_LIBRARIES_WITH_INSTALL = []

PY_LIBRARIES = [
":cpp_const_py",
Expand All @@ -126,14 +126,14 @@ PY_LIBRARIES = [
drake_py_library(
name = "util",
imports = PACKAGE_INFO.py_imports,
deps = PYBIND_LIBRARIES + PY_LIBRARIES,
deps = PY_LIBRARIES_WITH_INSTALL + PY_LIBRARIES,
)

install(
name = "install",
targets = PY_LIBRARIES,
py_dest = PACKAGE_INFO.py_dest,
deps = get_drake_pybind_installs(PYBIND_LIBRARIES),
deps = get_drake_py_installs(PY_LIBRARIES_WITH_INSTALL),
)

drake_cc_googletest(
Expand Down
8 changes: 5 additions & 3 deletions tools/skylark/pybind.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ def drake_pybind_library(
visibility = visibility,
)

def get_drake_pybind_installs(targets):
"""Gets install targets for `drake_pybind_library` targets.
def get_drake_py_installs(targets):
"""Gets install targets for Python targets / packages that have a sibling
install target.
@note This does not check the targets for correctness.
"""
return [_get_install(target) for target in targets]

def _get_install(target):
# Gets the install target for a `drake_pybind_library` target.
# Gets the install target for a Python target that have a sibling install
# target.
if ":" in target:
# Append suffix to target.
return target + "_install"
Expand Down

0 comments on commit c0e71fe

Please sign in to comment.