Skip to content

feat(repair): add --strip-level option for granular strip control#682

Open
taegyunkim wants to merge 4 commits intopypa:mainfrom
taegyunkim:strip-levels
Open

feat(repair): add --strip-level option for granular strip control#682
taegyunkim wants to merge 4 commits intopypa:mainfrom
taegyunkim:strip-levels

Conversation

@taegyunkim
Copy link
Copy Markdown

@taegyunkim taegyunkim commented Mar 24, 2026

Summary

Closes #491.

  • Adds a new --strip-level option to auditwheel repair with four levels: none (default), debug (strip -g), unneeded (strip --strip-unneeded), and all (strip -s)
  • Deprecates the existing --strip flag (maps to --strip-level=all for backward compatibility)
  • Validates conflicting --strip and --strip-level usage early, before any wheel processing begins

Motivation

The current --strip flag only supports strip -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

  • StripLevel enum in repair.py maps each level to the corresponding strip CLI arguments
  • process_symbols() applies stripping to both vendored libraries and extension modules
  • Conflict guard and strip normalization happen at the top of repair_wheel(), before the pure-wheel early return
  • _get_strip_args(StripLevel.NONE) raises ValueError as a safety net (callers skip processing for NONE)

Test plan

  • Unit tests for argument parsing (TestStripLevelArgument)
  • Unit tests for execute() integration (TestStripLevelExecute) — verifies strip level is passed through, deprecation warning is emitted, and conflicting args error
  • Unit tests for repair_wheel() behavior (TestRepairWheelStripLevels) — verifies process_symbols is called/skipped correctly per level
  • Unit tests for _get_strip_args and process_symbols (TestGetStripArgs, TestProcessSymbols, TestStripSymbolsShim)
  • Conflict guard test on pure wheels (TestRepairWheelConflict)
  • All 200 unit tests pass

taegyunkim and others added 4 commits March 21, 2026 17:27
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
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.

Allow repair to use strip with --strip-debug instead of only allowing --strip-all

1 participant