Unverified Commit b4c90504 authored by Kelly Guo's avatar Kelly Guo Committed by GitHub

Fixes venv and conda pip installation on windows (#970)

# Description

The current windows installation does not support pip installation of
isaac sim in venv as it only checks whether a conda environment is
enabled or assumes that a symlink to isaac sim is used. This change adds
support to check for system python when isaac sim is installed via pip.
In addition, isaac sim variables at conda environment startup should
only be assigned if isaac sim is installed from binary. This change
addresses the need for when pip installation of isaac sim is used in
conda.


## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- 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`
- [x] I have made corresponding changes to the documentation
- [x] 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
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent a7dbc84e
...@@ -14,26 +14,19 @@ rem Helper functions ...@@ -14,26 +14,19 @@ rem Helper functions
rem extract Isaac Sim directory rem extract Isaac Sim directory
:extract_isaacsim_path :extract_isaacsim_path
rem check if conda environment is activated and isaacsim package is installed rem Use the sym-link path to Isaac Sim directory
if not "%CONDA_PREFIX%"=="" ( set isaac_path=%ISAACLAB_PATH%\_isaac_sim
rem use conda python rem Check if directory exists
set python_exe=%CONDA_PREFIX%\python if not exist "%isaac_path%" (
call !python_exe! -m pip show isaacsim-rl > nul 2>&1 rem Find the Python executable
if errorlevel 1 ( call :extract_python_exe
rem Use the sym-link path to Isaac Sim directory rem retrieve the isaacsim path from the installed package
set isaac_path=%ISAACLAB_PATH%\_isaac_sim set "isaac_path="
) else ( for /f "delims=" %%i in ('!python_exe! -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])"') do (
rem retrieve the isaacsim path from the installed package if not defined isaac_path (
set "isaac_path=" set "isaac_path=%%i"
for /f "delims=" %%i in ('!python_exe! -c "import isaacsim; import os; print(os.environ['ISAAC_PATH'])"') do (
if not defined isaac_path (
set "isaac_path=%%i"
)
) )
) )
) else (
rem Use the sym-link path to Isaac Sim directory
set isaac_path=%ISAACLAB_PATH%\_isaac_sim
) )
rem Check if the directory exists rem Check if the directory exists
if not exist "%isaac_path%" ( if not exist "%isaac_path%" (
...@@ -50,16 +43,25 @@ rem extract the python from isaacsim ...@@ -50,16 +43,25 @@ rem extract the python from isaacsim
rem check if using conda rem check if using conda
if not "%CONDA_PREFIX%"=="" ( if not "%CONDA_PREFIX%"=="" (
rem use conda python rem use conda python
set python_exe=%CONDA_PREFIX%\python set python_exe=%CONDA_PREFIX%\python.exe
) else ( ) else (
rem obtain isaacsim path rem use kit python
call :extract_isaacsim_path set python_exe=%ISAACLAB_PATH%\_isaac_sim\python.bat
rem use python from kit if Isaac Sim not installed from pip
set python_exe=!isaac_path!\python.bat
) )
rem check if there is a python path available rem check for if isaac sim was installed to system python
if "%python_exe%"=="" ( if not exist "%python_exe%" (
echo [ERROR] Unable to find any Python executable at path: %isaac_path% set "python_exe="
python -m pip show isaacsim-rl > nul 2>&1
if %ERRORLEVEL% equ 0 (
for /f "delims=" %%i in ('where python') do (
if not defined python_exe (
set "python_exe=%%i"
)
)
)
)
if not exist "%python_exe%" (
echo [ERROR] Unable to find any Python executable at path: %python_exe%
echo %tab%This could be due to the following reasons: echo %tab%This could be due to the following reasons:
echo %tab%1. Conda environment is not activated. echo %tab%1. Conda environment is not activated.
echo %tab%2. Python executable is not available at the default path: %ISAACLAB_PATH%\_isaac_sim\python.bat echo %tab%2. Python executable is not available at the default path: %ISAACLAB_PATH%\_isaac_sim\python.bat
...@@ -83,7 +85,7 @@ if errorlevel 1 ( ...@@ -83,7 +85,7 @@ if errorlevel 1 (
) )
rem check if there is a python path available rem check if there is a python path available
if not exist "%isaacsim_exe%" ( if not exist "%isaacsim_exe%" (
echo [ERROR] No isaac-sim executable found at path: !isaac_path! echo [ERROR] No isaac-sim executable found at path: %isaacsim_exe%
exit /b 1 exit /b 1
) )
goto :eof goto :eof
...@@ -135,27 +137,42 @@ mkdir "%CONDA_PREFIX%\etc\conda\deactivate.d" 2>nul ...@@ -135,27 +137,42 @@ mkdir "%CONDA_PREFIX%\etc\conda\deactivate.d" 2>nul
rem obtain isaacsim path rem obtain isaacsim path
call :extract_isaacsim_path call :extract_isaacsim_path
if exist "%isaac_path%" (
rem add variables to environment during activation rem add variables to environment during activation
( (
echo @echo off echo @echo off
echo rem for isaac-sim echo rem for isaac-sim
echo set "RESOURCE_NAME=IsaacSim" echo set "RESOURCE_NAME=IsaacSim"
echo set CARB_APP_PATH=!isaac_path!\kit echo set CARB_APP_PATH=!isaac_path!\kit
echo set EXP_PATH=!isaac_path!\apps echo set EXP_PATH=!isaac_path!\apps
echo set ISAAC_PATH=!isaac_path! echo set ISAAC_PATH=!isaac_path!
echo set PYTHONPATH=%PYTHONPATH%;!isaac_path!\site echo set PYTHONPATH=%PYTHONPATH%;!isaac_path!\site
echo. echo.
echo rem for isaac-lab echo rem for isaac-lab
echo doskey isaaclab=isaaclab.bat $* echo doskey isaaclab=isaaclab.bat $*
) > "%CONDA_PREFIX%\etc\conda\activate.d\env_vars.bat" ) > "%CONDA_PREFIX%\etc\conda\activate.d\env_vars.bat"
( (
echo $env:CARB_APP_PATH="!isaac_path!\kit" echo $env:CARB_APP_PATH="!isaac_path!\kit"
echo $env:EXP_PATH="!isaac_path!\apps" echo $env:EXP_PATH="!isaac_path!\apps"
echo $env:ISAAC_PATH="!isaac_path!" echo $env:ISAAC_PATH="!isaac_path!"
echo $env:PYTHONPATH="%PYTHONPATH%;!isaac_path!\site" echo $env:PYTHONPATH="%PYTHONPATH%;!isaac_path!\site"
echo $env:RESOURCE_NAME="IsaacSim" echo $env:RESOURCE_NAME="IsaacSim"
) > "%CONDA_PREFIX%\etc\conda\activate.d\env_vars.ps1" ) > "%CONDA_PREFIX%\etc\conda\activate.d\env_vars.ps1"
) else (
rem assume isaac sim will be installed from pip
rem add variables to environment during activation
(
echo @echo off
echo rem for isaac-sim
echo set "RESOURCE_NAME=IsaacSim"
echo.
echo rem for isaac-lab
echo doskey isaaclab=isaaclab.bat $*
) > "%CONDA_PREFIX%\etc\conda\activate.d\env_vars.bat"
(
echo $env:RESOURCE_NAME="IsaacSim"
) > "%CONDA_PREFIX%\etc\conda\activate.d\env_vars.ps1"
)
rem reactivate the environment to load the variables rem reactivate the environment to load the variables
call conda activate %env_name% call conda activate %env_name%
......
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