feat(repair): add --strip-level option for granular strip control#682
Open
taegyunkim wants to merge 4 commits intopypa:mainfrom
Open
feat(repair): add --strip-level option for granular strip control#682taegyunkim wants to merge 4 commits intopypa:mainfrom
taegyunkim wants to merge 4 commits intopypa:mainfrom
Conversation
Add a --strip-level flag to auditwheel repair with four levels: - none (default, no change in behavior) - debug (strip -g: removes debug symbols only, preserves full backtraces) - unneeded (strip --strip-unneeded: removes symbols not needed for relocation) - all (strip -s: removes all symbols, equivalent to old --strip) The existing --strip flag is deprecated in favour of --strip-level=all. Both flags are mutually exclusive. The strip_symbols() function is kept for backward API compatibility and delegates to the new process_symbols(). Closes pypa#491 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Move conflict guard and strip normalization to top of repair_wheel(), before the pure-wheel early return, preventing partial wheel writes - Resolve StripLevel.NONE vs Python None confusion: execute() now resolves --strip to strip_level=ALL before the loop and no longer passes the deprecated strip= parameter to repair_wheel() - Fix zip_compression_level default from 0 (Z_NO_COMPRESSION) to zlib.Z_DEFAULT_COMPRESSION - Make _get_strip_args(NONE) raise ValueError instead of returning [] (which would invoke strip with no flags, stripping all symbols) - Fix test mocks for Python 3.14 compatibility (MagicMock comparison), lazy import patch targets, dist-info assertion, and SBOM patching
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #491.
--strip-leveloption toauditwheel repairwith four levels:none(default),debug(strip -g),unneeded(strip --strip-unneeded), andall(strip -s)--stripflag (maps to--strip-level=allfor backward compatibility)--stripand--strip-levelusage early, before any wheel processing beginsMotivation
The current
--stripflag only supportsstrip -s(strip all symbols), which is too aggressive for many use cases. Users building wheels with debug symbols want the ability to strip only debug info (-g) or unneeded symbols (--strip-unneeded) while keeping the symbol table intact for debugging and profiling.Design
StripLevelenum inrepair.pymaps each level to the correspondingstripCLI argumentsprocess_symbols()applies stripping to both vendored libraries and extension modulesrepair_wheel(), before the pure-wheel early return_get_strip_args(StripLevel.NONE)raisesValueErroras a safety net (callers skip processing forNONE)Test plan
TestStripLevelArgument)execute()integration (TestStripLevelExecute) — verifies strip level is passed through, deprecation warning is emitted, and conflicting args errorrepair_wheel()behavior (TestRepairWheelStripLevels) — verifiesprocess_symbolsis called/skipped correctly per level_get_strip_argsandprocess_symbols(TestGetStripArgs,TestProcessSymbols,TestStripSymbolsShim)TestRepairWheelConflict)