Skip to content

Commit

Permalink
pybind: Start to simplify drake_pybind_library
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI committed Oct 10, 2018
1 parent ac3eb24 commit 1440aeb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tools/skylark/pybind.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def drake_pybind_library(
py_srcs = [],
py_deps = [],
py_imports = [],
# TODO(eric.cousineau): Turn this off by default. Rename it to indicate
# that install is Drake-specific.
add_install = True,
visibility = None,
testonly = None):
Expand All @@ -124,15 +126,19 @@ def drake_pybind_library(
Shared object name. By default, this is `_${name}`, so that the C++
code can be then imported in a more controlled fashion in Python.
If overridden, this could be the public interface exposed to the user.
@param package_info
@param package_info (optional)
This should be the result of `get_pybind_package_info` called from the
current package. This dictates how `PYTHONPATH` is configured, and
where the modules will be installed.
This is only required if `add_install` is True.
@param add_install (optional)
Add install targets.
"""
if package_info == None:
fail("`package_info` must be supplied.")
if add_install:
fail("`package_info` must be supplied if `add_install` is True.")
else:
py_imports = package_info.py_imports + py_imports
if not cc_so_name:
cc_so_name = "_" + name
install_name = name + "_install"
Expand All @@ -147,7 +153,7 @@ def drake_pybind_library(
cc_binary_rule = drake_cc_binary,
py_srcs = py_srcs,
py_deps = py_deps,
py_imports = package_info.py_imports + py_imports,
py_imports = py_imports,
py_library_rule = drake_py_library,
testonly = testonly,
visibility = visibility,
Expand All @@ -165,6 +171,7 @@ def drake_pybind_library(
library_dest = package_info.py_dest,
visibility = visibility,
)
return targets

def get_drake_py_installs(targets):
"""Gets install targets for Python targets / packages that have a sibling
Expand Down

0 comments on commit 1440aeb

Please sign in to comment.