@@ -2,18 +2,23 @@ Standalone `python3.dll` import library generator
22=================================================
33
44Generates import libraries for the Stable ABI Python DLL
5- for MinGW-w64 cross-compile targets.
5+ for MinGW-w64 and MSVC ( cross-) compile targets.
66
77See < https://docs.python.org/3/c-api/stable.html > for details.
88
99This crate ** does not require** Python 3 distribution files
10- to be present on the cross-compile host system.
10+ to be present on the (cross-)compile host system.
11+
12+ ** Note:** MSVC (cross-)compile targets require LLVM binutils
13+ to be available on the host system.
14+ More specifically, ` python3-dll-a ` requires ` llvm-dlltool ` executable
15+ to be present in ` PATH ` when targeting ` *-pc-windows-msvc ` .
1116
1217Example ` build.rs ` script
1318-------------------------
1419
1520The following script can be used to cross-compile Stable ABI
16- PyO3 extension modules for Windows:
21+ PyO3 extension modules for Windows (64-bit MinGW-w64) :
1722
1823``` rust
1924fn main () {
@@ -29,18 +34,19 @@ fn main() {
2934A compatible ` python3.dll ` import library will be automatically created in
3035the directory pointed by ` PYO3_CROSS_LIB_DIR ` environment variable.
3136
32- If both 64-bit and 32-bit Windows cross-compile targets support is needed,
33- the more generic ` generate_implib_for_target() ` function must be used:
37+ If both 64-bit and 32-bit or GNU and MSVC ABI (cross-)compile target
38+ support is needed, the more generic ` generate_implib_for_target() `
39+ function must be used:
40+
3441
3542``` rust
3643fn main () {
37- if std :: env :: var (" CARGO_CFG_TARGET_OS" ). unwrap () == " windows"
38- && std :: env :: var (" CARGO_CFG_TARGET_ENV" ). unwrap () == " gnu"
39- {
44+ if std :: env :: var (" CARGO_CFG_TARGET_OS" ). unwrap () == " windows" {
4045 let libdir = std :: env :: var (" PYO3_CROSS_LIB_DIR" )
4146 . expect (" PYO3_CROSS_LIB_DIR is not set when cross-compiling" );
4247 let arch = std :: env :: var (" CARGO_CFG_TARGET_ARCH" ). unwrap ();
43- python3_dll_a :: generate_implib_for_target (& libdir , & arch , " gnu" )
48+ let env = std :: env :: var (" CARGO_CFG_TARGET_ENV" ). unwrap ();
49+ python3_dll_a :: generate_implib_for_target (& libdir , & arch , & env )
4450 . expect (" python3.dll import library generator failed" );
4551 }
4652}
0 commit comments