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
This commit is contained in:
Alessio Quaglino
2025-08-13 07:42:31 -07:00
committed by Copybara-Service
parent 6a9e68a542
commit cc52d0242b
2 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -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)
+1 -2
View File
@@ -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<std::string>(asset.first).c_str());
std::string buffer_name = py::cast<std::string>(asset.first).c_str();
std::string buffer = py::cast<std::string>(asset.second);
const int vfs_error = InterceptMjErrors(mj_addBufferVFS)(
&vfs, buffer_name.c_str(), buffer.c_str(), buffer.size());