Skip to content

Crosscompiling

Under certain conditions1, Pyaket automatically uses cargo-zigbuild for an easier and streamlined cross-compilation experience, where Zig is used in the final -- and complex -- linking stage.

  • Most of the code is pure-rust, but some crates may depend on specific syscalls or libraries.
  • Instructions here only applies for hosts that differ from the target.

Have ziglang installed

Simply install pyaket with the zig dependency group, as in pip install pyaket[zig]

Opting out of auto zigbuild

Whenever you have compatible tools for a target, you can set the AUTO_ZIGBUILD=0 environment variable to disable the automatic usage of cargo-zigbuild (eg. a working mingw-w64 toolchain)

Targets

MacOS

Compiling to Apple targets requires any of:

  • Setting SDKROOT=Path to a MacOS SDK path, like this one (easier).
  • Setting DEVELOPER_DIR=Path to an Xcode installation.

You're good to go, as simple as that 🚀

Pyaket Docker images already includes them!

Note: Automatically managing an SDK is tracked in this issue.

Linux

Windows

MinGW

Compiling to a Windows target is easier done via *-pc-windows-gnu, which requires a mingw-w64 toolchain

MSVC

Experimental

It may be possible to use cargo-xwin to build MSVC binaries from non-windows hosts, tracked in #18.

Compatibility table

Thanks to Rust's amazing toolchain, coupled with cargo-zigbuild, and using pure crates, Pyaket can pretty much compile executables from any platform to any platform without docker or vms.

From / To

N/A

N/A

GNU

MSVC

🐧 Linux x86 ✅ x86

☑️ Arm

☑️ x86

☑️ Arm

✅ x86

❌ Arm

🚫 x86

🚫 Arm

🐧 Linux Arm ❓ x86

❓ Arm

❓ x86

❓ Arm

❓ x86

❌ Arm

🚫 x86

🚫 Arm

💠 Windows x86 ✅ x86

☑️ Arm

☑️ x86

☑️ Arm

✅ x86

☑️ Arm

✅ x86

🤏 Arm

💠 Windows Arm ❓ x86

❓ Arm

❓ x86

❓ Arm

❓ x86

❓ Arm

❓ x86

❓ Arm

🍎 MacOS x86 ✔️ x86

✔️ Arm

✔️ x86

✔️ Arm

✔️ x86

✔️ Arm

🚫 x86

🚫 Arm

🍎 MacOS Arm ✔️ x86

✔️ Arm

✔️ x86

✔️ Arm

✔️ x86

✔️ Arm

🚫 x86

🚫 Arm

Note: The table simply states if it compile and/or run. Your Python project may not work on all platforms.

  • ✅ Verified and supported
  • ☑️ Compiled, but untested
  • ✔️ Should work (untested)
  • ❌ Impractical (possible)
  • 🚫 Impossible

  1. Most often when the target operating system differs from the host one.