Skip to content

Add support for python-env.sh for dev workflows#6434

Merged
pbarejko merged 1 commit into
isaac-sim:developfrom
pbarejko:pbarejko/add-support-for-python-env-sh
Jul 9, 2026
Merged

Add support for python-env.sh for dev workflows#6434
pbarejko merged 1 commit into
isaac-sim:developfrom
pbarejko:pbarejko/add-support-for-python-env-sh

Conversation

@pbarejko

@pbarejko pbarejko commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Description

Local Isaac Sim builds (6.1+) ship setup_python_env.sh instead of setup_conda_env.sh. Isaac Lab only sourced the latter, breaking the developer workflow when _isaac_sim points at a source build. This PR falls back to setup_python_env.sh, sets the required Kit env vars, and prepends the active environment's site-packages to avoid Kit prebundle shadowing.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks 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
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@pbarejko
pbarejko requested a review from huidongc July 9, 2026 01:49
@pbarejko pbarejko self-assigned this Jul 9, 2026
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends isaaclab.sh to fall back to setup_python_env.sh when setup_conda_env.sh is absent, enabling the developer workflow with local Isaac Sim 6.1+ source builds. It also exports the required Kit environment variables (ISAAC_PATH, CARB_APP_PATH, EXP_PATH) and, for activated venv/conda environments, prepends the environment's site-packages to PYTHONPATH to prevent Kit's prebundle directories from shadowing user-installed packages.

  • Env-script fallback: When _isaac_sim/setup_conda_env.sh is missing, the script now sources setup_python_env.sh and manually exports the three Kit vars that setup_conda_env.sh would have set automatically.
  • PYTHONPATH ordering fix: After sourcing, the active environment's site-packages path (obtained via site.getsitepackages()[0]) is prepended so that user packages win over Kit's vendored copies; this fix applies only when VIRTUAL_ENV or CONDA_PREFIX is set, leaving the auto-discovered env_isaaclab venv uncovered.
  • Updated warning message: The warning text now names both missing scripts for clarity.

Confidence Score: 4/5

Safe to merge for the primary dev workflow (activated venv/conda + local Isaac Sim source build); the env_isaaclab auto-discovered venv won't get the PYTHONPATH fix but is a secondary use case.

The new sourcing path and env-var exports are straightforward and consistent with the existing setup_conda_env.sh pattern. The site-packages prepend logic is correctly guarded and degrades silently on older Python. The one gap is that the env_isaaclab auto-discovered venv is excluded from the PYTHONPATH fix even though python_exe resolves to it in that scenario, leaving Kit prebundle shadowing possible for users relying on that path.

Only isaaclab.sh changed; the env_isaaclab handling on lines 52-56 warrants a second look.

Important Files Changed

Filename Overview
isaaclab.sh Adds fallback to setup_python_env.sh for local Isaac Sim 6.1+ source builds, exports required Kit env vars, and prepends the active venv/conda site-packages to PYTHONPATH; the auto-discovered env_isaaclab venv case is not covered by the site-packages fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[isaaclab.sh starts] --> B[Resolve python_exe\nVIRTUAL_ENV / CONDA_PREFIX /\nenv_isaaclab / python.sh / python3]
    B --> C[Prepend source/isaaclab to PYTHONPATH]
    C --> D{_isaac_sim dir present?}
    D -- No --> Z[exec python_exe]
    D -- Yes --> E{setup_conda_env.sh\nexists?}
    E -- Yes --> F[Source setup_conda_env.sh]
    F --> Z
    E -- No --> G{setup_python_env.sh\nexists?}
    G -- No --> H[Print WARNING]
    H --> Z
    G -- Yes --> I[Export ISAAC_PATH\nCARB_APP_PATH\nEXP_PATH]
    I --> J[Source setup_python_env.sh\nKit prebundle dirs prepended to PYTHONPATH]
    J --> K{VIRTUAL_ENV or\nCONDA_PREFIX set?}
    K -- No --> Z
    K -- Yes --> L[Get env site-packages\nvia python_exe]
    L --> M{site-packages\npath found?}
    M -- No --> Z
    M -- Yes --> N[Prepend env site-packages\nto PYTHONPATH\nenv pkgs win over Kit bundle]
    N --> Z[exec python_exe]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[isaaclab.sh starts] --> B[Resolve python_exe\nVIRTUAL_ENV / CONDA_PREFIX /\nenv_isaaclab / python.sh / python3]
    B --> C[Prepend source/isaaclab to PYTHONPATH]
    C --> D{_isaac_sim dir present?}
    D -- No --> Z[exec python_exe]
    D -- Yes --> E{setup_conda_env.sh\nexists?}
    E -- Yes --> F[Source setup_conda_env.sh]
    F --> Z
    E -- No --> G{setup_python_env.sh\nexists?}
    G -- No --> H[Print WARNING]
    H --> Z
    G -- Yes --> I[Export ISAAC_PATH\nCARB_APP_PATH\nEXP_PATH]
    I --> J[Source setup_python_env.sh\nKit prebundle dirs prepended to PYTHONPATH]
    J --> K{VIRTUAL_ENV or\nCONDA_PREFIX set?}
    K -- No --> Z
    K -- Yes --> L[Get env site-packages\nvia python_exe]
    L --> M{site-packages\npath found?}
    M -- No --> Z
    M -- Yes --> N[Prepend env site-packages\nto PYTHONPATH\nenv pkgs win over Kit bundle]
    N --> Z[exec python_exe]
Loading

Reviews (1): Last reviewed commit: "Add support for python-env.sh for dev wo..." | Re-trigger Greptile

Comment thread isaaclab.sh
Comment on lines +52 to +56
if [ -n "$VIRTUAL_ENV" ] || [ -n "$CONDA_PREFIX" ]; then
env_site_packages="$("$python_exe" -c 'import site; print(site.getsitepackages()[0])' 2>/dev/null || true)"
if [ -n "$env_site_packages" ]; then
export PYTHONPATH="$env_site_packages:$PYTHONPATH"
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 env_isaaclab venv not covered by site-packages fix

The guard [ -n "$VIRTUAL_ENV" ] || [ -n "$CONDA_PREFIX" ] excludes the third resolution path for python_exe (line 19): the auto-discovered env_isaaclab venv. When a user has env_isaaclab present but no explicitly activated venv/conda, python_exe already points at env_isaaclab/bin/python, yet the site-packages prepend is never performed. After setup_python_env.sh injects Kit's prebundle directories into PYTHONPATH, those vendored copies will still shadow env_isaaclab's packages — the exact problem this block is meant to prevent.

@pbarejko
pbarejko merged commit e2292cc into isaac-sim:develop Jul 9, 2026
62 checks passed
maxkra15 pushed a commit to maxkra15/IsaacLab that referenced this pull request Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants