Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr14878+rico #15205

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions setup/mac/source_distribution/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ConfigArgParse
semantic-version
toposort
2 changes: 2 additions & 0 deletions setup/ubuntu/source_distribution/packages-bionic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ patch
patchelf
pkg-config
python3-all-dev
python3-configargparse
python3-semantic-version
python3-toposort
zlib1g-dev
2 changes: 2 additions & 0 deletions setup/ubuntu/source_distribution/packages-focal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ patch
patchelf
pkg-config
python3-all-dev
python3-configargparse
python3-semantic-version
python3-toposort
zlib1g-dev
73 changes: 73 additions & 0 deletions tools/autopybind/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- mode: python; -*-
# vi: set ft=python:

load("//tools/lint:lint.bzl", "add_lint_tests")
load(
"@drake//tools/skylark:drake_py.bzl",
"drake_py_binary",
"drake_py_unittest",
)
load(
"@drake//tools/skylark:pybind.bzl",
"generate_autopybind11_rsp_file",
)

generate_autopybind11_rsp_file(
name = "generate_autopybind11_rsp_file",
header_archive = "libdrake_headers.tar",
rsp_file = "libdrake_compile_info.rsp",
targets = [
"//lcmtypes:lcmtypes_drake_cc",
"//tools/install/libdrake:drake_headers",
"//examples/compass_gait:compass_gait",
"//examples/manipulation_station:manipulation_station",
"//examples/manipulation_station:manipulation_station_hardware_interface", # noqa
"//examples/pendulum:pendulum_plant",
"//examples/quadrotor:quadrotor_plant",
"//examples/rimless_wheel:rimless_wheel",
"//examples/van_der_pol:van_der_pol",
"@eigen",
"@fmt",
"@lcm",
"@spdlog",
],
)

filegroup(
name = "inputs",
data = [
"libdrake_compile_info.rsp",
"libdrake_headers.tar",
],
)

filegroup(
name = "config",
data = [
"autopybind11_customization.yaml",
"bindings_to_generate.yaml",
],
)

drake_py_binary(
name = "generate",
srcs = ["generate.py"],
data = [
":config",
":inputs",
"@castxml//:castxml_bin",
],
deps = [
"//tools/lint:find_data",
"@autopybind11_py",
"@pygccxml_py",
],
)

drake_py_unittest(
name = "generate_test",
size = "medium",
data = [":generate"],
)

add_lint_tests()
28 changes: 28 additions & 0 deletions tools/autopybind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Semi-Automated Python Binding Generation Tool

This provides an integration with
[`autopybind11`](https://gitlab.kitware.com/autopybind11/autopybind11). At
present, it is meant to *bootstrap* bindings (e.g., generate or regenerate
bindings for a class that may need some correction or customization or may be
incomplete), but is not meant to completely replace the manual binding process.

## Running

To output template bindings to `/tmp/autopybind11`, please run the following:
```bash
bazel run //tools/autopybind:generate -- --output_dir=/tmp/autopybind11
```

This is configured using the `bindings_to_generate.yaml` file in this
directory. For more information on the `autopybind11` schema, please review its
[documentation](https://gitlab.kitware.com/autopybind11/autopybind11).

## Troubleshooting

If you encounter an issue with our usage of `autopybind11`, please run the
following script that captures all output, commit the generate files to git,
and make a draft pull request pointing to the problem that you are having:
```bash
cd drake
./tools/autopybind/generate_debug
```
7 changes: 7 additions & 0 deletions tools/autopybind/autopybind11_customization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
private_members_as_fields: false
enable_doc_strings: false
pass_eigen_by_ref: false
use_eigen_return_policy: false
use_template_wrapping_function: true
print_python_warnings: false
Loading