Skip to content

Commit f49302e

Browse files
authored
Fixes isaaclab.sh script to deal with local system python (isaac-sim#649)
# Description Realized that isaac-sim#631 did not deal properly with the case when not in a conda or docker. This MR re-writes the logic to hopefully make the operation safe. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
1 parent d84fbed commit f49302e

File tree

3 files changed

+29
-41
lines changed

3 files changed

+29
-41
lines changed

.vscode/tools/setup_vscode.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
isaacsim_dir = os.environ.get("ISAAC_PATH", "")
2828
except ModuleNotFoundError or ImportError:
2929
isaacsim_dir = os.path.join(ISAACLAB_DIR, "_isaac_sim")
30+
except EOFError:
31+
print("Unable to trigger EULA acceptance. This is likely due to the script being run in a non-interactive shell.")
32+
print("Please run the script in an interactive shell to accept the EULA.")
33+
print("Skipping the setup of the VSCode settings...")
34+
sys.exit(0)
3035

3136
# check if the isaac-sim directory exists
3237
if not os.path.exists(isaacsim_dir):

docker/Dockerfile.pip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# To build the Docker image and run the Docker container, follow the steps below:
1111
#
1212
# 1. Build the Docker image:
13-
# docker build -t isaac-lab:latest -f docker/Dockerfile.pip .
13+
# docker build -t isaac-lab-pip:latest -f docker/Dockerfile.pip .
1414
# 2. Run the Docker container:
15-
# docker run -it --gpus all --rm --network=host --name isaac-lab -v $(pwd):/root/isaaclab isaac-lab:latest
15+
# docker run -it --gpus all --rm --network=host --name isaac-lab -v $(pwd):/root/isaaclab isaac-lab-pip:latest
1616

1717
# Base image: Ubuntu 22.04
1818
FROM ubuntu:22.04 AS base

isaaclab.sh

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

2525
# extract isaac sim path
2626
extract_isaacsim_path() {
27-
# Check if we have pip package installed inside conda environment
28-
if ! [[ -z "${CONDA_PREFIX}" ]]; then
27+
# Use the sym-link path to Isaac Sim directory
28+
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
29+
# If above path is not available, try to find the path using python
30+
if [ ! -d "${isaac_path}" ]; then
2931
# Use the python executable to get the path
30-
local python_exe=${CONDA_PREFIX}/bin/python
32+
local python_exe=$(extract_python_exe)
3133
# Retrieve the path importing isaac sim and getting the environment path
3234
if [ $(${python_exe} -m pip list | grep -c 'isaacsim-rl') ]; then
3335
local isaac_path=$(${python_exe} -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
34-
else
35-
# If package not installed, try with the default path
36-
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
37-
fi
38-
elif command -v python &> /dev/null; then
39-
# note: we need to deal with this case because of docker containers
40-
# Retrieve the path importing isaac sim and getting the environment path
41-
if [ $(python -m pip list | grep -c 'isaacsim-rl') ]; then
42-
local isaac_path=$(python -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
43-
else
44-
# If package not installed, use an empty path for failure
45-
local isaac_path=''
4636
fi
47-
else
48-
# Use the sym-link path to Isaac Sim directory
49-
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
5037
fi
5138
# check if there is a path available
5239
if [ ! -d "${isaac_path}" ]; then
@@ -65,21 +52,22 @@ extract_isaacsim_path() {
6552

6653
# extract the python from isaacsim
6754
extract_python_exe() {
68-
# check if using conda
69-
if ! [[ -z "${CONDA_PREFIX}" ]]; then
70-
# use conda python
71-
local python_exe=${CONDA_PREFIX}/bin/python
72-
elif command -v python &> /dev/null; then
73-
# note: we need to deal with this case because of docker containers
74-
if [ $(python -m pip list | grep -c 'isaacsim-rl') ]; then
75-
local python_exe=$(which python)
55+
# default to python in the kit
56+
local python_exe=${ISAACLAB_PATH}/_isaac_sim/python.sh
57+
# if default python is not available, check if conda is activated
58+
if [ ! -f "${python_exe}" ]; then
59+
# check if using conda
60+
if ! [[ -z "${CONDA_PREFIX}" ]]; then
61+
# use conda python
62+
local python_exe=${CONDA_PREFIX}/bin/python
7663
else
77-
# leave a blank path for failure
78-
local python_exe=''
64+
# note: we need to check system python for cases such as docker
65+
# inside docker, if user installed into system python, we need to use that
66+
# otherwise, use the python from the kit
67+
if [ $(python -m pip list | grep -c 'isaacsim-rl') ]; then
68+
local python_exe=$(which python)
69+
fi
7970
fi
80-
else
81-
# use python from kit
82-
local python_exe=${ISAACLAB_PATH}/_isaac_sim/python.sh
8371
fi
8472
# check if there is a python path available
8573
if [ ! -f "${python_exe}" ]; then
@@ -90,12 +78,6 @@ extract_python_exe() {
9078
echo -e "\t3. Python executable is not available at the default path: ${ISAACLAB_PATH}/_isaac_sim/python.sh" >&2
9179
exit 1
9280
fi
93-
# kit dependencies are built with python 3.10 so any other version will not work
94-
# this is needed in case users have multiple python versions installed and the wrong one is being used
95-
if [ "$(${python_exe} --version | grep -c '3.10')" -eq 0 ]; then
96-
echo "[ERROR] Found Python version: $(${python_exe} --version) while expecting 3.10. Please use the correct python version." >&2
97-
exit 1
98-
fi
9981
# return the result
10082
echo ${python_exe}
10183
}
@@ -300,8 +282,9 @@ while [[ $# -gt 0 ]]; do
300282
# install the rl-frameworks specified
301283
${python_exe} -m pip install -e ${ISAACLAB_PATH}/source/extensions/omni.isaac.lab_tasks["${framework_name}"]
302284

303-
# check if we are inside a docker container (in that case don't setup VSCode)
304-
if [ -f "/.dockerenv" ]; then
285+
# check if we are inside a docker container or are building a docker image
286+
# in that case don't setup VSCode since it asks for EULA agreement which triggers user interaction
287+
if [ -f /.dockerenv ]; then
305288
echo "[INFO] Running inside a docker container. Skipping VSCode settings setup."
306289
echo "[INFO] To setup VSCode settings, run 'isaaclab -v'."
307290
else

0 commit comments

Comments
 (0)