Skip to content

PYTHON-5839 - PyMongo wheels have multiple versions of C extensions#2865

Merged
NoahStapp merged 1 commit into
mongodb:masterfrom
NoahStapp:PYTHON-5839
Jun 10, 2026
Merged

PYTHON-5839 - PyMongo wheels have multiple versions of C extensions#2865
NoahStapp merged 1 commit into
mongodb:masterfrom
NoahStapp:PYTHON-5839

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

PYTHON-5839

Changes in this PR

Clean up built C extensions after each version to prevent them from leaking into the next wheel.

Test Plan

Tested with dist CI checks.

Checklist

Checklist for Author

  • [ ] Did you update the changelog (if necessary)?
  • [ ] Is there test coverage?
  • [ ] Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

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

This PR addresses PYTHON-5839 by ensuring in-place built C extension artifacts don’t persist between cibuildwheel builds for different Python versions, preventing multiple extension versions from being unintentionally included across wheels.

Changes:

  • Replace the old targeted cleanup logic with a generic cleanup that removes *.so and *.pyd artifacts from bson/ and pymongo/.
  • Configure cibuildwheel via CIBW_BEFORE_BUILD in the dist workflow to run the cleanup before each wheel build.

Reviewed changes

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

File Description
tools/clean.py Simplifies cleanup by deleting any *.so/*.pyd under bson and pymongo before each build.
.github/workflows/dist.yml Adds CIBW_BEFORE_BUILD hook so cleanup runs before each cibuildwheel build iteration.

@NoahStapp

Copy link
Copy Markdown
Contributor Author

Old output:

# in wheel's bson/ directory
_cbson.cpython-39-aarch64-linux-gnu.so
_cbson.cpython-310-aarch64-linux-gnu.so
_cbson.cpython-311-aarch64-linux-gnu.so
_cbson.cpython-312-aarch64-linux-gnu.so
_cbson.cpython-313-aarch64-linux-gnu.so
_cbson.cpython-314-aarch64-linux-gnu.so

New output:

# in wheel's bson/ directory
_cbson.cpython-39-x86_64-linux-gnu.so

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@blink1073 blink1073 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@NoahStapp NoahStapp merged commit d8b6b8a into mongodb:master Jun 10, 2026
73 of 77 checks passed
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.

4 participants