From cc52d0242baa61f111dcba7b7f0ba5bf2385807a Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Wed, 13 Aug 2025 07:42:31 -0700 Subject: [PATCH] Do not strip the path when compiling an mjSpec. The path has already been stripped while parsing. This will enable prefixes that contain a `/` while attaching. Also use `spec.meshdir` for asset paths in `spec.to_zip()`. PiperOrigin-RevId: 794573523 Change-Id: Ic36bb641c3d72848399006cf718afd8542e91ed4 --- python/mujoco/__init__.py | 2 +- python/mujoco/specs_wrapper.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/python/mujoco/__init__.py b/python/mujoco/__init__.py index de578935..d800c0b0 100644 --- a/python/mujoco/__init__.py +++ b/python/mujoco/__init__.py @@ -105,7 +105,7 @@ def to_zip(spec: _specs.MjSpec, file: Union[str, IO[bytes]]) -> None: file = open(file, 'wb') with zipfile.ZipFile(file, 'w') as zip_file: for filename, contents in files_to_zip.items(): - zip_info = zipfile.ZipInfo(os.path.join(spec.modelname, filename)) + zip_info = zipfile.ZipInfo(os.path.join(spec.meshdir, filename)) zip_file.writestr(zip_info, contents) diff --git a/python/mujoco/specs_wrapper.cc b/python/mujoco/specs_wrapper.cc index 18ffd3b5..3ca6d3c5 100644 --- a/python/mujoco/specs_wrapper.cc +++ b/python/mujoco/specs_wrapper.cc @@ -98,8 +98,7 @@ raw::MjModel* MjSpec::Compile() { mjVFS vfs; mj_defaultVFS(&vfs); for (const auto& asset : assets) { - std::string buffer_name = - _impl::StripPath(py::cast(asset.first).c_str()); + std::string buffer_name = py::cast(asset.first).c_str(); std::string buffer = py::cast(asset.second); const int vfs_error = InterceptMjErrors(mj_addBufferVFS)( &vfs, buffer_name.c_str(), buffer.c_str(), buffer.size());