Skip to content

Fixs isaaclab.sh to detect isaacsim_version accurately 4.5 or >= 5.0 #3139

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

Merged
merged 1 commit into from
Aug 12, 2025
Merged
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
47 changes: 31 additions & 16 deletions isaaclab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,48 @@ install_system_deps() {
fi
}

# Returns success (exit code 0 / "true") if the detected Isaac Sim version starts with 4.5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Does the isaaclab.bat file also need to be adapted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should convert these shell/bat scripts to a python file to simplify the maintainance work between different OS platforms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think people generally also understand python more than bash.
Though I wonder if using python, could it be a lot more verbose than writing bash.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the isaaclab.bat, its checking workflow is good, and also worked with windows, so I think no need for now

# otherwise returns non-zero ("false"). Works with both symlinked binary installs and pip installs.
is_isaacsim_version_4_5() {
local version=""
local python_exe
python_exe=$(extract_python_exe)

# 1) Try the VERSION file
local sim_file
sim_file=$("${python_exe}" -c "import isaacsim; print(isaacsim.__file__)" 2>/dev/null) || return 1
local version_path
version_path=$(dirname "${sim_file}")/../../VERSION
if [[ -f "${version_path}" ]]; then
local ver
ver=$(head -n1 "${version_path}")
[[ "${ver}" == 4.5* ]] && return 0
# 0) Fast path: read VERSION file from the symlinked _isaac_sim directory (binary install)
# If the repository has _isaac_sim → <IsaacSimRoot> symlink, the VERSION file is the simplest source of truth.
if [[ -f "${ISAACLAB_PATH}/_isaac_sim/VERSION" ]]; then
# Read first line of the VERSION file; don't fail the whole script on errors.
version=$(head -n1 "${ISAACLAB_PATH}/_isaac_sim/VERSION" || true)
fi

# 2) Fallback to importlib.metadata via a here-doc
local ver
ver=$("${python_exe}" <<'PYCODE' 2>/dev/null
# 1) Package-path probe: import isaacsim and walk up to ../../VERSION (pip or nonstandard layouts)
# If we still don't know the version, ask Python where the isaacsim package lives
if [[ -z "$version" ]]; then
local sim_file=""
# Print isaacsim.__file__; suppress errors so set -e won't abort.
sim_file=$("${python_exe}" -c 'import isaacsim, os; print(isaacsim.__file__)' 2>/dev/null || true)
if [[ -n "$sim_file" ]]; then
local version_path
version_path="$(dirname "$sim_file")/../../VERSION"
# If that VERSION file exists, read it.
[[ -f "$version_path" ]] && version=$(head -n1 "$version_path" || true)
fi
fi

# 2) Fallback: use package metadata via importlib.metadata.version("isaacsim")
if [[ -z "$version" ]]; then
version=$("${python_exe}" <<'PY' 2>/dev/null || true
from importlib.metadata import version, PackageNotFoundError
try:
print(version("isaacsim"))
except PackageNotFoundError:
import sys; sys.exit(1)
PYCODE
) || return 1
pass
PY
)
fi

[[ "${ver}" == 4.5* ]]
# Final decision: return success if version begins with "4.5", 0 if match, 1 otherwise.
[[ "$version" == 4.5* ]]
}

# check if running in docker
Expand Down
Loading