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

[pydrake] Remove some gratuitous uses of python repo constants #22345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 2 additions & 25 deletions bindings/pydrake/multibody/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@python//:version.bzl", "PYTHON_SITE_PACKAGES_RELPATH")
load("//bindings/pydrake:pydrake.bzl", "add_lint_tests_pydrake")
load("//tools/install:install.bzl", "install", "install_files")
load("//tools/jupyter:jupyter_py.bzl", "drake_jupyter_py_binary")
Expand All @@ -18,10 +17,6 @@ load(
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
"//tools/workspace:cmake_configure_file.bzl",
"cmake_configure_file",
)

package(default_visibility = [
"//bindings/pydrake:__subpackages__",
Expand Down Expand Up @@ -298,24 +293,6 @@ drake_jupyter_py_binary(
],
)

cmake_configure_file(
name = "generate_run_installed_mesh_to_model",
src = "run_installed_mesh_to_model.py.in",
out = "run_installed_mesh_to_model.py",
defines = [
"PYTHON_SITE_PACKAGES_RELPATH=" + PYTHON_SITE_PACKAGES_RELPATH,
],
)

cmake_configure_file(
name = "generate_run_installed_fix_inertia",
src = "run_installed_fix_inertia.py.in",
out = "run_installed_fix_inertia.py",
defines = [
"PYTHON_SITE_PACKAGES_RELPATH=" + PYTHON_SITE_PACKAGES_RELPATH,
],
)

install_files(
name = "install_wrapper_scripts",
dest = "bin",
Expand Down Expand Up @@ -566,7 +543,7 @@ drake_py_unittest(

add_lint_tests_pydrake(
python_lint_extra_srcs = [
"run_installed_mesh_to_model.py.in",
"run_installed_fix_inertia.py.in",
"run_installed_mesh_to_model.py",
"run_installed_fix_inertia.py",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def main():
# Ensure that we can import pydrake, accommodating symlinks.
prefix_dir = dirname(dirname(realpath(__file__)))
assert isdir(join(prefix_dir, "bin")), f"Bad location: {prefix_dir}"
site_dir = join(prefix_dir, "@PYTHON_SITE_PACKAGES_RELPATH@")
version = f"{sys.version_info.major}.{sys.version_info.minor}"
site_dir = join(prefix_dir, f"lib/python{version}/site-packages")
sys.path.insert(0, site_dir)

# Execute the imported main.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def main():
# Ensure that we can import pydrake, accommodating symlinks.
prefix_dir = dirname(dirname(realpath(__file__)))
assert isdir(join(prefix_dir, "bin")), f"Bad location: {prefix_dir}"
site_dir = join(prefix_dir, "@PYTHON_SITE_PACKAGES_RELPATH@")
version = f"{sys.version_info.major}.{sys.version_info.minor}"
site_dir = join(prefix_dir, f"lib/python{version}/site-packages")
sys.path.insert(0, site_dir)

# Execute the imported main.
Expand Down
27 changes: 2 additions & 25 deletions bindings/pydrake/visualization/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@python//:version.bzl", "PYTHON_SITE_PACKAGES_RELPATH")
load("//bindings/pydrake:pydrake.bzl", "add_lint_tests_pydrake")
load("//tools/install:install.bzl", "install", "install_files")
load(
Expand All @@ -13,10 +12,6 @@ load(
"get_drake_py_installs",
"get_pybind_package_info",
)
load(
"//tools/workspace:cmake_configure_file.bzl",
"cmake_configure_file",
)

package(default_visibility = [
"//bindings/pydrake:__subpackages__",
Expand Down Expand Up @@ -91,24 +86,6 @@ drake_py_library(
deps = [":visualization"],
)

cmake_configure_file(
name = "generate_run_installed_meldis",
src = "run_installed_meldis.py.in",
out = "run_installed_meldis.py",
defines = [
"PYTHON_SITE_PACKAGES_RELPATH=" + PYTHON_SITE_PACKAGES_RELPATH,
],
)

cmake_configure_file(
name = "generate_run_installed_model_visualizer",
src = "run_installed_model_visualizer.py.in",
out = "run_installed_model_visualizer.py",
defines = [
"PYTHON_SITE_PACKAGES_RELPATH=" + PYTHON_SITE_PACKAGES_RELPATH,
],
)

install_files(
name = "install_wrapper_scripts",
dest = "bin",
Expand Down Expand Up @@ -256,8 +233,8 @@ drake_py_unittest(

add_lint_tests_pydrake(
python_lint_extra_srcs = [
"run_installed_meldis.py.in",
"run_installed_model_visualizer.py.in",
"run_installed_meldis.py",
"run_installed_model_visualizer.py",
"test/visualization_install_tests.py",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def main():
# Ensure that we can import pydrake, accommodating symlinks.
prefix_dir = dirname(dirname(realpath(__file__)))
assert isdir(join(prefix_dir, "bin")), f"Bad location: {prefix_dir}"
site_dir = join(prefix_dir, "@PYTHON_SITE_PACKAGES_RELPATH@")
version = f"{sys.version_info.major}.{sys.version_info.minor}"
site_dir = join(prefix_dir, f"lib/python{version}/site-packages")
sys.path.insert(0, site_dir)

# Execute the imported main.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def main():
# Ensure that we can import pydrake, accommodating symlinks.
prefix_dir = dirname(dirname(realpath(__file__)))
assert isdir(join(prefix_dir, "bin")), f"Bad location: {prefix_dir}"
site_dir = join(prefix_dir, "@PYTHON_SITE_PACKAGES_RELPATH@")
version = f"{sys.version_info.major}.{sys.version_info.minor}"
site_dir = join(prefix_dir, f"lib/python{version}/site-packages")
sys.stdout.flush()
sys.path.insert(0, site_dir)

# Execute the imported main.
Expand Down
6 changes: 0 additions & 6 deletions tools/workspace/stable_baselines3_internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
load("@python//:version.bzl", "PYTHON_VERSION")
load("//tools/lint:lint.bzl", "add_lint_tests")
load("//tools/skylark:drake_py.bzl", "drake_py_unittest")

drake_py_unittest(
name = "stable_baselines3_internal_test",
# DrakeGym is only supported for Python >= 3.10.
tags = ["manual"] if PYTHON_VERSION in [
"3.8",
"3.9",
] else [],
deps = ["@stable_baselines3_internal//:stable_baselines3"],
)

Expand Down