Skip to content

[None][feat] Add --skip_requirements to build_wheel.py#16188

Open
lucifer1004 wants to merge 1 commit into
NVIDIA:mainfrom
lucifer1004:feat/skip-req
Open

[None][feat] Add --skip_requirements to build_wheel.py#16188
lucifer1004 wants to merge 1 commit into
NVIDIA:mainfrom
lucifer1004:feat/skip-req

Conversation

@lucifer1004

@lucifer1004 lucifer1004 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Currently, build_wheel.py unconditionally pip-installs requirements-dev.txt (and conan) into the build environment. When that environment is managed by an external tool (conda, pixi, uv) whose resolution deliberately differs from the requirement pins — for example a torch or NCCL version override — every build silently downgrades or replaces the managed packages, and the external manager restores them on its next sync, masking what happened.

With --skip_requirements the environment's installed packages are used as they are: the dev-requirements install and the conan install are both skipped, while conan is still located (venv scripts directory, then PATH) and its absence still fails loudly. Typically combined with --no-venv. Default behavior is unchanged.

Summary by CodeRabbit

  • New Features

    • Added a new option to skip installing development requirements during setup.
    • Environment setup can now also skip installing Conan when that option is enabled.
  • Bug Fixes

    • Improved flexibility for users who want a faster or more minimal build setup without extra package installations.

… managed environments

build_wheel.py unconditionally pip-installs requirements-dev.txt (and
conan) into the build environment. When that environment is managed by
an external tool (conda, pixi, uv) whose resolution deliberately
differs from the requirement pins — for example a torch or NCCL
version override — every build silently downgrades or replaces the
managed packages, and the external manager restores them on its next
sync, masking what happened.

With --skip_requirements the environment's installed packages are used
as they are: the dev-requirements install and the conan install are
both skipped, while conan is still located (venv scripts directory,
then PATH) and its absence still fails loudly. Typically combined with
--no-venv. Default behavior is unchanged.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a --skip_requirements CLI flag to scripts/build_wheel.py. When enabled, it skips pip install -r <requirements_file> and conan installation during virtual environment setup, relying on already-installed packages instead.

Changes

Skip Requirements Installation

Layer / File(s) Summary
Venv setup and conan skip logic
scripts/build_wheel.py
setup_venv and setup_conan gain a skip_requirements/skip_install parameter that conditionally skips pip install -r <requirements_file> and conan==2.14.0 installation.
Main function and CLI wiring
scripts/build_wheel.py
main adds a keyword-only skip_requirements parameter forwarded to setup_venv, and the argument parser registers --skip_requirements with help text.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#16015: Both PRs extend main() and setup_venv() parameter lists and CLI argument registration in scripts/build_wheel.py.

Suggested reviewers: tburt-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, but it omits the required template sections for Test Coverage and PR Checklist. Rewrite the PR description using the template headings and add a short test coverage section plus the checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and accurately describes the main change to build_wheel.py.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/build_wheel.py`:
- Around line 138-150: Add a guard in setup_venv so skip_requirements cannot be
used with a freshly created virtual environment: when skip_requirements is true,
verify no_venv is also true or that the current interpreter is already inside a
venv (sys.prefix != sys.base_prefix), and otherwise fail early with a clear
error. Update the setup_venv flow before create_venv and the later package
checks so the invalid combination is caught near the option handling instead of
letting tensorrt/build installation steps fail later.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 82dfc434-c9f2-4da4-b141-9a67447bac5a

📥 Commits

Reviewing files that changed from the base of the PR and between 046c787 and 7fc681b.

📒 Files selected for processing (1)
  • scripts/build_wheel.py

Comment thread scripts/build_wheel.py
Comment on lines 138 to +150
def setup_venv(project_dir: Path,
requirements_file: Path,
no_venv: bool,
yes: bool = False) -> tuple[Path, Path]:
yes: bool = False,
skip_requirements: bool = False) -> tuple[Path, Path]:
"""Creates/updates a venv and installs requirements.

Args:
project_dir: The root directory of the project.
requirements_file: Path to the requirements file.
no_venv: Use current Python environment as is.
skip_requirements: Do not pip-install requirements (or conan) into
the environment; use its installed packages as they are.

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Missing guard when skip_requirements is combined with a freshly-created venv.

setup_venv only skips pip-install of requirements/conan; it does not check whether no_venv is set. If a user passes --skip_requirements without --no-venv (and is not already inside a venv), create_venv() at Line 160 creates a brand-new, empty venv, and then no packages (torch, build, tensorrt, etc.) are ever installed into it. This is silently allowed even though the help text says it's "typically combined with --no-venv" — the resulting failure (e.g. the tensorrt check a few lines later, or python -m build) will be confusing and won't point back to this flag combination.

Consider raising a clear error/warning in setup_venv when skip_requirements is True but the environment is not the current interpreter (i.e., no_venv is False and sys.prefix == sys.base_prefix), since that combination guarantees a downstream failure.

🛡️ Proposed guard
     if no_venv or sys.prefix != sys.base_prefix:
         reason = "Explicitly requested by user" if no_venv else "Already inside virtual environment"
         print(f"-- {reason}, using environment {sys.prefix} as is.")
         venv_prefix = Path(sys.prefix)
     else:
+        if skip_requirements:
+            raise RuntimeError(
+                "--skip_requirements requires --no-venv (or running inside an "
+                "existing environment); a freshly created venv would have no "
+                "packages installed.")
         venv_prefix = create_venv(project_dir)

Also applies to: 215-228

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build_wheel.py` around lines 138 - 150, Add a guard in setup_venv so
skip_requirements cannot be used with a freshly created virtual environment:
when skip_requirements is true, verify no_venv is also true or that the current
interpreter is already inside a venv (sys.prefix != sys.base_prefix), and
otherwise fail early with a clear error. Update the setup_venv flow before
create_venv and the later package checks so the invalid combination is caught
near the option handling instead of letting tensorrt/build installation steps
fail later.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant