Skip to content

Commit e571091

Browse files
committed
add option to specifiy python when creating venv with uv
1 parent bd547aa commit e571091

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

isaaclab.sh

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ setup_uv_env() {
429429
local env_path="${ISAACLAB_PATH}/${env_name}"
430430
if [ ! -d "${env_path}" ]; then
431431
echo -e "[INFO] Creating uv environment named '${env_name}'..."
432-
uv venv --clear --python "${python_path}" "${env_path}"
432+
uv venv --clear ${python_path:+--python "$python_path"} "${env_path}"
433433
else
434434
echo "[INFO] uv environment '${env_name}' already exists."
435435
fi
@@ -496,7 +496,18 @@ print_help () {
496496
echo -e "\t-d, --docs Build the documentation from source using sphinx."
497497
echo -e "\t-n, --new Create a new external project or internal task from template."
498498
echo -e "\t-c, --conda [NAME] Create the conda environment for Isaac Lab. Default name is 'env_isaaclab'."
499-
echo -e "\t-u, --uv [NAME] Create the uv environment for Isaac Lab. Default name is 'env_isaaclab'."
499+
echo -e "\t-u, --uv [NAME] [--python PYTHON_PATH]"
500+
echo -e "\t Create the uv environment for Isaac Lab. Default name is 'env_isaaclab'."
501+
echo -e "\t Optionally specify a Python interpreter path to use for the environment."
502+
echo -e "\nExamples:"
503+
echo -e "\t 1. uv environment creation:"
504+
echo -e "\t\t1.a create env_isaaclab with system python3"
505+
echo -e "\t\t$(basename "$0") --uv"
506+
echo -e "\t\t1.b create myenv with system python3"
507+
echo -e "\t\t$(basename "$0") --uv myenv "
508+
echo -e "\t\t1.c create myenv with specified Python 3.11"
509+
echo -e "\t\t$(basename "$0") --uv myenv --python ${HOME}/isaacsim50/kit/python/bin/python3"
510+
echo -e "\t"
500511
echo -e "\n" >&2
501512
}
502513

@@ -590,18 +601,20 @@ while [[ $# -gt 0 ]]; do
590601
shift # past argument
591602
;;
592603
-u|--uv)
593-
# use default name if not provided
594-
if [ -z "$2" ]; then
595-
echo "[INFO] Using default uv environment name: env_isaaclab"
596-
uv_env_name="env_isaaclab"
597-
else
598-
echo "[INFO] Using uv environment name: $2"
599-
uv_env_name=$2
600-
shift # past argument
604+
uv_env_name="env_isaaclab"
605+
python_path=""
606+
# consume env name
607+
if [[ -n "$2" && "$2" != "--python" ]]; then
608+
uv_env_name="$2"
609+
shift
601610
fi
602-
# setup the uv environment for Isaac Lab
603-
setup_uv_env ${uv_env_name}
604-
shift # past argument
611+
# consume python path
612+
if [[ "$2" == "--python" && -n "$3" ]]; then
613+
python_path="$3"
614+
shift 2
615+
fi
616+
setup_uv_env "${uv_env_name}" "${python_path}"
617+
shift
605618
;;
606619
-f|--format)
607620
# reset the python path to avoid conflicts with pre-commit

0 commit comments

Comments
 (0)