-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpp_const: Add ability to impose C++ const semantics in Python.
- Loading branch information
1 parent
8aa72db
commit 5bfad74
Showing
7 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
load("@drake//tools/install:install.bzl", "install") | ||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
load( | ||
"//tools/skylark:drake_py.bzl", | ||
"drake_py_library", | ||
) | ||
load( | ||
"//tools/skylark:pybind.bzl", | ||
"get_pybind_package_info", | ||
) | ||
load(":forward_files.bzl", "forward_files") | ||
|
||
package(default_visibility = [ | ||
"//bindings/pydrake:__subpackages__", | ||
]) | ||
|
||
# This determines how `PYTHONPATH` is configured, and how to install the | ||
# bindings. | ||
PACKAGE_INFO = get_pybind_package_info( | ||
base_package = "//bindings", | ||
) | ||
|
||
drake_py_library( | ||
name = "module_py", | ||
srcs = ["__init__.py"], | ||
imports = PACKAGE_INFO.py_imports, | ||
) | ||
|
||
# Forward physical files to simplify working with `third_party` files (both | ||
# for Python imports and for installation). | ||
wrapt_prefix = "//third_party:com_github_grahamdumpleton_wrapt/" | ||
|
||
forward_files( | ||
srcs = [wrapt_prefix + f for f in [ | ||
"__init__.py", | ||
"LICENSE", | ||
"wrappers.py", | ||
]], | ||
dest_prefix = "wrapt/", | ||
strip_prefix = wrapt_prefix, | ||
tags = ["nolint"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
# TODO(eric.cousineau): Use Ubuntu packages once we have a later version of | ||
# `python-wrapt` that does not have bugs like a mis-mapped `__mod__` proxy. | ||
drake_py_library( | ||
name = "wrapt_py", | ||
srcs = [ | ||
"wrapt/__init__.py", | ||
"wrapt/wrappers.py", | ||
], | ||
imports = PACKAGE_INFO.py_imports, | ||
tags = ["nolint"], | ||
) | ||
|
||
PY_LIBRARIES = [ | ||
":module_py", | ||
":wrapt_py", | ||
] | ||
|
||
drake_py_library( | ||
name = "third_party", | ||
visibility = ["//visibility:public"], | ||
deps = PY_LIBRARIES, | ||
) | ||
|
||
install( | ||
name = "install", | ||
targets = PY_LIBRARIES, | ||
py_dest = PACKAGE_INFO.py_dest, | ||
docs = ["wrapt/LICENSE"], | ||
doc_dest = "share/doc", | ||
) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty Python module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- python -*- | ||
|
||
def forward_files( | ||
srcs, | ||
strip_prefix, | ||
dest_prefix, | ||
visibility = None, | ||
tags = []): | ||
"""Forwards files in `srcs` to be physically present in the current | ||
packages. | ||
Present implementation simply copies the files. | ||
@param srcs | ||
List of string, pointing *directly* to files. Does not handle filegroup | ||
targets. | ||
@param strip_prefix | ||
String to be stripped from source files. Should include trailing slash. | ||
@param dest_prefix | ||
String to be prepended to target. | ||
""" | ||
outs = [] | ||
for src in srcs: | ||
if not src.startswith(strip_prefix): | ||
fail("'{}' not under '{}'".format(src, strip_prefix)) | ||
out = dest_prefix + src[len(strip_prefix):] | ||
native.genrule( | ||
name = out + ".forward", | ||
srcs = [src], | ||
outs = [out], | ||
cmd = "cp $< $@", | ||
tags = tags, | ||
visibility = visibility, | ||
) | ||
outs.append(out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.