Skip to content

Adds prebundle package repointing during installation#4958

Merged
kellyguo11 merged 3 commits intoisaac-sim:developfrom
ooctipus:fix/repoint_prebundle_packages
Mar 12, 2026
Merged

Adds prebundle package repointing during installation#4958
kellyguo11 merged 3 commits intoisaac-sim:developfrom
ooctipus:fix/repoint_prebundle_packages

Conversation

@ooctipus
Copy link
Copy Markdown
Collaborator

@ooctipus ooctipus commented Mar 12, 2026

Description

Isaac Sim ships prebundled copies of packages (torch, warp, newton, etc.) inside pip_prebundle directories. Whether Isaac Sim is installed via pip or via a local symlink (_isaac_sim), these prebundled copies can shadow the versions installed in the active conda/uv environment (e.g. torch+cu128 overriding the torch+cu130 the user installed on aarch64), causing version mismatches or native crashes during Kit startup.
This PR adds _repoint_prebundle_packages() which runs at the end of command_install and replaces prebundled package directories with symlinks pointing to the active environment's site-packages. Original copies are preserved as .bak for recovery. The operation is idempotent.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

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

@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Mar 12, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 12, 2026

Greptile Summary

This PR adds _repoint_prebundle_packages(), called at the end of command_install, which walks every pip_prebundle directory under the Isaac Sim installation and replaces listed package directories (torch, warp, newton, etc.) with absolute symlinks pointing to the active environment's site-packages. This prevents shadowing when setup_conda_env.sh prepends prebundle paths to PYTHONPATH — a particularly acute problem on aarch64 where the CUDA suffixes differ. The approach is idempotent, preserves originals as .bak, and degrades gracefully when Isaac Sim is not present.

Key issues found during review:

  • Broken symlink at backup path: backup.exists() returns False for a broken symlink, so the cleanup branch is skipped and the subsequent prebundled.rename(backup) will raise NotADirectoryError on POSIX if a dangling symlink already occupies the backup slot.
  • Missing Windows guard: Path.symlink_to() requires elevated privileges on Windows; the function has no is_windows() early-return, unlike the rest of the install code.
  • Unguarded filesystem operations: shutil.rmtree, unlink, rename, and symlink_to inside the loop have no try/except, so a transient permission error or unexpected file type would propagate as a hard crash rather than a logged warning.

Confidence Score: 3/5

  • Safe to merge on Linux/macOS for the common case, but three edge-case logic bugs could crash the installer in specific environments (Windows, broken-symlink backup, permission errors).
  • The happy-path logic is correct and the early-exit guards prevent regressions when Isaac Sim is absent. However, a broken symlink at the backup path can raise NotADirectoryError on POSIX, missing Windows symlink privilege handling can raise PermissionError, and unguarded filesystem calls let any unexpected OS error bubble up as a hard install failure rather than a graceful warning — all three of which are fixable before merging.
  • source/isaaclab/isaaclab/cli/commands/install.py — specifically the _repoint_prebundle_packages() function's backup handling, Windows guard, and exception handling.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/cli/commands/install.py Adds _repoint_prebundle_packages() to replace Isaac Sim prebundled packages with symlinks to the active environment's site-packages; contains a broken-symlink edge case in the backup cleanup, missing Windows guard for symlink creation, and no exception handling around filesystem ops.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[command_install] --> B[_repoint_prebundle_packages]
    B --> C{Isaac Sim path\nfound?}
    C -- No --> D[return early]
    C -- Yes --> E[Run: site.getsitepackages to get\nsite-packages path]
    E --> F{site-packages\ndir exists?}
    F -- No --> G[print_warning + return]
    F -- Yes --> H[rglob pip_prebundle dirs]
    H --> I{Any\npip_prebundle\ndirs?}
    I -- No --> J[return early]
    I -- Yes --> K[For each prebundle_dir × pkg_name]
    K --> L{venv_pkg\nexists?}
    L -- No --> K
    L -- Yes --> M{prebundled\nexists or is_symlink?}
    M -- No --> K
    M -- Yes --> N{prebundled\nis_symlink?}
    N -- Yes --> O{Already points\nto correct target?}
    O -- Yes --> K
    O -- No --> P[unlink symlink]
    P --> Q[symlink_to venv_pkg]
    N -- No --> R[Create .bak backup\ncheck backup.exists\nnot is_symlink ⚠️]
    R --> S[rename prebundled → .bak]
    S --> Q
    Q --> K
    K --> T{repointed > 0?}
    T -- Yes --> U[print_info count]
    T -- No --> V[print_debug up-to-date]
Loading

Last reviewed commit: 267adbf

Comment thread source/isaaclab/isaaclab/cli/commands/install.py Outdated
Comment thread source/isaaclab/isaaclab/cli/commands/install.py
Comment thread source/isaaclab/isaaclab/cli/commands/install.py
@kellyguo11 kellyguo11 changed the title Add prebundle package repointing during installation Adds prebundle package repointing during installation Mar 12, 2026
@kellyguo11 kellyguo11 merged commit 7a7c89c into isaac-sim:develop Mar 12, 2026
10 of 14 checks passed
@ooctipus ooctipus deleted the fix/repoint_prebundle_packages branch March 12, 2026 02:39
daniela-hase pushed a commit to daniela-hase/IsaacLab that referenced this pull request Mar 30, 2026
# Description
Isaac Sim ships prebundled copies of packages (torch, warp, newton,
etc.) inside `pip_prebundle` directories. Whether Isaac Sim is installed
via pip or via a local symlink (`_isaac_sim`), these prebundled copies
can shadow the versions installed in the active conda/uv environment
(e.g. `torch+cu128` overriding the `torch+cu130` the user installed on
aarch64), causing version mismatches or native crashes during Kit
startup.
This PR adds `_repoint_prebundle_packages()` which runs at the end of
`command_install` and replaces prebundled package directories with
symlinks pointing to the active environment's `site-packages`. Original
copies are preserved as `.bak` for recovery. The operation is
idempotent.
## Type of change
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
## Checklist
- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] 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
- [x] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants