pypa / cibuildwheel

🎡 Build Python wheels for all the platforms with minimal configuration.
https://cibuildwheel.pypa.io
Other
1.86k stars 237 forks source link

Run twine check on built wheels #797

Closed Korijn closed 3 years ago

Korijn commented 3 years ago

twine check <wheel> is a quick little test, which for example verifies if your README and LICENSE are correctly linked and formatted such that they will display correctly on pypi. Would be useful if there was an option to enable this step as part of the package test!

henryiii commented 3 years ago

Why not just run it yourself? pipx run twine check wheelhouse/* is one line - same length as adding an option. It also would add a new dependency for us. Small packages that do one thing well are better than conglomerates. Also, if you use the gh-action-pypi-publish GitHub Action from PyPA, that runs twine check for you.

While I like the idea behind it, twine check actually doesn't really check most issues - I don't think I've run across a failed PyPI upload in the wild it could have caught yet. Adding extra quotes around names, missing metadata, etc. all are not checked by it.

henryiii commented 3 years ago

However, maybe we could provide a post-build command? So a user could put "twine check {wheel}". I'm thinking that might be very useful for a different use case (re-tagging the wheels), so might be something to keep in mind.

Korijn commented 3 years ago

Well, I would like to add it to the test command via configuration, but I'm not sure how to point it to the wheel file.

henryiii commented 3 years ago

That's the wrong abstraction. If, for example, your wheel is not installable (usually because you are building for a platform that NumPy hasn't released wheels yet for), then adding a test command will cause the package to be installed, triggering your numpy in install_requires, and breaking. Tests are based on installing your package, while twine does not expect or want the package to be installed.

Really, running twine check on each wheel is wasteful, anyway. What I'd do is run it on your SDist once, instead of on every wheel. See https://github.com/scikit-hep/boost-histogram/blob/481fbd39506f7d9eaead6f13d32842af0cb1c892/.github/workflows/wheels.yml#L37

henryiii commented 3 years ago

Probably should add --strict there, actually.

Korijn commented 3 years ago

Fair enough! I can work with that, thanks again.