Skip to content

refactor: cleanup anti-patterns#3075

Merged
messense merged 4 commits into
PyO3:mainfrom
messense:refactor/codebase-cleanup
Mar 9, 2026
Merged

refactor: cleanup anti-patterns#3075
messense merged 4 commits into
PyO3:mainfrom
messense:refactor/codebase-cleanup

Conversation

@messense

@messense messense commented Mar 9, 2026

Copy link
Copy Markdown
Member

No description provided.

messense added 2 commits March 9, 2026 20:08
Extract the closure-immediately-invoked-for-error-context pattern
in add_data() into a proper named function add_data_subdir(). This
replaces the '(|| { ... })().with_context(...)' idiom with a clean
function call that is easier to read and debug.
- main.rs: Extract ensure_release_profile() to deduplicate PEP 517
  profile defaulting in WriteDistInfo and BuildWheel handlers
- auditwheel/musllinux.rs: Fall back to /usr/bin/ls when /bin/ls
  doesn't exist, fixing compatibility with distros that don't
  symlink /bin -> /usr/bin
@messense messense requested a review from Copilot March 9, 2026 12:10

Copilot AI 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.

Pull request overview

Refactors and cleans up a few small anti-patterns by extracting helper logic, deduplicating profile defaults for PEP 517 builds, and improving musl libc detection robustness.

Changes:

  • Extracted data-subdirectory walking logic into a helper function in module_writer.
  • Centralized “default to release profile” behavior for PEP 517 builds via a local helper.
  • Made musl libc detection more robust by falling back from /bin/ls to /usr/bin/ls.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/module_writer/mod.rs Extracts per-subdir walk/add logic into add_data_subdir for cleaner control flow.
src/main.rs Adds BuildContext import and factors out release-profile defaulting for PEP 517 builds.
src/auditwheel/musllinux.rs Improves libc interpreter detection by trying an alternate ls path.

Comment thread src/module_writer/mod.rs Outdated
Comment thread src/main.rs Outdated
messense and others added 2 commits March 9, 2026 20:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@messense messense merged commit ecdedbf into PyO3:main Mar 9, 2026
35 of 36 checks passed
@messense messense deleted the refactor/codebase-cleanup branch March 9, 2026 12:20
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