Skip to content

Commit 64d928b

Browse files
committed
deals with docker container cases
1 parent 1cc8e21 commit 64d928b

File tree

1 file changed

+44
-28
lines changed

1 file changed

+44
-28
lines changed

isaaclab.sh

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,40 @@ export ISAACLAB_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && p
2424

2525
# extract isaac sim path
2626
extract_isaacsim_path() {
27-
# Check if IsaacSim directory manually specified
28-
# Note: for manually build isaacsim, this: _build/linux-x86_64/release
29-
if [ ! -z ${ISAACSIM_PATH} ];
30-
then
31-
# Use local build (for internal development) or user specified path
32-
local isaac_path=${ISAACSIM_PATH}
33-
else
34-
# Check if we have pip package installed
35-
if [ $(pip list | grep -c 'isaacsim-rl') ]; then
36-
# Use the python executable to get the path
37-
local python_exe=$(extract_python_exe)
38-
# Retrieve the path importing isaac sim and getting the environment path
27+
# Check if we have pip package installed inside conda environment
28+
if ! [[ -z "${CONDA_PREFIX}" ]]; then
29+
# Use the python executable to get the path
30+
local python_exe=${CONDA_PREFIX}/bin/python
31+
# Retrieve the path importing isaac sim and getting the environment path
32+
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') ]; then
3933
local isaac_path=$(${python_exe} -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
4034
else
41-
# Use the sym-link path to Isaac Sim directory
42-
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
35+
# If package not installed, use an empty path for failure
36+
local isaac_path=''
4337
fi
38+
elif command -v python &> /dev/null; then
39+
# Use the python executable to get the path
40+
local python_exe=$(which python)
41+
# Retrieve the path importing isaac sim and getting the environment path
42+
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') ]; then
43+
local isaac_path=$(${python_exe} -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
44+
else
45+
# If package not installed, use an empty path for failure
46+
local isaac_path=''
47+
fi
48+
else
49+
# Use the sym-link path to Isaac Sim directory
50+
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
4451
fi
4552
# check if there is a path available
4653
if [ ! -d "${isaac_path}" ]; then
47-
echo "[ERROR] No Isaac Sim directory found at path: ${isaac_path}" >&2
48-
echo "[ERROR] Please specify the path to the Isaac Sim directory using 'ISAACSIM_PATH' environment variable." >&2
54+
# throw an error if no path is found
55+
echo -e "[ERROR] Unable to find the Isaac Sim directory: '${isaac_path}'" >&2
56+
echo -e "\tThis could be due to the following reasons:" >&2
57+
echo -e "\t1. Conda environment is not activated." >&2
58+
echo -e "\t2. Isaac Sim pip package 'isaacsim-rl' is not installed." >&2
59+
echo -e "\t3. Isaac Sim directory is not available at the default path: ${ISAACLAB_PATH}/_isaac_sim" >&2
60+
# exit the script
4961
exit 1
5062
fi
5163
# return the result
@@ -58,27 +70,33 @@ extract_python_exe() {
5870
if ! [[ -z "${CONDA_PREFIX}" ]]; then
5971
# use conda python
6072
local python_exe=${CONDA_PREFIX}/bin/python
61-
else
62-
# check if pip package is installed
63-
if [ $(pip list | grep -c 'isaacsim-rl') ]; then
64-
# use current python executable
73+
elif command -v python &> /dev/null; then
74+
# use the python executable to get the path
75+
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') ]; then
6576
local python_exe=$(which python)
6677
else
67-
# obtain the isaac sim path
68-
local isaac_path=$(extract_isaacsim_path)
69-
# use python from kit
70-
local python_exe=${isaac_path}/python.sh
78+
# leave a blank path for failure
79+
local python_exe=''
7180
fi
81+
else
82+
# obtain the isaac sim path
83+
local isaac_path=$(extract_isaacsim_path)
84+
# use python from kit
85+
local python_exe=${isaac_path}/python.sh
7286
fi
7387
# check if there is a python path available
7488
if [ ! -f "${python_exe}" ]; then
75-
echo "[ERROR] No python executable found at path: ${python_exe}" >&2
89+
echo -e "[ERROR] Unable to find any Python executable at path: '${python_exe}'" >&2
90+
echo -e "\tThis could be due to the following reasons:" >&2
91+
echo -e "\t1. Conda environment is not activated." >&2
92+
echo -e "\t2. Isaac Sim pip package 'isaacsim-rl' is not installed." >&2
93+
echo -e "\t3. Python executable is not available at the default path: ${ISAACLAB_PATH}/_isaac_sim/python.sh" >&2
7694
exit 1
7795
fi
7896
# kit dependencies are built with python 3.10 so any other version will not work
7997
# this is needed in case users have multiple python versions installed and the wrong one is being used
8098
if [ "$(${python_exe} --version | grep -c '3.10')" -eq 0 ]; then
81-
echo "[ERROR] Found version: $(${python_exe} --version) while expecting 3.10. Please use the correct python version." >&2
99+
echo "[ERROR] Found Python version: $(${python_exe} --version) while expecting 3.10. Please use the correct python version." >&2
82100
exit 1
83101
fi
84102
# return the result
@@ -261,8 +279,6 @@ while [[ $# -gt 0 ]]; do
261279
fi
262280
# install the rl-frameworks specified
263281
${python_exe} -m pip install -e ${ISAACLAB_PATH}/source/extensions/omni.isaac.lab_tasks["${framework_name}"]
264-
# setup vscode settings
265-
update_vscode_settings
266282
# unset local variables
267283
unset extract_python_exe
268284
unset install_isaaclab_extension

0 commit comments

Comments
 (0)