diff --git a/bindings/pydrake/multibody/BUILD.bazel b/bindings/pydrake/multibody/BUILD.bazel index 156e1c132da8..17e7bbe2ffb1 100644 --- a/bindings/pydrake/multibody/BUILD.bazel +++ b/bindings/pydrake/multibody/BUILD.bazel @@ -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") @@ -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__", @@ -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", @@ -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", ], ) diff --git a/bindings/pydrake/multibody/run_installed_fix_inertia.py.in b/bindings/pydrake/multibody/run_installed_fix_inertia.py similarity index 78% rename from bindings/pydrake/multibody/run_installed_fix_inertia.py.in rename to bindings/pydrake/multibody/run_installed_fix_inertia.py index 63b24164bd7d..f6d2e66e751a 100755 --- a/bindings/pydrake/multibody/run_installed_fix_inertia.py.in +++ b/bindings/pydrake/multibody/run_installed_fix_inertia.py @@ -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. diff --git a/bindings/pydrake/multibody/run_installed_mesh_to_model.py.in b/bindings/pydrake/multibody/run_installed_mesh_to_model.py similarity index 78% rename from bindings/pydrake/multibody/run_installed_mesh_to_model.py.in rename to bindings/pydrake/multibody/run_installed_mesh_to_model.py index 9aa53bfc71ec..057cf16f6e3f 100755 --- a/bindings/pydrake/multibody/run_installed_mesh_to_model.py.in +++ b/bindings/pydrake/multibody/run_installed_mesh_to_model.py @@ -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. diff --git a/bindings/pydrake/visualization/BUILD.bazel b/bindings/pydrake/visualization/BUILD.bazel index 41a412b26e3e..0c66d6d6d7d3 100644 --- a/bindings/pydrake/visualization/BUILD.bazel +++ b/bindings/pydrake/visualization/BUILD.bazel @@ -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( @@ -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__", @@ -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", @@ -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", ], ) diff --git a/bindings/pydrake/visualization/run_installed_meldis.py.in b/bindings/pydrake/visualization/run_installed_meldis.py similarity index 78% rename from bindings/pydrake/visualization/run_installed_meldis.py.in rename to bindings/pydrake/visualization/run_installed_meldis.py index 7f391b1d8985..6df83b429017 100755 --- a/bindings/pydrake/visualization/run_installed_meldis.py.in +++ b/bindings/pydrake/visualization/run_installed_meldis.py @@ -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. diff --git a/bindings/pydrake/visualization/run_installed_model_visualizer.py.in b/bindings/pydrake/visualization/run_installed_model_visualizer.py similarity index 76% rename from bindings/pydrake/visualization/run_installed_model_visualizer.py.in rename to bindings/pydrake/visualization/run_installed_model_visualizer.py index 977838cb417b..b88d3bf90612 100755 --- a/bindings/pydrake/visualization/run_installed_model_visualizer.py.in +++ b/bindings/pydrake/visualization/run_installed_model_visualizer.py @@ -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. diff --git a/tools/workspace/stable_baselines3_internal/BUILD.bazel b/tools/workspace/stable_baselines3_internal/BUILD.bazel index e4efa4d7f73e..5828dceceb58 100644 --- a/tools/workspace/stable_baselines3_internal/BUILD.bazel +++ b/tools/workspace/stable_baselines3_internal/BUILD.bazel @@ -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"], )