Skip to content

feat: add --install-args to forward arguments to cmake --install - #217

Open
wyli wants to merge 3 commits into
mainfrom
feat/install-prefix
Open

feat: add --install-args to forward arguments to cmake --install#217
wyli wants to merge 3 commits into
mainfrom
feat/install-prefix

Conversation

@wyli

@wyli wyli commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

holoscan install emits a bare cmake --install <build-dir> with no way to pass options to it. The only way to influence the install today is through the configure stage:

holoscan install <project> --configure-args="-DCMAKE_INSTALL_PREFIX=<dir>"

That bakes the destination into the build tree's CMake cache, so a configured tree can only ever install to one location and retargeting it forces a reconfigure. It also cannot reach the rest of cmake --install's options at all — --strip, --component, --default-directory-permissions.

Change

Add --install-args, mirroring the existing --configure-args: repeatable, forwarded verbatim to cmake --install.

$ holoscan install smoke_app --local --dryrun \
      --install-args='--prefix /opt/holohub' --install-args=--strip

cmake --install <root>/build/smoke_app \
  --prefix /opt/holohub \
  --strip

CMake resolves these at install time, so the build tree's cache is left untouched and one built tree can be installed repeatedly to different destinations without reconfiguring:

holoscan install my_app --local --install-args='--prefix /opt/my_app' --install-args='--component runtime'
holoscan install my_app --local --install-args='--prefix /usr/local'  --install-args='--component dev'

That second invocation is the case the configure-time approach cannot express.

Implementation notes

  • Modeled on --configure-args — same action="append" shape, same os.path.expandvars treatment, so the two stages behave alike.
  • One divergence: values are shlex.split. --configure-args appends each value as exactly one token, which suits -DFOO=ON but not cmake --install's separate-value options — --component dev is two tokens. shlex.split handles both, and is identical for single-token values (shlex.split('--strip') is ['--strip']). It differs only when a value contains quotes or shell metacharacters.
  • Container branch forwards them shlex.quoted into the recursive in-container holoscan install ... --local command, alongside the existing --configure-args forwarding. Round-trip verified: the branch emits --install-args='--component dev', a shell re-splits that to the single argv token --install-args=--component dev, and the in-container shlex.split restores ['--component', 'dev'].
  • No validation or filtering of forwarded arguments. As with --configure-args, values are passed through as given; cmake --install is the one that rejects bad input.

Notes for review

  • An earlier revision of this PR added a dedicated typed --prefix flag instead. That was replaced with the general forwarding mechanism per review feedback; no bespoke per-option flags remain.
  • Options settable both here and through a first-class flag follow CMake's own last-wins ordering, since --install-args values are appended in order. This matches the existing overlap between --build-type and --configure-args.
  • Without --local — or when a mode's env selects a local build — forwarded paths are resolved inside the container, so a destination must be a mounted path. Called out in the flag's help text.
  • --dev returns early and never reaches cmake --install, so --install-args is accepted but unused on that path.

Testing

Both existing install tests extended rather than new ones added: the local-path test pins the full emitted token list including ordering and asserts nothing leaks into the configure step; the container-path test asserts the quoted forwarding for a value containing a space.

Full unit suite: 420 passed, 1 skipped. ruff, black, isort and codespell clean on both changed files.

🤖 Generated with Claude Code

`holoscan install` emitted a bare `cmake --install <build-dir>`, so the only
way to pick a destination was `--configure-args="-DCMAKE_INSTALL_PREFIX=..."`.
That bakes the path into the build tree's CMake cache: a configured tree can
only ever install to one location, and changing it forces a reconfigure.

Add `--prefix`, forwarded to `cmake --install --prefix`. It is resolved at
install time and leaves the cache untouched, so one built tree can be
installed to several destinations. The flag is spelled to match CMake's own
option; internally it is `install_prefix` so it cannot be confused with the
unrelated `cli.prefix` metadata placeholder prefix used in the same module.

Both paths are covered: the local branch appends the option to the cmake
invocation, and the container branch forwards it (shell-quoted) into the
recursive in-container `holoscan install ... --local` command.

Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@wyli
wyli requested review from agirault and tbirdso August 4, 2026 09:32
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The install command accepts repeatable --install-args values. Local installs expand and split these values for cmake --install. Container installs forward shell-quoted values to the nested install command. Unit tests cover both modes.

Changes

Install argument handling

