forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate .pyi's using pybind11-stubgen
Add pybind11-stubgen as a new external. Add a rule to generate `.pyi`s for `pydrake` using the same and a small helper script. For now, this must be manually invoked, and some functions are being skipped (see RobotLocomotion#17520). However, this will give us the ability to manually test the generated `.pyi` files. Adding logic to install them and/or otherwise bundle them can come later.
- Loading branch information
1 parent
22596f6
commit 0e2d39f
Showing
6 changed files
with
77 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,24 @@ | ||
"""Command-line tool to generate Drake's Python type-completion.""" | ||
|
||
import sys | ||
import pybind11_stubgen | ||
|
||
import pydrake.all | ||
|
||
|
||
def _modules_to_scan(): | ||
names = ["pydrake"] | ||
for name in sys.modules.keys(): | ||
if "._" in name: | ||
# Private module. | ||
continue | ||
if name.startswith("pydrake."): | ||
names.append(name) | ||
return names | ||
|
||
|
||
if __name__ == "__main__": | ||
args = sys.argv[1:] | ||
modules = _modules_to_scan() | ||
|
||
pybind11_stubgen.main(args + modules) |
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,8 @@ | ||
# -*- python -*- | ||
|
||
# This file exists to make our directory into a Bazel package, so that our | ||
# neighboring *.bzl file can be loaded elsewhere. | ||
|
||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
|
||
add_lint_tests() |
11 changes: 11 additions & 0 deletions
11
tools/workspace/pybind11_stubgen_internal/package.BUILD.bazel
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,11 @@ | ||
# -*- python -*- | ||
|
||
load("@drake//tools/skylark:py.bzl", "py_binary", "py_library") | ||
|
||
licenses(["notice"]) # BSD-3-Clause | ||
|
||
py_library( | ||
name = "pybind11_stubgen", | ||
srcs = ["pybind11_stubgen/__init__.py"], | ||
visibility = ["//visibility:public"], | ||
) |
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,15 @@ | ||
# -*- python -*- | ||
|
||
load("@drake//tools/workspace:github.bzl", "github_archive") | ||
|
||
def pybind11_stubgen_internal_repository( | ||
name, | ||
mirrors = None): | ||
github_archive( | ||
name = name, | ||
repository = "sizmailov/pybind11-stubgen", | ||
commit = "2536dbc3cad276c9edea86a3af61de9a57ab644d", | ||
sha256 = "e7350051a4179516cc740745d69a847eecf83dad902e6b23b18cac43dd1c9e9e", # noqa | ||
build_file = "@drake//tools/workspace/pybind11_stubgen_internal:package.BUILD.bazel", # noqa | ||
mirrors = mirrors, | ||
) |