check-wheel-contents is a command-line tool designed to validate the structure and contents of Python wheel (.whl) files, helping developers avoid common packaging mistakes before publishing. It analyzes wheels for issues like incorrect file placement, duplicate files, or inclusion of unwanted artifacts (`.pyc` files, `tests/` directories). Maintained actively, it currently supports Python 3.10 and newer.
pip install check-wheel-contentsNo compatibility data collected yet for this library.
After building your Python wheel, typically using `python -m build --wheel` which places it in a `dist/` directory, run `check-wheel-contents` on the generated `.whl` file or the directory containing it. The tool will print 'OK' if all checks pass, or detailed error messages for any failures.
Ensure your project uses a 'src/' layout (e.g., `package_dir={'': 'src'}` in `setup.py` or equivalent in `pyproject.toml`) and that no `__init__.py` exists directly in `src/` or the project root if it's not part of a package.Add `global-exclude *.py[co]` to your `MANIFEST.in` file (if using `setuptools`) to prevent these files from being included, ensuring it's placed correctly if you're also using `graft` or `recursive-include`.
Always clean your build environment by deleting the `build/` and `dist/` directories (e.g., `rm -rf build dist/`) before performing a new wheel build.
Review your `setup.py` or `pyproject.toml` configuration to ensure only your main package(s) are included. Use `exclude` arguments in `find_packages()` or explicitly list packages/modules, ensuring that test directories or other artifacts are not inadvertently included at the top level.
Exclude `*.pyc` and `*.pyo` files from your wheel build process, typically by adding `global-exclude *.py[co]` to your `MANIFEST.in` (for setuptools projects) or configuring your build backend accordingly.
Delete the `build/` directory and rebuild the wheel to resolve stale files. Review your packaging configuration to ensure no files are being copied instead of moved or renamed, or included twice from different sources.
Adjust your build configuration (e.g., `setuptools.find_packages()` exclusions, `package_dir` settings) to ensure only the intended main package(s) are installed at the top level of `site-packages`.
Verify that all files included in the wheel are genuinely part of your project's source. This might involve cleaning your build directory (`rm -rf build dist/`) and rebuilding, or correcting your `MANIFEST.in` or build configuration to accurately reflect your source layout.
No dependency data recorded yet.