Layer / File(s) Summary
Install argument parsing and forwarding
src/holoscan_cli/commands/install.py
The install command registers repeatable --install-args values. Local installation expands and tokenizes the values. Container installation shell-quotes each value before forwarding it.
Local and container argument tests
tests/unit/test_lifecycle_commands.py
Tests verify argument tokenization, separation from build configuration arguments, and shell-safe forwarding of values containing spaces.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: agirault

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding repeatable --install-args support for forwarding arguments to cmake --install.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@src/holoscan_cli/commands/install.py`:
- Around line 105-113: Update the --prefix help text in the argument parser to
say the path is resolved inside the container when installation runs in a
container, replacing the misleading “Without --local” condition. Keep the
existing forwarding and install-time behavior descriptions unchanged.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76335b81-de2d-4396-b8d8-dd5ca4ba2b00

📥 Commits

Reviewing files that changed from the base of the PR and between ad09a9c and 5339f62.

📒 Files selected for processing (2)
  • src/holoscan_cli/commands/install.py
  • tests/unit/test_lifecycle_commands.py

Comment thread src/holoscan_cli/commands/install.py
Comment thread src/holoscan_cli/commands/install.py Outdated
Comment on lines +105 to +107
parser.add_argument(
"--prefix",
dest="install_prefix",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rather than overfitting to --prefix, could we expose a more general args forwarding approach as done for configuration args?

See other valid args: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project . --component in particular might be useful for installing build subsets into particular paths.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

thanks, adding support of --install-args='--prefix /opt/holohub' --install-args=--strip.

Do we need --prefix=/opt/holohub as a shortcut of --install-args='--prefix /opt/holohub'? worth adding if it's a frequently used parameter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My guess would be that it is not common enough to want it explicitly surfaced in the CLI, but @agirault might be best to confirm

wyli and others added 2 commits August 4, 2026 14:02
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
@wyli wyli changed the title feat: add --prefix to install for install-time destination selection feat: add --install-args to forward arguments to cmake --install Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/unit/test_lifecycle_commands.py (2)

146-146: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add parser-level coverage for repeatable --install-args.

_project_args injects install_args directly into Namespace, so these handler tests pass even if the real parser does not register the option. Parse two --install-args values through the install parser and assert that both values are retained.

🤖 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 `@tests/unit/test_lifecycle_commands.py` at line 146, Add parser-level coverage
in the install parser tests for repeatable --install-args: parse two occurrences
through the real parser and assert both values are retained in the resulting
Namespace. Do not rely on _project_args injecting install_args directly;
exercise the parser registration and append behavior instead.

508-534: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Strengthen the local forwarding test.

The test uses literal paths and leaves configure_args as None. It does not verify os.path.expandvars or prove that existing configuration arguments remain unchanged. Use a quoted environment variable containing spaces, pass a non-empty configure_args list, and assert both results.

🤖 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 `@tests/unit/test_lifecycle_commands.py` around lines 508 - 534, The test
test_handle_install_local_forwards_install_args_at_install_time should use a
quoted install argument containing an environment variable whose expanded value
includes spaces, and pass a non-empty configure_args list through _project_args.
Set the environment variable with monkeypatch, then assert calls contains the
correctly expanded cmake install tokens and build_kwargs["configure_args"]
exactly preserves the original configuration arguments.
🤖 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.

Nitpick comments:
In `@tests/unit/test_lifecycle_commands.py`:
- Line 146: Add parser-level coverage in the install parser tests for repeatable
--install-args: parse two occurrences through the real parser and assert both
values are retained in the resulting Namespace. Do not rely on _project_args
injecting install_args directly; exercise the parser registration and append
behavior instead.
- Around line 508-534: The test
test_handle_install_local_forwards_install_args_at_install_time should use a
quoted install argument containing an environment variable whose expanded value
includes spaces, and pass a non-empty configure_args list through _project_args.
Set the environment variable with monkeypatch, then assert calls contains the
correctly expanded cmake install tokens and build_kwargs["configure_args"]
exactly preserves the original configuration arguments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b5e8f8c-d6d9-40dd-b11d-485fbfc8e3b1

📥 Commits

Reviewing files that changed from the base of the PR and between 1c37f9b and 8b5d42e.

📒 Files selected for processing (2)
  • src/holoscan_cli/commands/install.py
  • tests/unit/test_lifecycle_commands.py

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.

2 participants