Skip to content

Support tarball-mode packages in patch application#1011

Merged
rapids-bot[bot] merged 3 commits intorapidsai:mainfrom
bdice:cpm-patch-tarball-support
May 5, 2026
Merged

Support tarball-mode packages in patch application#1011
rapids-bot[bot] merged 3 commits intorapidsai:mainfrom
bdice:cpm-patch-tarball-support

Conversation

@bdice
Copy link
Copy Markdown
Contributor

@bdice bdice commented Apr 27, 2026

Description

Add a new patch application path that uses patch -p1, so CPM packages fetched as tarballs can have patches applied to them. Tarball-extracted directories have no .git repository and so cannot use git apply or git am. The existing git-mode path is retained unchanged for packages fetched as git clones. The fetch mode is detected from versions.json (git_url/git_tag vs url/url_hash) and the patch script dispatches accordingly.

Also includes a few adjacent fixes uncovered while adding the above:

  • Fix pinning_write_file.cmake to respect mode switching when an override provides git fields for a package whose default is URL-mode. Previously the fallback to default JSON could incorrectly detect URL-mode even when the override explicitly switched to git-mode.
  • Update verify_generated_pins to handle URL-mode packages in pin verification, checking url/url_hash fields instead of git_tag/git_shallow.
  • Update cpm_package_override-multiple tests to provide git_url alongside git_tag in overrides so that partial git overrides remain valid regardless of whether the default entry is git- or url-mode.

Test coverage

Splits the existing patch-command tests into explicit -git and -tarball variants for each scenario (regular, embedded, required, required-fails) and adds -diff-git/-diff-tarball pairs so both .patch and .diff files are exercised in both modes. Each test specifies its fetch mode explicitly in override.json (git_url/git_tag for -git tests, url/url_hash for -tarball tests) rather than relying on the default, so the tests remain correct regardless of how versions.json evolves. The override is applied before rapids_cpm_package_details_internal so the explicitly declared mode is used for the test's pre-populate step.

Coverage matrix:

git mode tarball mode
.diff new new
.patch existing new
inline patch existing new
required existing new
required-fails existing new

This PR is a prerequisite for #1005 (converting versions.json entries to tarballs), since several of the packages being converted have patches applied via overrides in downstream RAPIDS projects.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • The cmake-format.json is up to date with these changes.

@bdice bdice added the improvement Improves an existing functionality label Apr 27, 2026
@bdice bdice requested a review from a team as a code owner April 27, 2026 19:27
@bdice bdice added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Apr 27, 2026
@bdice
Copy link
Copy Markdown
Contributor Author

bdice commented Apr 27, 2026

Testing jointly with #1005 downstream in cuDF: rapidsai/cudf#22313

Comment thread rapids-cmake/cpm/detail/generate_patch_command.cmake
Comment thread rapids-cmake/cpm/detail/pinning_write_file.cmake Outdated
bdice added 2 commits April 28, 2026 19:37
Add a new patch application path that uses 'patch -p1' to work on
tarball-extracted directories, which have no .git repository and so
cannot use 'git apply' or 'git am'. The existing git-mode path is
retained unchanged for packages fetched as git clones. The fetch mode
is detected from versions.json (git_url/git_tag vs url/url_hash) and
the patch script dispatches accordingly.

Fix pinning_write_file.cmake to respect mode switching when an override
provides git fields for a package whose default is URL-mode. Previously,
the fallback to default JSON could incorrectly detect URL-mode even when
the override explicitly switched to git-mode.

Update verify_generated_pins to handle URL-mode packages in pin
verification, checking url/url_hash fields instead of git_tag/git_shallow.

Update cpm_package_override-multiple tests to provide git_url alongside
git_tag in overrides, so that partial git overrides remain valid
regardless of whether the default entry is git- or url-mode.

Split the existing patch-command tests into explicit -git and -tarball
variants for each scenario (regular, embedded, required, required-fails)
and add -diff-git/-diff-tarball pairs so both .patch and .diff files
are exercised in both modes. Each test specifies its fetch mode
explicitly in override.json (git_url/git_tag for -git tests,
url/url_hash for -tarball tests) rather than relying on the default,
so the tests remain correct regardless of how versions.json evolves.
The override is applied before rapids_cpm_package_details_internal so
the explicitly declared mode is used for the test's pre-populate step.
@bdice bdice force-pushed the cpm-patch-tarball-support branch from efaec10 to ee9ec5e Compare April 29, 2026 00:42
@bdice bdice requested a review from robertmaynard May 5, 2026 15:37
@bdice
Copy link
Copy Markdown
Contributor Author

bdice commented May 5, 2026

/merge

@rapids-bot rapids-bot Bot merged commit 832f115 into rapidsai:main May 5, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants