Skip to content

fix(python-pip): find a wheel's .data directory by its filename name - #988

Open
olucasleitedev wants to merge 1 commit into
aws:developfrom
olucasleitedev:fix/python-pip-wheel-data-dir-name
Open

olucasleitedev wants to merge 1 commit into
aws:developfrom
olucasleitedev:fix/python-pip-wheel-data-dir-name

Conversation

@olucasleitedev

Copy link
Copy Markdown

Issue #, if available: N/A (same bug as aws/chalice#1356, which this packager was derived from)

Description of changes

Package.data_dir built the {distribution}-{version}.data name from the PEP 503 normalized package name (foo-bar), but wheels name that directory with the escaped name from the wheel filename (foo_bar, PEP 427). For packages whose name contains _, - or . (or upper-case letters, on case-sensitive file systems), _install_purelib_and_platlib never found the directory, so modules shipped under .data/purelib or .data/platlib stayed inside it and could not be imported on Lambda. chalice hit the same bug with an SQLAlchemy wheel built from its sdist (SQLAlchemy-1.3.9.data/purelib/sqlalchemy/...).

data_dir now uses the name and version from the wheel filename. The unit test that asserted the normalized name is updated.

Description of how you validated changes

  • Added a functional test that installs foo_bar-1.2-...whl containing foo_bar-1.2.data/purelib/foo_bar/. It fails on develop (only foo_bar-1.2.data ends up in site-packages) and passes with the fix.
  • pytest tests/unit/workflows/python_pip tests/functional/workflows/python_pip: 204 passed, 1 skipped. black --check and ruff check pass.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Package.data_dir built the {distribution}-{version}.data directory name
from the PEP 503 normalized package name (foo-bar), but a wheel names
that directory with the escaped name from its filename (foo_bar, per
PEP 427). For any package whose name contains "_", "-" or "." (or upper
case letters, on case-sensitive file systems) the directory was never
found, so modules shipped under .data/purelib or .data/platlib were left
inside it and could not be imported in the Lambda package.

Build the directory name from the wheel filename instead.
@olucasleitedev
olucasleitedev requested a review from a team as a code owner December 4, 2026 09:46
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.

1 participant