From 1426f9c7de1593d2291fc9e23f97fcb2753fa808 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Mon, 20 May 2024 09:38:50 -0700 Subject: [PATCH] [doc,tools] Adjust imports and libraries in prep for bzlmod Re-spell imports to lose the "drake" part of the module namespace. The old spelling of imports is dispreferred and will not work with upcoming bzlmod. For all Drake Python code, we should be using drake_py_library so that all Drake-specific settings are always in effect. (Earlier in bzlmod porting this was critically important; since then, I've changed some options so that it's less critical but we should anyway follow this hygiene so that we always have a single point of control for our build rules.) --- doc/build.py | 2 +- doc/doxygen_cxx/build.py | 2 +- doc/doxygen_cxx/test/system_doxygen_test.py | 2 +- doc/pages.py | 2 +- doc/pydrake/build.py | 8 +++--- doc/pydrake/pydrake_sphinx_extension.py | 3 ++- doc/styleguide/build.py | 2 +- tools/BUILD.bazel | 6 ++--- tools/install/BUILD.bazel | 8 +++--- tools/install/dummy/BUILD.bazel | 4 +-- tools/install/installer.py | 2 +- tools/install/test/install_meta_test.py | 2 +- tools/install/test/installer_test.py | 2 +- tools/jupyter/BUILD.bazel | 27 +++++++++---------- tools/jupyter/__init__.py | 1 - tools/jupyter/example.ipynb | 2 +- tools/jupyter/jupyter_py.bzl | 2 +- tools/lcm_gen/BUILD.bazel | 2 +- tools/lcm_gen/test/lcm_gen_test.py | 2 +- tools/lint/BUILD.bazel | 2 +- tools/lint/buildifier.py | 4 +-- tools/lint/clang_format_includes.py | 4 +-- tools/lint/clang_format_lint.py | 2 +- tools/lint/drakelint.py | 2 +- tools/lint/formatter.py | 2 +- tools/lint/python_lint.bzl | 12 --------- tools/lint/test/find_data_test.py | 2 +- tools/lint/test/formatter_test.py | 2 +- tools/lint/test/util_test.py | 2 +- tools/skylark/BUILD.bazel | 5 ++-- tools/wheel/BUILD.bazel | 4 +-- tools/wheel/macos/change_lpath.py | 2 +- tools/wheel/macos/strip_rpath.py | 2 +- tools/wheel/wheel_builder/main.py | 6 ++--- tools/workspace/BUILD.bazel | 10 ++++--- tools/workspace/mirror_to_s3.py | 2 +- tools/workspace/new_release.py | 2 +- tools/workspace/openusd_internal/BUILD.bazel | 3 ++- tools/workspace/pybind11/BUILD.bazel | 18 +++++++------ tools/workspace/pybind11/mkdoc.py | 5 ++-- tools/workspace/pybind11/mkdoc_comment.py | 2 +- .../pybind11/test/mkdoc_comment_test.py | 2 +- tools/workspace/vendor_cxx_test.py | 2 +- 43 files changed, 85 insertions(+), 95 deletions(-) delete mode 100644 tools/jupyter/__init__.py diff --git a/doc/build.py b/doc/build.py index 3eb67daf8f40..47b00ff8f32f 100644 --- a/doc/build.py +++ b/doc/build.py @@ -11,7 +11,7 @@ from python import runfiles import xml.etree.ElementTree as ET -from drake.doc.defs import check_call, main +from doc.defs import check_call, main def _build(*, out_dir, temp_dir, quick, modules): diff --git a/doc/doxygen_cxx/build.py b/doc/doxygen_cxx/build.py index c2e582debc6b..27895096e3c9 100644 --- a/doc/doxygen_cxx/build.py +++ b/doc/doxygen_cxx/build.py @@ -12,7 +12,7 @@ from python import runfiles -from drake.doc.defs import ( +from doc.defs import ( check_call, main, perl_cleanup_html_output, diff --git a/doc/doxygen_cxx/test/system_doxygen_test.py b/doc/doxygen_cxx/test/system_doxygen_test.py index 231be9d2668c..fbd1caf77805 100644 --- a/doc/doxygen_cxx/test/system_doxygen_test.py +++ b/doc/doxygen_cxx/test/system_doxygen_test.py @@ -2,7 +2,7 @@ from textwrap import dedent, indent import unittest -import drake.doc.doxygen_cxx.system_doxygen as mut +import doc.doxygen_cxx.system_doxygen as mut class TestSystemDoxygen(unittest.TestCase): diff --git a/doc/pages.py b/doc/pages.py index 55940bcdd4bf..e7df7f96969a 100644 --- a/doc/pages.py +++ b/doc/pages.py @@ -7,7 +7,7 @@ import os import tempfile -from drake.doc.defs import ( +from doc.defs import ( check_call, main, perl_cleanup_html_output, diff --git a/doc/pydrake/build.py b/doc/pydrake/build.py index f6e24887eb7d..de4269104491 100644 --- a/doc/pydrake/build.py +++ b/doc/pydrake/build.py @@ -7,7 +7,10 @@ from os.path import join import sys -from drake.doc.defs import ( +import pydrake._all_everything +from pydrake.common import _MangledName + +from doc.defs import ( check_call, main, perl_cleanup_html_output, @@ -15,9 +18,6 @@ verbose, ) -import pydrake._all_everything -from pydrake.common import _MangledName - def _get_submodules(name): prefix = name + "." diff --git a/doc/pydrake/pydrake_sphinx_extension.py b/doc/pydrake/pydrake_sphinx_extension.py index 47f77b3cbe12..649bebd69bcc 100644 --- a/doc/pydrake/pydrake_sphinx_extension.py +++ b/doc/pydrake/pydrake_sphinx_extension.py @@ -26,10 +26,11 @@ from sphinx.ext import autodoc from sphinx.util.nodes import nested_parse_with_titles -from drake.doc.doxygen_cxx.system_doxygen import system_yaml_to_html from pydrake.common.cpp_template import TemplateBase from pydrake.common.deprecation import DrakeDeprecationWarning +from doc.doxygen_cxx.system_doxygen import system_yaml_to_html + def rindex(s, sub): """Reverse index of a substring.""" diff --git a/doc/styleguide/build.py b/doc/styleguide/build.py index b221bbb2b600..b961152ad745 100644 --- a/doc/styleguide/build.py +++ b/doc/styleguide/build.py @@ -7,7 +7,7 @@ from os.path import join import textwrap -from drake.doc.defs import check_call, main, symlink_input +from doc.defs import check_call, main, symlink_input def _add_title(*, temp_dir, filename, title): diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 230d1e323900..560308f73fad 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -1,18 +1,16 @@ load("//tools/lint:lint.bzl", "add_lint_tests") -load("//tools/skylark:drake_py.bzl", "drake_py_binary") +load("//tools/skylark:drake_py.bzl", "drake_py_binary", "drake_py_library") load( "//tools/skylark:drake_runfiles_binary.bzl", "drake_runfiles_binary", ) -load("//tools/skylark:py.bzl", "py_binary", "py_library") package(default_visibility = ["//visibility:public"]) -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], visibility = [":__subpackages__"], - deps = ["//:module_py"], ) alias( diff --git a/tools/install/BUILD.bazel b/tools/install/BUILD.bazel index fec31acec903..bf1220e9ee28 100644 --- a/tools/install/BUILD.bazel +++ b/tools/install/BUILD.bazel @@ -2,27 +2,27 @@ load("//tools/lint:lint.bzl", "add_lint_tests") load( "//tools/skylark:drake_py.bzl", "drake_py_binary", + "drake_py_library", "drake_py_unittest", ) -load("//tools/skylark:py.bzl", "py_library") package(default_visibility = ["//visibility:public"]) -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], visibility = [":__subpackages__"], deps = ["//tools:module_py"], ) -py_library( +drake_py_library( name = "otool", srcs = ["otool.py"], visibility = ["//:__subpackages__"], deps = [":module_py"], ) -py_library( +drake_py_library( name = "install_test_helper", testonly = 1, srcs = ["install_test_helper.py"], diff --git a/tools/install/dummy/BUILD.bazel b/tools/install/dummy/BUILD.bazel index 357a1d180703..4743593592fc 100644 --- a/tools/install/dummy/BUILD.bazel +++ b/tools/install/dummy/BUILD.bazel @@ -8,9 +8,9 @@ load( ) load( "//tools/skylark:drake_py.bzl", + "drake_py_library", "drake_py_unittest", ) -load("//tools/skylark:py.bzl", "py_library") package(default_visibility = ["//tools/install:__subpackages__"]) @@ -35,7 +35,7 @@ drake_transitive_installed_hdrs_filegroup( deps = [":dummy_private"], ) -py_library( +drake_py_library( name = "dummy_py", testonly = 1, srcs = ["dummy.py"], diff --git a/tools/install/installer.py b/tools/install/installer.py index 5be9d7e27375..70f10aa959c2 100644 --- a/tools/install/installer.py +++ b/tools/install/installer.py @@ -22,7 +22,7 @@ from subprocess import check_output, check_call -from drake.tools.install import otool +from tools.install import otool # Used for matching against libraries and extracting useful components. # N.B. On linux, dynamic libraries may have their version number as a suffix diff --git a/tools/install/test/install_meta_test.py b/tools/install/test/install_meta_test.py index ad57307bf21a..b1aee822ec8c 100644 --- a/tools/install/test/install_meta_test.py +++ b/tools/install/test/install_meta_test.py @@ -8,7 +8,7 @@ from subprocess import STDOUT, check_output import sys -import drake.tools.install.installer as installer +import tools.install.installer as installer # TODO(eric.cousineau): Expand on these tests, especially for nuanced things # like Python C extensions. diff --git a/tools/install/test/installer_test.py b/tools/install/test/installer_test.py index 81bbb1ab0671..25499566d18d 100644 --- a/tools/install/test/installer_test.py +++ b/tools/install/test/installer_test.py @@ -4,7 +4,7 @@ from os.path import isdir, join import unittest -from drake.tools.install.installer import Installer +from tools.install.installer import Installer class TestInstall(unittest.TestCase): diff --git a/tools/jupyter/BUILD.bazel b/tools/jupyter/BUILD.bazel index b6db4034a203..c04f639d61db 100644 --- a/tools/jupyter/BUILD.bazel +++ b/tools/jupyter/BUILD.bazel @@ -1,28 +1,27 @@ load("//tools/jupyter:jupyter_py.bzl", "drake_jupyter_py_binary") load("//tools/lint:lint.bzl", "add_lint_tests") -load( - "//tools/skylark:drake_py.bzl", - "drake_py_library", - "drake_py_unittest", -) +load("//tools/skylark:drake_py.bzl", "drake_py_unittest") +load("//tools/skylark:py.bzl", "py_library") -drake_py_library( - name = "module_py", - srcs = ["__init__.py"], - deps = ["//tools:module_py"], -) +package(default_visibility = ["//visibility:private"]) -drake_py_library( +# Note that we do NOT use drake_py_library here, so that our codegen via the +# JUPYTER_PY_TEMPLATE file is as simple and portable as possible. Instead, +# we'll use an `imports = ["."]` to establish a helpful `sys.path`. +py_library( name = "jupyter_bazel_py", srcs = ["jupyter_bazel.py"], + imports = ["."], visibility = ["//visibility:public"], - deps = [":module_py"], ) -drake_py_library( +# Note that we do NOT use drake_py_library here, so that this program is a +# more representative demo of what and end user would experience. Instead, +# we'll use an `imports = ["."]` to establish a helpful `sys.path`. +py_library( name = "example_library", srcs = ["example_library.py"], - imports = [":module_py"], + imports = ["."], ) drake_jupyter_py_binary( diff --git a/tools/jupyter/__init__.py b/tools/jupyter/__init__.py deleted file mode 100644 index 5b38b6d5d7d1..000000000000 --- a/tools/jupyter/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Empty Python module `__init__`, required to make this a module. diff --git a/tools/jupyter/example.ipynb b/tools/jupyter/example.ipynb index 051068c50262..2b82164d7028 100644 --- a/tools/jupyter/example.ipynb +++ b/tools/jupyter/example.ipynb @@ -16,7 +16,7 @@ "import ipywidgets as widgets\n", "import numpy as np\n", "\n", - "from drake.tools.jupyter.example_library import my_func" + "from example_library import my_func" ] }, { diff --git a/tools/jupyter/jupyter_py.bzl b/tools/jupyter/jupyter_py.bzl index 5f9461e2d761..cc3b3d0583e5 100644 --- a/tools/jupyter/jupyter_py.bzl +++ b/tools/jupyter/jupyter_py.bzl @@ -9,7 +9,7 @@ load("//tools/workspace:generate_file.bzl", "generate_file") _JUPYTER_PY_TEMPLATE = """ import sys -from drake.tools.jupyter.jupyter_bazel import _jupyter_bazel_notebook_main +from jupyter_bazel import _jupyter_bazel_notebook_main def main(): diff --git a/tools/lcm_gen/BUILD.bazel b/tools/lcm_gen/BUILD.bazel index df05716b063e..662206c316ad 100644 --- a/tools/lcm_gen/BUILD.bazel +++ b/tools/lcm_gen/BUILD.bazel @@ -12,7 +12,7 @@ load( load("//tools/lint:lint.bzl", "add_lint_tests") # The library target for this tool. -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], deps = ["//tools:module_py"], diff --git a/tools/lcm_gen/test/lcm_gen_test.py b/tools/lcm_gen/test/lcm_gen_test.py index 6ca3d4be0e56..a78170ffebe7 100644 --- a/tools/lcm_gen/test/lcm_gen_test.py +++ b/tools/lcm_gen/test/lcm_gen_test.py @@ -4,7 +4,7 @@ from python import runfiles -from drake.tools.lcm_gen import ( +from tools.lcm_gen import ( CppGen, Parser, PrimitiveType, diff --git a/tools/lint/BUILD.bazel b/tools/lint/BUILD.bazel index 78a594926a8a..21bafb0f40a4 100644 --- a/tools/lint/BUILD.bazel +++ b/tools/lint/BUILD.bazel @@ -13,7 +13,7 @@ load( package(default_visibility = ["//visibility:public"]) -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], deps = ["//tools:module_py"], diff --git a/tools/lint/buildifier.py b/tools/lint/buildifier.py index 0b650f8d6d0e..7a56e6ad5cd2 100644 --- a/tools/lint/buildifier.py +++ b/tools/lint/buildifier.py @@ -12,8 +12,8 @@ import sys from subprocess import Popen, PIPE, STDOUT -from drake.tools.lint.find_data import find_data -from drake.tools.lint.util import find_all_sources +from tools.lint.find_data import find_data +from tools.lint.util import find_all_sources # These match data=[] in our BUILD.bazel file. _BUILDIFIER = "external/buildifier/buildifier" diff --git a/tools/lint/clang_format_includes.py b/tools/lint/clang_format_includes.py index 5dd30481b471..614434e84702 100644 --- a/tools/lint/clang_format_includes.py +++ b/tools/lint/clang_format_includes.py @@ -8,8 +8,8 @@ import os import sys -from drake.tools.lint.formatter import IncludeFormatter -from drake.tools.lint.util import find_all_sources +from tools.lint.formatter import IncludeFormatter +from tools.lint.util import find_all_sources def main(workspace_name="drake"): diff --git a/tools/lint/clang_format_lint.py b/tools/lint/clang_format_lint.py index e2ff673b1726..64a500c2ceb7 100644 --- a/tools/lint/clang_format_lint.py +++ b/tools/lint/clang_format_lint.py @@ -2,7 +2,7 @@ import subprocess import sys -import drake.tools.lint.clang_format as clang_format_lib +import tools.lint.clang_format as clang_format_lib def _is_cxx(filename): diff --git a/tools/lint/drakelint.py b/tools/lint/drakelint.py index db3dcfcfd124..264915cad6af 100644 --- a/tools/lint/drakelint.py +++ b/tools/lint/drakelint.py @@ -2,7 +2,7 @@ import re import sys -from drake.tools.lint.formatter import IncludeFormatter +from tools.lint.formatter import IncludeFormatter def _check_unguarded_openmp_uses(filename): diff --git a/tools/lint/formatter.py b/tools/lint/formatter.py index 7810994749dc..c998958232fb 100644 --- a/tools/lint/formatter.py +++ b/tools/lint/formatter.py @@ -5,7 +5,7 @@ import os from subprocess import Popen, PIPE, CalledProcessError -import drake.tools.lint.clang_format as clang_format_lib +import tools.lint.clang_format as clang_format_lib class FormatterBase: diff --git a/tools/lint/python_lint.bzl b/tools/lint/python_lint.bzl index c7f0ec5003ac..e777ddc4640f 100644 --- a/tools/lint/python_lint.bzl +++ b/tools/lint/python_lint.bzl @@ -52,18 +52,6 @@ def python_lint( PYTHON_LINT_IGNORE_DEFAULT (as strings, with the 'E' or 'W'). exclude: List of labels to exclude from linting, e.g., [:foo.py]. extra_srcs: Source files that are not discoverable via rules. - - Example: - BUILD: - load("//tools/lint:python_lint.bzl", "python_lint") - load("//tools/skylark:py.bzl", "py_library") - - py_library( - name = "foo", - srcs = ["foo.py"], - ) - - python_lint() """ if existing_rules == None: existing_rules = native.existing_rules().values() diff --git a/tools/lint/test/find_data_test.py b/tools/lint/test/find_data_test.py index 6ffb1f3ebcd0..2554e0c8c2a0 100644 --- a/tools/lint/test/find_data_test.py +++ b/tools/lint/test/find_data_test.py @@ -1,7 +1,7 @@ import os import unittest -from drake.tools.lint.find_data import find_data +from tools.lint.find_data import find_data class FindDataTest(unittest.TestCase): diff --git a/tools/lint/test/formatter_test.py b/tools/lint/test/formatter_test.py index 294b86e47511..b84b5772312e 100644 --- a/tools/lint/test/formatter_test.py +++ b/tools/lint/test/formatter_test.py @@ -1,6 +1,6 @@ import unittest -from drake.tools.lint.formatter import FormatterBase, IncludeFormatter +from tools.lint.formatter import FormatterBase, IncludeFormatter class TestFormatterBase(unittest.TestCase): diff --git a/tools/lint/test/util_test.py b/tools/lint/test/util_test.py index 3628617e3acf..2ac1ad7ff41c 100644 --- a/tools/lint/test/util_test.py +++ b/tools/lint/test/util_test.py @@ -1,7 +1,7 @@ import os import unittest -from drake.tools.lint.util import find_all_sources +from tools.lint.util import find_all_sources class UtilTest(unittest.TestCase): diff --git a/tools/skylark/BUILD.bazel b/tools/skylark/BUILD.bazel index 4331cb5e6a11..f7010bb2d5bd 100644 --- a/tools/skylark/BUILD.bazel +++ b/tools/skylark/BUILD.bazel @@ -1,6 +1,5 @@ load("//tools/lint:lint.bzl", "add_lint_tests") -load("//tools/skylark:drake_py.bzl", "drake_py_unittest") -load("//tools/skylark:py.bzl", "py_binary") +load("//tools/skylark:drake_py.bzl", "drake_py_binary", "drake_py_unittest") package(default_visibility = ["//visibility:public"]) @@ -14,7 +13,7 @@ config_setting( constraint_values = ["@platforms//os:osx"], ) -py_binary( +drake_py_binary( name = "rewrite_osx_ar_hidden", srcs = ["rewrite_osx_ar_hidden.py"], ) diff --git a/tools/wheel/BUILD.bazel b/tools/wheel/BUILD.bazel index e4dbf859ee1c..a1b8fac7325e 100644 --- a/tools/wheel/BUILD.bazel +++ b/tools/wheel/BUILD.bazel @@ -1,12 +1,12 @@ load("//tools/lint:lint.bzl", "add_lint_tests") -load("//tools/skylark:drake_py.bzl", "drake_py_binary") +load("//tools/skylark:drake_py.bzl", "drake_py_binary", "drake_py_library") exports_files( glob(["**"]), visibility = ["//tools:__subpackages__"], ) -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], visibility = [":__subpackages__"], diff --git a/tools/wheel/macos/change_lpath.py b/tools/wheel/macos/change_lpath.py index d80431b388ac..c48575a4e85b 100644 --- a/tools/wheel/macos/change_lpath.py +++ b/tools/wheel/macos/change_lpath.py @@ -8,7 +8,7 @@ import subprocess import sys -from drake.tools.install import otool +from tools.install import otool def _chlpath(path, libs, old, new): diff --git a/tools/wheel/macos/strip_rpath.py b/tools/wheel/macos/strip_rpath.py index 04dbe73be623..a4327af6b84a 100644 --- a/tools/wheel/macos/strip_rpath.py +++ b/tools/wheel/macos/strip_rpath.py @@ -7,7 +7,7 @@ import subprocess import sys -from drake.tools.install import otool +from tools.install import otool def _filter_rpaths(paths, exclusions): diff --git a/tools/wheel/wheel_builder/main.py b/tools/wheel/wheel_builder/main.py index 3c9b7bdd54b1..1e290e31ebf2 100644 --- a/tools/wheel/wheel_builder/main.py +++ b/tools/wheel/wheel_builder/main.py @@ -4,14 +4,14 @@ import sys -from drake.tools.wheel.wheel_builder.common import do_main as main +from tools.wheel.wheel_builder.common import do_main as main if __name__ == '__main__': if sys.platform == 'linux': - from drake.tools.wheel.wheel_builder import linux as platform + from tools.wheel.wheel_builder import linux as platform elif sys.platform == 'darwin': - from drake.tools.wheel.wheel_builder import macos as platform + from tools.wheel.wheel_builder import macos as platform else: platform = None diff --git a/tools/workspace/BUILD.bazel b/tools/workspace/BUILD.bazel index e51b1e6cd642..10b2fc59dbbd 100644 --- a/tools/workspace/BUILD.bazel +++ b/tools/workspace/BUILD.bazel @@ -1,10 +1,14 @@ load("//tools/install:check_licenses.bzl", "check_licenses") load("//tools/install:install.bzl", "install") load("//tools/lint:lint.bzl", "add_lint_tests") -load("//tools/skylark:drake_py.bzl", "drake_py_binary", "drake_py_test") -load("//tools/skylark:py.bzl", "py_library") +load( + "//tools/skylark:drake_py.bzl", + "drake_py_binary", + "drake_py_library", + "drake_py_test", +) -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], visibility = [":__subpackages__"], diff --git a/tools/workspace/mirror_to_s3.py b/tools/workspace/mirror_to_s3.py index 4b5ca71e2614..3cec96749a90 100644 --- a/tools/workspace/mirror_to_s3.py +++ b/tools/workspace/mirror_to_s3.py @@ -24,7 +24,7 @@ import botocore import requests -from drake.tools.workspace.metadata import read_repository_metadata +from tools.workspace.metadata import read_repository_metadata BUCKET_NAME = 'drake-mirror' diff --git a/tools/workspace/new_release.py b/tools/workspace/new_release.py index d9dc350f6e49..dc8e1dd6a57f 100644 --- a/tools/workspace/new_release.py +++ b/tools/workspace/new_release.py @@ -48,7 +48,7 @@ import git import github3 -from drake.tools.workspace.metadata import read_repository_metadata +from tools.workspace.metadata import read_repository_metadata logger = logging.getLogger('new_release') logger.setLevel(logging.INFO) diff --git a/tools/workspace/openusd_internal/BUILD.bazel b/tools/workspace/openusd_internal/BUILD.bazel index 262448f44c86..d0abcc2fdfe5 100644 --- a/tools/workspace/openusd_internal/BUILD.bazel +++ b/tools/workspace/openusd_internal/BUILD.bazel @@ -1,7 +1,8 @@ load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("//tools/lint:lint.bzl", "add_lint_tests") +load("//tools/skylark:drake_py.bzl", "drake_py_binary") -py_binary( +drake_py_binary( name = "upgrade", srcs = ["upgrade.py"], data = [ diff --git a/tools/workspace/pybind11/BUILD.bazel b/tools/workspace/pybind11/BUILD.bazel index 8ea022f3e0d3..d94f84327827 100644 --- a/tools/workspace/pybind11/BUILD.bazel +++ b/tools/workspace/pybind11/BUILD.bazel @@ -4,8 +4,12 @@ load( "drake_cc_googletest", "drake_cc_library", ) -load("//tools/skylark:drake_py.bzl", "drake_py_unittest") -load("//tools/skylark:py.bzl", "py_binary", "py_library") +load( + "//tools/skylark:drake_py.bzl", + "drake_py_binary", + "drake_py_library", + "drake_py_unittest", +) load( "//tools/skylark:pybind.bzl", "generate_pybind_documentation_header", @@ -19,13 +23,13 @@ exports_files( visibility = ["@pybind11//:__pkg__"], ) -py_library( +drake_py_library( name = "module_py", srcs = ["__init__.py"], deps = ["//tools/workspace:module_py"], ) -py_library( +drake_py_library( name = "libclang_setup_py", srcs = ["libclang_setup.py"], visibility = ["//visibility:public"], @@ -35,11 +39,9 @@ py_library( ], ) -py_binary( +drake_py_binary( name = "mkdoc", srcs = ["mkdoc.py"], - python_version = "PY3", - srcs_version = "PY3", visibility = ["//visibility:public"], deps = [ ":libclang_setup_py", @@ -48,7 +50,7 @@ py_binary( ], ) -py_library( +drake_py_library( name = "mkdoc_comment_py", srcs = ["mkdoc_comment.py"], visibility = ["//visibility:public"], diff --git a/tools/workspace/pybind11/mkdoc.py b/tools/workspace/pybind11/mkdoc.py index 5aba732683cd..53fbc829c8fd 100644 --- a/tools/workspace/pybind11/mkdoc.py +++ b/tools/workspace/pybind11/mkdoc.py @@ -49,9 +49,8 @@ from clang import cindex from clang.cindex import AccessSpecifier, CursorKind, TypeKind -from drake.tools.workspace.pybind11.mkdoc_comment import process_comment - -from drake.tools.workspace.pybind11.libclang_setup import add_library_paths +from tools.workspace.pybind11.libclang_setup import add_library_paths +from tools.workspace.pybind11.mkdoc_comment import process_comment CLASS_KINDS = [ diff --git a/tools/workspace/pybind11/mkdoc_comment.py b/tools/workspace/pybind11/mkdoc_comment.py index 50f1339eda16..9b38dce51bef 100644 --- a/tools/workspace/pybind11/mkdoc_comment.py +++ b/tools/workspace/pybind11/mkdoc_comment.py @@ -38,7 +38,7 @@ import re import textwrap -from drake.doc.doxygen_cxx.system_doxygen import process_doxygen_to_sphinx +from doc.doxygen_cxx.system_doxygen import process_doxygen_to_sphinx def process_comment(comment): diff --git a/tools/workspace/pybind11/test/mkdoc_comment_test.py b/tools/workspace/pybind11/test/mkdoc_comment_test.py index 7e88ec71c4df..3d024f6597f2 100644 --- a/tools/workspace/pybind11/test/mkdoc_comment_test.py +++ b/tools/workspace/pybind11/test/mkdoc_comment_test.py @@ -1,6 +1,6 @@ import unittest -from drake.tools.workspace.pybind11.mkdoc_comment import process_comment +from tools.workspace.pybind11.mkdoc_comment import process_comment class TestDocstring(unittest.TestCase): diff --git a/tools/workspace/vendor_cxx_test.py b/tools/workspace/vendor_cxx_test.py index f9f631b6ebdc..c4739dd6cdae 100644 --- a/tools/workspace/vendor_cxx_test.py +++ b/tools/workspace/vendor_cxx_test.py @@ -1,6 +1,6 @@ import unittest -from drake.tools.workspace.vendor_cxx import _rewrite_one_text +from tools.workspace.vendor_cxx import _rewrite_one_text class TestVendorCxx(unittest.TestCase):