kaitai_struct_python_runtime icon indicating copy to clipboard operation
kaitai_struct_python_runtime copied to clipboard

Upload prebuilt wheel distributions to PyPI

Open dgelessus opened this issue 5 years ago • 0 comments
trafficstars

It looks like currently the PyPI kaitaistruct package only contains a source tarball distribution, but not a prebuilt wheel distribution. Wheels are Python's format for built packages, and their advantage is that a wheel is a static collection of files, which can be installed (by Python package managers like pip) by just extracting them into the proper location. In contrast, installing a package from a source tarball requires running a build script/tool, and potentially installing extra dependencies for the build. This all happens automatically, but is a bit slower than just extracting a wheel. Wheels also have some other advantages besides just installation speed, but they're a bit complicated to explain. In any case, it's considered good practice to provide wheels, and almost every package on PyPI has them.

In the case of pure Python modules like kaitaistruct, the difference between installing a source tarball and a wheel actually isn't that big - because Python code doesn't need to be compiled, the build from source has no special requirements and normally takes less than a second to complete. On the other hand, this also means that it's very quick and easy as a developer to build and upload a wheel distribution, and it makes the installation a little bit faster for everyone 🙂

The process for building and uploading a wheel is very straightforward - it should be enough to go into a source directory for version 0.9 of the runtime and run:

$ python3 setup.py bdist_wheel
$ twine check dist/kaitaistruct-0.9-*.whl # runs a few validity checks on the wheel's metadata
$ twine upload dist/kaitaistruct-0.9-*.whl

This should add the built wheel in addition to the existing source tarball for version 0.9. I think PyPI lets you retroactively upload additional files for existing releases, as long as no existing files would get overwritten. I've never actually tried this myself though (I always upload source and wheel distributions at the same time) so it might not actually be possible to add a wheel to an existing release like this.

dgelessus avatar Oct 29 '20 02:10 dgelessus