Best Practices for Cross-Compiling Wheels with `setup.py`

You might get some hints from how cibuildwheel sets up cross-compiling on Windows. The --plat-name option can be set through a configuration file, which can be specified by environment variable (as shown in the linked code), and the variable to override the extension module suffix explicitly should work on all platforms.

VSCMD_ARG_TGT_ARCH probably isn’t relevant, though it may work if you need the distutils.get_platform() function (or its equivalents) to report something different.

So it’s a bit complicated, but the only real alternative is going to be invasive. (Adding that pyproject.toml - if none currently exists - shouldn’t be invasive at all. The build-backend specification is the only one you need, there’s no requirement to fill out any of the rest in order to use setuptools (or other build backends that don’t require it) - if there is, it’s because setuptools chose to make it mandatory, even though they didn’t have to.)

1 Like