Skip to content

Support uv in ExecuTorch installation scripts - #24419

Open
mshr-h wants to merge 1 commit into
pytorch:mainfrom
mshr-h:fix-uv-install-support
Open

mshr-h wants to merge 1 commit into
pytorch:mainfrom
mshr-h:fix-uv-install-support

Conversation

@mshr-h

@mshr-h mshr-h commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #15907, #24417

Fresh uv virtual environments do not include pip, causing installation to fail while bootstrapping packaging.

Prefer pip when available; otherwise use uv targeting the running Python environment. Keep the installer choice fixed throughout installation and document uv setup.

Test plan

Verify that source installation completes successfully in all three configurations below. Use a fresh .venv for each case.

1. uv available, pip initially unavailable

uv venv --python 3.12
source .venv/bin/activate
./install_executorch.sh --editable --verbose
python3 -I -c 'from executorch.extension.pybindings import portable_lib; print("Pass")'

2. Both uv and pip available

uv venv --python 3.12
source .venv/bin/activate
uv pip install pip
./install_executorch.sh --editable --verbose
python3 -I -c 'from executorch.extension.pybindings import portable_lib; print("Pass")'

3. pip available, uv unavailable

python3.12 -m venv .venv
source .venv/bin/activate
pip3 install pip
./install_executorch.sh --editable --verbose
python3 -I -c 'from executorch.extension.pybindings import portable_lib; print("Pass")'

Result: All three configurations passed.

cc @nil-is-all

@mshr-h
mshr-h requested a review from mergennachin as a code owner November 2, 2026 10:12
Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:12
@pytorch-bot

pytorch-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24419

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 28 Awaiting Approval, 1 Unrelated Failure

As of commit 747c22d with merge base f2564fb (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Fresh uv virtual environments do not include pip. Use pip when available,
or fall back to uv pip targeting the running Python interpreter. Cache the
choice so installing pip as a build dependency does not change installers
midway through the process.

Use the shared command for dependency bootstrap and package installation,
preserve pip's index selection behavior, and remove the redundant pip-only
upgrade strategy option. Document how to set up a uv environment.
@mshr-h
mshr-h force-pushed the fix-uv-install-support branch from e67faf5 to 747c22d Compare November 2, 2026 10:15

Copilot AI left a comment

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.

🟡 Changes recommended

Installer selection and caching lack automated test coverage, leaving fallback behavior and sticky installer selection unprotected against regressions.

1 open issue
What changed in this PR

This PR enables source installation in fresh uv environments without pip, addressing the installation failures described in #15907 and #24417.

Changes:

  • Adds cached installer selection that prefers pip and otherwise uses uv targeting the running Python.
  • Routes dependency bootstrapping and package installation through the shared helper.
  • Documents uv environment setup.
File Description
install_utils.py Adds installer selection and uses it to bootstrap packaging.
install_requirements.py Uses the shared installer for dependencies and removes a pip-specific option.
install_executorch.py Uses the shared installer for ExecuTorch installation.
docs/​source/​using-executorch-building-from-source.md Documents uv setup and installer fallback behavior.

Review effort: Balanced

Comment thread install_utils.py
Comment on lines +29 to +32
@functools.lru_cache(maxsize=1)
def get_package_install_command() -> Tuple[str, ...]:
"""Choose an installer once, even if requirements later install pip."""
if importlib.util.find_spec("pip") is not None:
Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:20

Copilot AI left a comment

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.

🔵 Needs a closer look

Installer selection and caching lack automated regression tests covering pip preference, uv fallback targeting the running interpreter, neither installer being available, and retention of the cached uv choice.

1 open issue

Review effort: Balanced

@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Nov 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. community: contribution PRs coming from community (excluding hardware partners)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants