From d66d1bc9e5ffcc58971019f5a0f7ff3ce601e839 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 15 May 2022 10:53:53 +0800 Subject: [PATCH 1/4] Integrate `cargo-xwin` for cross compiling to Windows MSVC targets --- .github/workflows/test.yml | 4 +- Cargo.lock | 738 ++++++++++++++++++++++++++++++++++++- Cargo.toml | 6 + Changelog.md | 1 + src/compile.rs | 45 ++- 5 files changed, 771 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3489ccb33..d99579a0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -121,9 +121,11 @@ jobs: - name: test cross compiling windows abi3 wheel if: matrix.os == 'ubuntu-latest' run: | - sudo apt-get install -y mingw-w64 + sudo apt-get install -y mingw-w64 llvm rustup target add x86_64-pc-windows-gnu + rustup target add x86_64-pc-windows-msvc cargo run -- build --no-sdist -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-gnu + cargo run -- build --no-sdist -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-msvc - name: test compiling with PYO3_CONFIG_FILE shell: bash run: | diff --git a/Cargo.lock b/Cargo.lock index 1ff3a16aa..902e5651c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,6 +214,18 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cab" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d789f1af9f1c827b64e2e442f23022e118a6dd34c20f29dc098b7f951f9b14aa" +dependencies = [ + "byteorder", + "chrono", + "flate2", + "lzxd", +] + [[package]] name = "cache-padded" version = "1.2.0" @@ -247,6 +259,23 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-xwin" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "539cdddb3a51ac413196f50872f000112d1c5343a9860c7a1b76c8a21903bb00" +dependencies = [ + "anyhow", + "cargo-options", + "clap", + "dirs", + "fs-err", + "indicatif", + "path-slash", + "which", + "xwin", +] + [[package]] name = "cargo-zigbuild" version = "0.8.7" @@ -304,6 +333,16 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +[[package]] +name = "cfb" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f89d248799e3f15f91b70917f65381062a01bb8e222700ea0e5a7ff9785f9c" +dependencies = [ + "byteorder", + "uuid", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -326,6 +365,19 @@ dependencies = [ "encoding_rs", ] +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time 0.1.43", + "winapi", +] + [[package]] name = "chunked_transfer" version = "1.4.0" @@ -400,6 +452,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "cli-table" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbb116d9e2c4be7011360d0c0bee565712c11e969c9609b25b619366dc379d" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "combine" version = "4.6.4" @@ -474,6 +536,41 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-utils" version = "0.8.8" @@ -581,6 +678,70 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" +dependencies = [ + "encoding-index-japanese", + "encoding-index-korean", + "encoding-index-simpchinese", + "encoding-index-singlebyte", + "encoding-index-tradchinese", +] + +[[package]] +name = "encoding-index-japanese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-korean" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-simpchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-singlebyte" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding-index-tradchinese" +version = "1.20141219.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" +dependencies = [ + "encoding_index_tests", +] + +[[package]] +name = "encoding_index_tests" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" + [[package]] name = "encoding_rs" version = "0.8.31" @@ -825,7 +986,7 @@ checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -864,6 +1025,25 @@ dependencies = [ "scroll", ] +[[package]] +name = "h2" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.11.2" @@ -905,6 +1085,40 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "http" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff8670570af52249509a86f5e3e18a08c60b177071826898fde8997cf5f6bfbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + [[package]] name = "human-panic" version = "1.0.3" @@ -929,6 +1143,43 @@ dependencies = [ "quick-error", ] +[[package]] +name = "hyper" +version = "0.14.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +dependencies = [ + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + [[package]] name = "idna" version = "0.2.3" @@ -968,6 +1219,17 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indicatif" +version = "0.17.0-rc.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2946516aa80379c1e6ee9cfa75a7b2faf23f63690f44d682e7fecd0141bbcaf2" +dependencies = [ + "console", + "number_prefix", + "unicode-width", +] + [[package]] name = "indoc" version = "1.0.6" @@ -983,6 +1245,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "ipnet" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" + [[package]] name = "itertools" version = "0.10.3" @@ -1042,6 +1310,16 @@ version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -1051,6 +1329,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "lzxd" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784462f20dddd9dfdb45de963fa4ad4a288cb10a7889ac5d2c34fb6481c6b213" + [[package]] name = "mailparse" version = "0.13.8" @@ -1062,6 +1346,15 @@ dependencies = [ "quoted_printable", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.9" @@ -1075,6 +1368,7 @@ dependencies = [ "anyhow", "base64", "bytesize", + "cargo-xwin", "cargo-zigbuild", "cargo_metadata", "cbindgen", @@ -1119,7 +1413,7 @@ dependencies = [ "toml_edit", "tracing", "ureq", - "zip", + "zip 0.6.2", ] [[package]] @@ -1128,6 +1422,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.16" @@ -1162,6 +1465,30 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "msi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e13d63451762860877abbdb23e8bb67ddf408f48dfc3ac2a1eef8575fc5d2ce" +dependencies = [ + "byteorder", + "cfb", + "encoding", + "uuid", +] + [[package]] name = "multipart" version = "0.18.0" @@ -1292,6 +1619,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "num_threads" version = "0.1.6" @@ -1301,6 +1638,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.28.4" @@ -1369,9 +1712,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.0.0" +version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +checksum = "029d8d0b2f198229de29dca79676f2738ff952edf3fde542eb8bf94d8c21b435" [[package]] name = "os_type" @@ -1388,6 +1731,29 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +[[package]] +name = "parking_lot" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "path-slash" version = "0.1.4" @@ -1537,7 +1903,7 @@ dependencies = [ "rfc2047-decoder", "tar", "thiserror", - "zip", + "zip 0.6.2", ] [[package]] @@ -1591,6 +1957,30 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -1622,6 +2012,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.25" @@ -1637,6 +2036,44 @@ dependencies = [ "winapi", ] +[[package]] +name = "reqwest" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + [[package]] name = "rfc2047-decoder" version = "0.1.2" @@ -1692,9 +2129,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" +checksum = "a024a432ae760ab3bff924ad91ce1cfa52cb57ed16e1ef32d0d249cfee1a6c13" dependencies = [ "log", "ring", @@ -1702,6 +2139,15 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls-pemfile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" +dependencies = [ + "base64", +] + [[package]] name = "ryu" version = "1.0.9" @@ -1733,6 +2179,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "scroll" version = "0.11.0" @@ -1857,6 +2309,18 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sha2" version = "0.9.9" @@ -1881,6 +2345,15 @@ dependencies = [ "digest 0.10.3", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.1.0" @@ -1893,6 +2366,12 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + [[package]] name = "smawk" version = "0.3.1" @@ -2035,6 +2514,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "time" version = "0.3.9" @@ -2068,6 +2557,48 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "1.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395" +dependencies = [ + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "pin-project-lite", + "socket2", + "winapi", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-util" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.9" @@ -2089,6 +2620,12 @@ dependencies = [ "serde", ] +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + [[package]] name = "tracing" version = "0.1.34" @@ -2119,6 +2656,52 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" dependencies = [ "lazy_static", + "valuable", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" +dependencies = [ + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", + "tracing-serde", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if 1.0.0", + "rand", + "static_assertions", ] [[package]] @@ -2217,6 +2800,12 @@ dependencies = [ "getrandom", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vcpkg" version = "0.2.15" @@ -2252,12 +2841,28 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.80" @@ -2283,6 +2888,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.80" @@ -2350,6 +2967,17 @@ dependencies = [ "cc", ] +[[package]] +name = "which" +version = "4.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +dependencies = [ + "either", + "lazy_static", + "libc", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2381,6 +3009,58 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "xattr" version = "0.2.3" @@ -2390,6 +3070,36 @@ dependencies = [ "libc", ] +[[package]] +name = "xwin" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e156ef24de8e2e1d7296aec835f4e3e569b0491508374a7f9a4319d539f51" +dependencies = [ + "anyhow", + "bytes", + "cab", + "camino", + "chrono", + "clap", + "cli-table", + "flate2", + "indicatif", + "msi", + "parking_lot", + "rayon", + "regex", + "reqwest", + "ring", + "serde", + "serde_json", + "tempfile", + "tracing", + "tracing-subscriber", + "twox-hash", + "zip 0.5.13", +] + [[package]] name = "zbus" version = "1.9.1" @@ -2425,6 +3135,18 @@ dependencies = [ "syn", ] +[[package]] +name = "zip" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815" +dependencies = [ + "byteorder", + "crc32fast", + "flate2", + "thiserror", +] + [[package]] name = "zip" version = "0.6.2" @@ -2436,7 +3158,7 @@ dependencies = [ "crc32fast", "crossbeam-utils", "flate2", - "time", + "time 0.3.9", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c1a6aac5a..dc05e9577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ bytesize = "1.0.1" glob = "0.3.0" cargo_metadata = "0.14.0" cargo-zigbuild = "0.8.7" +cargo-xwin = "0.8.4" cbindgen = { version = "0.23.0", default-features = false } flate2 = "1.0.18" goblin = "0.5.1" @@ -84,3 +85,8 @@ faster-tests = [] # Without this, compressing the .gz archive becomes notably slow for debug builds [profile.dev.package.miniz_oxide] opt-level = 3 +# Speedup cargo-xwin for debug builds +[profile.dev.package.cab] +opt-level = 3 +[profile.dev.package.msi] +opt-level = 3 diff --git a/Changelog.md b/Changelog.md index 14bc4445b..ced7f1e33 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Allow setting the publish user name via `MATURIN_USERNAME` in [#915](https://github.com/PyO3/maturin/pull/915) * Add Windows python sysconfig in [#917](https://github.com/PyO3/maturin/pull/917) * Add support for `generate-import-lib` feature of pyo3 in [#918](https://github.com/PyO3/maturin/pull/918) +* Integrate [`cargo-xwin`](https://github.com/messense/cargo-xwin) for cross compiling to Windows MSVC targets in [#919](https://github.com/PyO3/maturin/pull/919) ## [0.12.15] - 2022-05-07 diff --git a/src/compile.rs b/src/compile.rs index cb64108fe..27be25073 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -192,26 +192,43 @@ fn compile_target( .chain(&rustc_args) .collect(); - let mut build = cargo_zigbuild::Build::new(Some(context.manifest_path.clone())); let target_triple = target.target_triple(); - if !context.zig { - build.disable_zig_linker = true; - if target.user_specified { - build.target = vec![target_triple.to_string()]; + let mut build_command = if target.is_msvc() && target.cross_compiling() { + let mut build = cargo_xwin::Build::new(Some(context.manifest_path.clone())); + build.target = vec![target_triple.to_string()]; + // Pass zig command to downstream, eg. python3-dll-a + if let Ok((zig_cmd, zig_args)) = cargo_zigbuild::Zig::find_zig() { + let zig_cmd = if zig_args.is_empty() { + zig_cmd + } else { + format!("{} {}", zig_cmd, zig_args.join(" ")) + }; + env::set_var("ZIG_COMMAND", zig_cmd); } + build.build_command("rustc")? } else { - let zig_triple = if target.is_linux() { - match context.platform_tag { - Some(PlatformTag::Manylinux { x, y }) => format!("{}.{}.{}", target_triple, x, y), - _ => target_triple.to_string(), + let mut build = cargo_zigbuild::Build::new(Some(context.manifest_path.clone())); + if !context.zig { + build.disable_zig_linker = true; + if target.user_specified { + build.target = vec![target_triple.to_string()]; } } else { - target_triple.to_string() - }; - build.target = vec![zig_triple]; - } + let zig_triple = if target.is_linux() { + match context.platform_tag { + Some(PlatformTag::Manylinux { x, y }) => { + format!("{}.{}.{}", target_triple, x, y) + } + _ => target_triple.to_string(), + } + } else { + target_triple.to_string() + }; + build.target = vec![zig_triple]; + } + build.build_command("rustc")? + }; - let mut build_command = build.build_command("rustc")?; build_command .args(&build_args) // We need to capture the json messages From d2d0bb8eba23370c182391e9bd6c55dd7359f808 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 15 May 2022 16:57:13 +0800 Subject: [PATCH 2/4] Feature-gate `cargo-xwin` because it depends on ring and rustls --- Cargo.toml | 4 ++-- src/compile.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dc05e9577..75e7b7809 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ bytesize = "1.0.1" glob = "0.3.0" cargo_metadata = "0.14.0" cargo-zigbuild = "0.8.7" -cargo-xwin = "0.8.4" +cargo-xwin = { version = "0.8.4", optional = true } cbindgen = { version = "0.23.0", default-features = false } flate2 = "1.0.18" goblin = "0.5.1" @@ -77,7 +77,7 @@ default = ["log", "upload", "rustls", "human-panic"] upload = ["ureq", "multipart", "rpassword", "configparser"] password-storage = ["upload", "keyring"] log = ["pretty_env_logger"] -rustls = ["ureq/tls"] +rustls = ["ureq/tls", "cargo-xwin"] native-tls = ["ureq/native-tls", "native-tls-crate"] # Internal feature to speed up the tests significantly faster-tests = [] diff --git a/src/compile.rs b/src/compile.rs index 27be25073..46da4e487 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -194,7 +194,11 @@ fn compile_target( let target_triple = target.target_triple(); let mut build_command = if target.is_msvc() && target.cross_compiling() { + #[cfg(feature = "cargo-xwin")] let mut build = cargo_xwin::Build::new(Some(context.manifest_path.clone())); + #[cfg(not(feature = "cargo-xwin"))] + let mut build = cargo_zigbuild::Build::new(Some(context.manifest_path.clone())); + build.target = vec![target_triple.to_string()]; // Pass zig command to downstream, eg. python3-dll-a if let Ok((zig_cmd, zig_args)) = cargo_zigbuild::Zig::find_zig() { From 6c9a92db3263234d109055f002f55afcafbbe3e4 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 15 May 2022 18:02:08 +0800 Subject: [PATCH 3/4] Always pass `ZIG_COMMAND` env var when `--zig` is present --- src/compile.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/compile.rs b/src/compile.rs index 46da4e487..862d8e7fc 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -200,15 +200,6 @@ fn compile_target( let mut build = cargo_zigbuild::Build::new(Some(context.manifest_path.clone())); build.target = vec![target_triple.to_string()]; - // Pass zig command to downstream, eg. python3-dll-a - if let Ok((zig_cmd, zig_args)) = cargo_zigbuild::Zig::find_zig() { - let zig_cmd = if zig_args.is_empty() { - zig_cmd - } else { - format!("{} {}", zig_cmd, zig_args.join(" ")) - }; - env::set_var("ZIG_COMMAND", zig_cmd); - } build.build_command("rustc")? } else { let mut build = cargo_zigbuild::Build::new(Some(context.manifest_path.clone())); @@ -233,6 +224,18 @@ fn compile_target( build.build_command("rustc")? }; + if context.zig { + // Pass zig command to downstream, eg. python3-dll-a + if let Ok((zig_cmd, zig_args)) = cargo_zigbuild::Zig::find_zig() { + let zig_cmd = if zig_args.is_empty() { + zig_cmd + } else { + format!("{} {}", zig_cmd, zig_args.join(" ")) + }; + build_command.env("ZIG_COMMAND", zig_cmd); + } + } + build_command .args(&build_args) // We need to capture the json messages From 69246fff0beedff14326beb7b24dffc5dffa1843 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 16 May 2022 10:31:25 +0800 Subject: [PATCH 4/4] Add a non-abi3 windows wheel cross compiling test --- .github/workflows/test.yml | 7 ++++++- test-crates/pyo3-mixed/Cargo.lock | 16 ++++++++++++++++ test-crates/pyo3-mixed/Cargo.toml | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d99579a0e..8b8f087de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,14 +118,19 @@ jobs: cargo run -- build --no-sdist -i python3.9 -m test-crates/pyo3-mixed/Cargo.toml --target aarch64-apple-darwin --zig # Check wheels with twine twine check --strict test-crates/pyo3-mixed/target/wheels/*.whl - - name: test cross compiling windows abi3 wheel + - name: test cross compiling windows wheel if: matrix.os == 'ubuntu-latest' run: | sudo apt-get install -y mingw-w64 llvm rustup target add x86_64-pc-windows-gnu rustup target add x86_64-pc-windows-msvc + + # abi3 cargo run -- build --no-sdist -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-gnu cargo run -- build --no-sdist -m test-crates/pyo3-pure/Cargo.toml --target x86_64-pc-windows-msvc + + # no-abi3 + cargo run -- build --no-sdist -i python3.9 -m test-crates/pyo3-mixed/Cargo.toml --target x86_64-pc-windows-msvc - name: test compiling with PYO3_CONFIG_FILE shell: bash run: | diff --git a/test-crates/pyo3-mixed/Cargo.lock b/test-crates/pyo3-mixed/Cargo.lock index e20d319d6..08a77ee0f 100644 --- a/test-crates/pyo3-mixed/Cargo.lock +++ b/test-crates/pyo3-mixed/Cargo.lock @@ -14,6 +14,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + [[package]] name = "cfg-if" version = "1.0.0" @@ -103,6 +109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b65b546c35d8a3b1b2f0ddbac7c6a569d759f357f2b9df884f5d6b719152c8" dependencies = [ "once_cell", + "python3-dll-a", "target-lexicon", ] @@ -146,6 +153,15 @@ dependencies = [ "pyo3", ] +[[package]] +name = "python3-dll-a" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "756dc4b8f4f5821cdf8358df7450ae53fdc1099f3bc096196c9d3738deeba1e6" +dependencies = [ + "cc", +] + [[package]] name = "quote" version = "1.0.18" diff --git a/test-crates/pyo3-mixed/Cargo.toml b/test-crates/pyo3-mixed/Cargo.toml index 6dd679236..20de0857f 100644 --- a/test-crates/pyo3-mixed/Cargo.toml +++ b/test-crates/pyo3-mixed/Cargo.toml @@ -6,7 +6,7 @@ description = "Implements a dummy function combining rust and python" edition = "2018" [dependencies] -pyo3 = { version = "0.16.5", features = ["extension-module"] } +pyo3 = { version = "0.16.5", features = ["extension-module", "generate-import-lib"] } [lib] name = "pyo3_mixed"