Skip to content

Commit

Permalink
Require python version 3.10 in isaaclab.sh
Browse files Browse the repository at this point in the history
3.10 is required. When running on Ubuntu 24, I ran into trouble
because Ubuntu 24 ships with 3.12. I was able to get isaaclab.sh
to work with the following steps:

* Install a version of 3.10 (be careful, 3.12 must remain the
default).
* Create a venv with 3.10, install isaac sim in the venv, then
proceed to install isaac lab.
* The following changes to the script:
** In `extract_python_exe`, check that we found the desired
version.
** Use the result of `extract_python_exe` everywhere to invoke
python (outside of `extract_python_exe` itself).

Also, fixed a bug where we could consider the system python
valid even if we counted 0 installed isaacsim-rl packages.
We meant to check for >0 packages installed.

Disclaimer: Someone else please try this locally.
  • Loading branch information
steple committed Jan 17, 2025
1 parent b08178b commit 0aa48d8
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions isaaclab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export ISAACLAB_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && p
# Helper functions
#==

# This is the python version we would like to use.
PYTHON_VERSION="3.10"

# extract isaac sim path
extract_isaacsim_path() {
# Use the sym-link path to Isaac Sim directory
Expand All @@ -31,7 +34,7 @@ extract_isaacsim_path() {
# Use the python executable to get the path
local python_exe=$(extract_python_exe)
# Retrieve the path importing isaac sim and getting the environment path
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') ]; then
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') -gt 0 ]; then
local isaac_path=$(${python_exe} -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
fi
fi
Expand Down Expand Up @@ -61,11 +64,12 @@ extract_python_exe() {
local python_exe=${ISAACLAB_PATH}/_isaac_sim/python.sh

if [ ! -f "${python_exe}" ]; then
# note: we need to check system python for cases such as docker
# inside docker, if user installed into system python, we need to use that
# otherwise, use the python from the kit
if [ $(python -m pip list | grep -c 'isaacsim-rl') ]; then
local python_exe=$(which python)
# Next, see if the system provides python. This includes use cases such as docker in docker, or systems
# where the default python is not the desired python. In the latter case, python would give us the default
# binary even if we are in a virtual environment created with the desired python version.
# That version is ok to use if the isaacsim-rl package is installed.
if [ $(python${PYTHON_VERSION} -m pip list | grep -c 'isaacsim-rl') -gt 0 ]; then
local python_exe=$(which python${PYTHON_VERSION})
fi
fi
fi
Expand All @@ -78,6 +82,15 @@ extract_python_exe() {
echo -e "\t3. Python executable is not available at the default path: ${ISAACLAB_PATH}/_isaac_sim/python.sh" >&2
exit 1
fi

# Get the major.minor version of the python that we just found.
python_exe_version=$(${python_exe} -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))')
# Check if it is the desired version.
if [ "${PYTHON_VERSION}" != ${python_exe_version} ]; then
echo -e "[ERROR] Found python version ${python_exe_version}, but wanted ${PYTHON_VERSION}." >&2
exit 1
fi

# return the result
echo ${python_exe}
}
Expand All @@ -86,12 +99,14 @@ extract_python_exe() {
extract_isaacsim_exe() {
# obtain the isaac sim path
local isaac_path=$(extract_isaacsim_path)
# python executable to use
# isaacsim executable to use
local isaacsim_exe=${isaac_path}/isaac-sim.sh
# retrieve the python executable
python_exe=$(extract_python_exe)
# check if there is a python path available
if [ ! -f "${isaacsim_exe}" ]; then
# check for installation using Isaac Sim pip
if [ $(python -m pip list | grep -c 'isaacsim-rl') -gt 0 ]; then
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') -gt 0 ]; then
# Isaac Sim - Python packages entry point
local isaacsim_exe="isaacsim omni.isaac.sim"
else
Expand Down Expand Up @@ -130,7 +145,7 @@ setup_conda_env() {
echo -e "[INFO] Conda environment named '${env_name}' already exists."
else
echo -e "[INFO] Creating conda environment named '${env_name}'..."
conda create -y --name ${env_name} python=3.10
conda create -y --name ${env_name} python=${PYTHON_VERSION}
fi

# cache current paths for later
Expand Down

0 comments on commit 0aa48d8

Please sign in to comment.