How to use ahead-of-time compilation with PyPI?

I have integrated ahead-of-time compilation as described in but when building the package like python3 sdist bdist_wheel and uploading the module to with twine upload --repository-url dist/*, I get the error message:

HTTPError: 400 Bad Request from
Binary wheel 'MyModule-1.0.0-cp37-cp37m-linux_x86_64.whl' has an unsupported platform tag 'linux_x86_64'.

Instead, I could build a source-only package with python3 sdist, but then the module won’t be aot-compiled and import will fail. A solution might be to aot-compile the module on first import, but I am not sure where to put the resulting shared library file for each possible platform.

You will probably need to use one of the manylinux platform tags to upload to PyPI:

There is some more info about the manylinux platform here:

This repo contains an example of building manylinux wheels:

Thank you for the links.

It seems like this would make the build process overly complex and I would still have to deal with Windows and Linux.

Instead, I’ll try to find out where to put the files when aot-compiling on import.

Would using the cache kwarg for the JIT decorator address your use case?

Using the kwarg would result in compilation on users’ machines on the first use for each set of argument types - on subsequent runs the compiled code will be loaded from the cache.

We were using caching until a few days ago, but import still took several seconds. With aot, it only takes slightly more than one second. A previous version was using C with ffi, which took well under a second to import, but it was harder to maintain for different platforms.

In a perfect world, caching would also be near-instant, but as long as that is not the case, aot-compilation seems like the next-best option.

We are now compiling on first import:

This way, we do not have to deal with manylinux and import will be reasonably fast.