4

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?

Jasper
  • 1,193
  • 1
  • 9
  • 14

2 Answers2

5

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.

Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121
1

pyo3 now has experimental Windows feature to bypass this process entirely using python3-dll-a. Read more here.

Jk Jensen
  • 339
  • 2
  • 4
  • 16