Unverified Commit 26a81a6a authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes isaaclab.sh script to deal with local system python (#649)

# Description

Realized that #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
parent 97cf1f18
...@@ -27,6 +27,11 @@ try: ...@@ -27,6 +27,11 @@ try:
isaacsim_dir = os.environ.get("ISAAC_PATH", "") isaacsim_dir = os.environ.get("ISAAC_PATH", "")
except ModuleNotFoundError or ImportError: except ModuleNotFoundError or ImportError:
isaacsim_dir = os.path.join(ISAACLAB_DIR, "_isaac_sim") isaacsim_dir = os.path.join(ISAACLAB_DIR, "_isaac_sim")
except EOFError:
print("Unable to trigger EULA acceptance. This is likely due to the script being run in a non-interactive shell.")
print("Please run the script in an interactive shell to accept the EULA.")
print("Skipping the setup of the VSCode settings...")
sys.exit(0)
# check if the isaac-sim directory exists # check if the isaac-sim directory exists
if not os.path.exists(isaacsim_dir): if not os.path.exists(isaacsim_dir):
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
# To build the Docker image and run the Docker container, follow the steps below: # To build the Docker image and run the Docker container, follow the steps below:
# #
# 1. Build the Docker image: # 1. Build the Docker image:
# docker build -t isaac-lab:latest -f docker/Dockerfile.pip . # docker build -t isaac-lab-pip:latest -f docker/Dockerfile.pip .
# 2. Run the Docker container: # 2. Run the Docker container:
# docker run -it --gpus all --rm --network=host --name isaac-lab -v $(pwd):/root/isaaclab isaac-lab:latest # docker run -it --gpus all --rm --network=host --name isaac-lab -v $(pwd):/root/isaaclab isaac-lab-pip:latest
# Base image: Ubuntu 22.04 # Base image: Ubuntu 22.04
FROM ubuntu:22.04 AS base FROM ubuntu:22.04 AS base
......
...@@ -24,29 +24,16 @@ export ISAACLAB_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && p ...@@ -24,29 +24,16 @@ export ISAACLAB_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && p
# extract isaac sim path # extract isaac sim path
extract_isaacsim_path() { extract_isaacsim_path() {
# Check if we have pip package installed inside conda environment # Use the sym-link path to Isaac Sim directory
if ! [[ -z "${CONDA_PREFIX}" ]]; then local isaac_path=${ISAACLAB_PATH}/_isaac_sim
# If above path is not available, try to find the path using python
if [ ! -d "${isaac_path}" ]; then
# Use the python executable to get the path # Use the python executable to get the path
local python_exe=${CONDA_PREFIX}/bin/python local python_exe=$(extract_python_exe)
# Retrieve the path importing isaac sim and getting the environment path # 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') ]; then
local isaac_path=$(${python_exe} -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])") local isaac_path=$(${python_exe} -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
else
# If package not installed, try with the default path
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
fi
elif command -v python &> /dev/null; then
# note: we need to deal with this case because of docker containers
# Retrieve the path importing isaac sim and getting the environment path
if [ $(python -m pip list | grep -c 'isaacsim-rl') ]; then
local isaac_path=$(python -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])")
else
# If package not installed, use an empty path for failure
local isaac_path=''
fi fi
else
# Use the sym-link path to Isaac Sim directory
local isaac_path=${ISAACLAB_PATH}/_isaac_sim
fi fi
# check if there is a path available # check if there is a path available
if [ ! -d "${isaac_path}" ]; then if [ ! -d "${isaac_path}" ]; then
...@@ -65,21 +52,22 @@ extract_isaacsim_path() { ...@@ -65,21 +52,22 @@ extract_isaacsim_path() {
# extract the python from isaacsim # extract the python from isaacsim
extract_python_exe() { extract_python_exe() {
# check if using conda # default to python in the kit
if ! [[ -z "${CONDA_PREFIX}" ]]; then local python_exe=${ISAACLAB_PATH}/_isaac_sim/python.sh
# use conda python # if default python is not available, check if conda is activated
local python_exe=${CONDA_PREFIX}/bin/python if [ ! -f "${python_exe}" ]; then
elif command -v python &> /dev/null; then # check if using conda
# note: we need to deal with this case because of docker containers if ! [[ -z "${CONDA_PREFIX}" ]]; then
if [ $(python -m pip list | grep -c 'isaacsim-rl') ]; then # use conda python
local python_exe=$(which python) local python_exe=${CONDA_PREFIX}/bin/python
else else
# leave a blank path for failure # note: we need to check system python for cases such as docker
local python_exe='' # 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)
fi
fi fi
else
# use python from kit
local python_exe=${ISAACLAB_PATH}/_isaac_sim/python.sh
fi fi
# check if there is a python path available # check if there is a python path available
if [ ! -f "${python_exe}" ]; then if [ ! -f "${python_exe}" ]; then
...@@ -90,12 +78,6 @@ extract_python_exe() { ...@@ -90,12 +78,6 @@ extract_python_exe() {
echo -e "\t3. Python executable is not available at the default path: ${ISAACLAB_PATH}/_isaac_sim/python.sh" >&2 echo -e "\t3. Python executable is not available at the default path: ${ISAACLAB_PATH}/_isaac_sim/python.sh" >&2
exit 1 exit 1
fi fi
# kit dependencies are built with python 3.10 so any other version will not work
# this is needed in case users have multiple python versions installed and the wrong one is being used
if [ "$(${python_exe} --version | grep -c '3.10')" -eq 0 ]; then
echo "[ERROR] Found Python version: $(${python_exe} --version) while expecting 3.10. Please use the correct python version." >&2
exit 1
fi
# return the result # return the result
echo ${python_exe} echo ${python_exe}
} }
...@@ -300,8 +282,9 @@ while [[ $# -gt 0 ]]; do ...@@ -300,8 +282,9 @@ while [[ $# -gt 0 ]]; do
# install the rl-frameworks specified # install the rl-frameworks specified
${python_exe} -m pip install -e ${ISAACLAB_PATH}/source/extensions/omni.isaac.lab_tasks["${framework_name}"] ${python_exe} -m pip install -e ${ISAACLAB_PATH}/source/extensions/omni.isaac.lab_tasks["${framework_name}"]
# check if we are inside a docker container (in that case don't setup VSCode) # check if we are inside a docker container or are building a docker image
if [ -f "/.dockerenv" ]; then # in that case don't setup VSCode since it asks for EULA agreement which triggers user interaction
if [ -f /.dockerenv ]; then
echo "[INFO] Running inside a docker container. Skipping VSCode settings setup." echo "[INFO] Running inside a docker container. Skipping VSCode settings setup."
echo "[INFO] To setup VSCode settings, run 'isaaclab -v'." echo "[INFO] To setup VSCode settings, run 'isaaclab -v'."
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment