Skip to content

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented May 23, 2025

Resolves #589.

I also switched the pre-commit config to use any Python 3 instead of constraining to 3.9. Without that, running pre-commit fails as shown in pre-commit/pre-commit#1375.

@vyasr
Copy link
Contributor Author

vyasr commented May 23, 2025

I tested this approach using https://github.com/rapidsai/ucxx/, which has wheels that are currently (incorrectly) linking to libpython and it worked fine in patching those dependencies out. I will be updating that build to remove the dependency altogether on the build side so that we won't need this functionality from auditwheel anymore, but it would still be the safe choice in general IMHO.

Copy link

codecov bot commented May 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.82%. Comparing base (f9bbbce) to head (05c1e54).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #590      +/-   ##
==========================================
+ Coverage   92.78%   92.82%   +0.04%     
==========================================
  Files          21       21              
  Lines        1760     1771      +11     
  Branches      332      333       +1     
==========================================
+ Hits         1633     1644      +11     
  Misses         77       77              
  Partials       50       50              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mayeut mayeut requested review from lkollar and Copilot May 24, 2025 12:22
Copilot

This comment was marked as outdated.

@mayeut mayeut requested a review from Copilot May 24, 2025 12:40
Copilot

This comment was marked as outdated.

@mayeut mayeut requested a review from Copilot May 24, 2025 13:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR changes how libpython dependencies are handled by removing them during repair rather than silently ignoring them, and updates tests to cover the new behavior. It also relaxes the pre-commit Python version constraint to any Python 3.

  • Drop LIBPYTHON_RE filtering in policy.filter_libs
  • Introduce remove_needed calls in repair_wheel and implement it in patcher
  • Add LIBPYTHON_RE support and skipping logic in lddtree
  • Update and add unit/integration tests to cover removal behavior
  • Add a session fixture in conftest.py to clean environment variables

Reviewed Changes

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

Show a summary per file
File Description
src/auditwheel/policy/init.py Remove LIBPYTHON_RE exclusion from filter_libs
src/auditwheel/lddtree.py Add LIBPYTHON_RE, skip libpython resolution in ldd, update __all__
src/auditwheel/repair.py Import LIBPYTHON_RE and call patcher.remove_needed for libpython
src/auditwheel/patcher.py Add remove_needed to base ElfPatcher and implement in Patchelf
tests/unit/test_policy.py Remove libpython entries from expected filtered libs
tests/unit/test_lddtree.py Add match/nomatch tests for LIBPYTHON_RE and a full ldd libpython test
tests/unit/test_elfpatcher.py Add test_remove_needed for Patchelf
tests/integration/test_bundled_wheels.py Extend integration tests for libpython removal and adjust imports
conftest.py Add clean_env fixture to unset auditwheel-related env vars before tests
Comments suppressed due to low confidence (2)

tests/integration/test_bundled_wheels.py:11

  • The test uses mock.patch but mock is no longer imported. Add from unittest import mock or import patch directly to avoid a NameError.
from unittest.mock import Mock

tests/integration/test_bundled_wheels.py:194

  • Namespace is used but not imported; add from argparse import Namespace (or adjust to use a different class) at the top of the file.
args = Namespace(

Co-authored-by: Copilot <[email protected]>
Copy link
Contributor

@lkollar lkollar left a comment

Choose a reason for hiding this comment

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

LGTM. I was wondering if we should introduce some sort of temporary override to disable this behaviour in case it causes issues, but it's always possible to pin to an older version, so I guess that's good enough.

@@ -57,6 +60,15 @@ def replace_needed(self, file_name: Path, *old_new_pairs: tuple[str, str]) -> No
]
)

def remove_needed(self, file_name: Path, *sonames: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, this is the right approach.

@mayeut
Copy link
Member

mayeut commented May 25, 2025

thanks for the review @lkollar

I was wondering if we should introduce some sort of temporary override to disable this behaviour in case it causes issues, but it's always possible to pin to an older version, so I guess that's good enough.

pinning is one way, adding --exclude libpython3*.so.* is another (although it's still a bit different when calling ldd, it wouldn't remove the DT_NEEDED entry)

I'll merge & tag a new version as I'll have some time end of next week if there are some bugs reported with a new version.

@mayeut mayeut merged commit 18a5487 into pypa:main May 25, 2025
14 checks passed
@vyasr vyasr deleted the fix/libpython_linkage branch May 25, 2025 19:11
@vyasr
Copy link
Contributor Author

vyasr commented May 25, 2025

Thanks for getting this cleaned up and merged so quickly! I appreciate the quick review.

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.

auditwheel is explicitly allowlisting libpython even though it violates the manylinux spec
3 participants