Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compiling (unixlike to windows) with PyO3 and Maturin

I'm wondering if anyone has experience with cross-compiling to windows with pyo3 and maturin.

The pyo3 docs say:

Cross compiling PyO3 modules is relatively straightforward and requires a few pieces of software:

A toolchain for your target. The appropriate options in your Cargo .config for the platform you're targeting and the toolchain you are using. A Python interpreter that's already been compiled for your target. The headers that match the above interpreter.

I've found the interpreter from here, but I don't understand how to get a windows python interpreter and libraries, or even what that means exactly.

I'm using maturin to build the python wheels and it works well on OS X, but I don't know how to start cross-compiling for windows.

Can anyone help me out?

like image 412
Jasper Avatar asked Nov 01 '25 07:11

Jasper


1 Answers

The goal is a wheel per Python version / architecture / OS.

An easy way to achieve this is through external runners (e.g. gitub runners) and an action that compiles the package using maturin for each of the platforms.

Here is how hyperjson does it.

like image 190
Jorge Leitao Avatar answered Nov 03 '25 21:11

Jorge Leitao