From 2e76fa453f5f9487eaa50a715bc1d77c22397fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Thu, 18 Feb 2021 09:17:28 +0100 Subject: [PATCH 1/2] maturin: add passthru test that uses maturinBuildHook The test builds the PyO3 word_count example module using maturinBuildHook. The motivation is to have a trivial test that does not regress for reasons unrelated to maturin or hook updates. --- .../tools/rust/maturin/default.nix | 5 +- .../rust/maturin/pyo3-test/Cargo.lock.patch | 688 ++++++++++++++++++ .../tools/rust/maturin/pyo3-test/default.nix | 12 + .../tools/rust/maturin/pyo3-test/generic.nix | 45 ++ 4 files changed, 749 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/tools/rust/maturin/pyo3-test/Cargo.lock.patch create mode 100644 pkgs/development/tools/rust/maturin/pyo3-test/default.nix create mode 100644 pkgs/development/tools/rust/maturin/pyo3-test/generic.nix diff --git a/pkgs/development/tools/rust/maturin/default.nix b/pkgs/development/tools/rust/maturin/default.nix index 52993b3790d8..ea39efdd163f 100644 --- a/pkgs/development/tools/rust/maturin/default.nix +++ b/pkgs/development/tools/rust/maturin/default.nix @@ -1,4 +1,5 @@ -{ lib +{ callPackage +, lib , stdenv , fetchFromGitHub , rustPlatform @@ -28,6 +29,8 @@ rustPlatform.buildRustPackage rec { # Requires network access, fails in sandbox. doCheck = false; + passthru.tests.pyo3 = callPackage ./pyo3-test {}; + meta = with lib; { description = "Build and publish Rust crates Python packages"; longDescription = '' diff --git a/pkgs/development/tools/rust/maturin/pyo3-test/Cargo.lock.patch b/pkgs/development/tools/rust/maturin/pyo3-test/Cargo.lock.patch new file mode 100644 index 000000000000..3aca2e4803a9 --- /dev/null +++ b/pkgs/development/tools/rust/maturin/pyo3-test/Cargo.lock.patch @@ -0,0 +1,688 @@ +diff --git a/Cargo.lock b/Cargo.lock +new file mode 100644 +index 000000000..5e698d4ff +--- /dev/null ++++ b/Cargo.lock +@@ -0,0 +1,682 @@ ++# This file is automatically @generated by Cargo. ++# It is not intended for manual editing. ++[[package]] ++name = "ahash" ++version = "0.4.7" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" ++ ++[[package]] ++name = "assert_approx_eq" ++version = "1.1.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "3c07dab4369547dbe5114677b33fbbf724971019f3818172d59a97a61c774ffd" ++ ++[[package]] ++name = "autocfg" ++version = "1.0.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" ++ ++[[package]] ++name = "bitflags" ++version = "1.2.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" ++ ++[[package]] ++name = "byteorder" ++version = "1.4.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" ++ ++[[package]] ++name = "cfg-if" ++version = "1.0.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" ++ ++[[package]] ++name = "const_fn" ++version = "0.4.5" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" ++ ++[[package]] ++name = "crossbeam-channel" ++version = "0.5.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" ++dependencies = [ ++ "cfg-if", ++ "crossbeam-utils", ++] ++ ++[[package]] ++name = "crossbeam-deque" ++version = "0.8.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" ++dependencies = [ ++ "cfg-if", ++ "crossbeam-epoch", ++ "crossbeam-utils", ++] ++ ++[[package]] ++name = "crossbeam-epoch" ++version = "0.9.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" ++dependencies = [ ++ "cfg-if", ++ "const_fn", ++ "crossbeam-utils", ++ "lazy_static", ++ "memoffset", ++ "scopeguard", ++] ++ ++[[package]] ++name = "crossbeam-utils" ++version = "0.8.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" ++dependencies = [ ++ "autocfg", ++ "cfg-if", ++ "lazy_static", ++] ++ ++[[package]] ++name = "ctor" ++version = "0.1.19" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "e8f45d9ad417bcef4817d614a501ab55cdd96a6fdb24f49aab89a54acfd66b19" ++dependencies = [ ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "either" ++version = "1.6.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" ++ ++[[package]] ++name = "getrandom" ++version = "0.1.16" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" ++dependencies = [ ++ "cfg-if", ++ "libc", ++ "wasi", ++] ++ ++[[package]] ++name = "ghost" ++version = "0.1.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "1a5bcf1bbeab73aa4cf2fde60a846858dc036163c7c33bec309f8d17de785479" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "glob" ++version = "0.3.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" ++ ++[[package]] ++name = "hashbrown" ++version = "0.9.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" ++dependencies = [ ++ "ahash", ++] ++ ++[[package]] ++name = "hermit-abi" ++version = "0.1.18" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" ++dependencies = [ ++ "libc", ++] ++ ++[[package]] ++name = "indoc" ++version = "0.3.6" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" ++dependencies = [ ++ "indoc-impl", ++ "proc-macro-hack", ++] ++ ++[[package]] ++name = "indoc-impl" ++version = "0.3.6" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" ++dependencies = [ ++ "proc-macro-hack", ++ "proc-macro2", ++ "quote", ++ "syn", ++ "unindent", ++] ++ ++[[package]] ++name = "instant" ++version = "0.1.9" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" ++dependencies = [ ++ "cfg-if", ++] ++ ++[[package]] ++name = "inventory" ++version = "0.1.10" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "0f0f7efb804ec95e33db9ad49e4252f049e37e8b0a4652e3cd61f7999f2eff7f" ++dependencies = [ ++ "ctor", ++ "ghost", ++ "inventory-impl", ++] ++ ++[[package]] ++name = "inventory-impl" ++version = "0.1.10" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "75c094e94816723ab936484666968f5b58060492e880f3c8d00489a1e244fa51" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "itoa" ++version = "0.4.7" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" ++ ++[[package]] ++name = "lazy_static" ++version = "1.4.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" ++ ++[[package]] ++name = "libc" ++version = "0.2.86" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" ++ ++[[package]] ++name = "lock_api" ++version = "0.4.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" ++dependencies = [ ++ "scopeguard", ++] ++ ++[[package]] ++name = "memoffset" ++version = "0.6.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" ++dependencies = [ ++ "autocfg", ++] ++ ++[[package]] ++name = "num-bigint" ++version = "0.3.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "5e9a41747ae4633fce5adffb4d2e81ffc5e89593cb19917f8fb2cc5ff76507bf" ++dependencies = [ ++ "autocfg", ++ "num-integer", ++ "num-traits", ++] ++ ++[[package]] ++name = "num-complex" ++version = "0.3.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" ++dependencies = [ ++ "num-traits", ++] ++ ++[[package]] ++name = "num-integer" ++version = "0.1.44" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" ++dependencies = [ ++ "autocfg", ++ "num-traits", ++] ++ ++[[package]] ++name = "num-traits" ++version = "0.2.14" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" ++dependencies = [ ++ "autocfg", ++] ++ ++[[package]] ++name = "num_cpus" ++version = "1.13.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" ++dependencies = [ ++ "hermit-abi", ++ "libc", ++] ++ ++[[package]] ++name = "parking_lot" ++version = "0.11.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" ++dependencies = [ ++ "instant", ++ "lock_api", ++ "parking_lot_core", ++] ++ ++[[package]] ++name = "parking_lot_core" ++version = "0.8.3" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" ++dependencies = [ ++ "cfg-if", ++ "instant", ++ "libc", ++ "redox_syscall", ++ "smallvec", ++ "winapi", ++] ++ ++[[package]] ++name = "paste" ++version = "0.1.18" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" ++dependencies = [ ++ "paste-impl", ++ "proc-macro-hack", ++] ++ ++[[package]] ++name = "paste-impl" ++version = "0.1.18" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" ++dependencies = [ ++ "proc-macro-hack", ++] ++ ++[[package]] ++name = "ppv-lite86" ++version = "0.2.10" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" ++ ++[[package]] ++name = "proc-macro-hack" ++version = "0.5.19" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" ++ ++[[package]] ++name = "proc-macro2" ++version = "1.0.24" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" ++dependencies = [ ++ "unicode-xid", ++] ++ ++[[package]] ++name = "proptest" ++version = "0.10.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "12e6c80c1139113c28ee4670dc50cc42915228b51f56a9e407f0ec60f966646f" ++dependencies = [ ++ "bitflags", ++ "byteorder", ++ "lazy_static", ++ "num-traits", ++ "quick-error", ++ "rand", ++ "rand_chacha", ++ "rand_xorshift", ++ "regex-syntax", ++] ++ ++[[package]] ++name = "pyo3" ++version = "0.13.2" ++dependencies = [ ++ "assert_approx_eq", ++ "cfg-if", ++ "ctor", ++ "hashbrown", ++ "indoc", ++ "inventory", ++ "libc", ++ "num-bigint", ++ "num-complex", ++ "parking_lot", ++ "paste", ++ "proptest", ++ "pyo3", ++ "pyo3-macros", ++ "rustversion", ++ "serde", ++ "serde_json", ++ "trybuild", ++ "unindent", ++] ++ ++[[package]] ++name = "pyo3-macros" ++version = "0.13.2" ++dependencies = [ ++ "pyo3-macros-backend", ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "pyo3-macros-backend" ++version = "0.13.2" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "quick-error" ++version = "1.2.3" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" ++ ++[[package]] ++name = "quote" ++version = "1.0.9" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" ++dependencies = [ ++ "proc-macro2", ++] ++ ++[[package]] ++name = "rand" ++version = "0.7.3" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" ++dependencies = [ ++ "getrandom", ++ "libc", ++ "rand_chacha", ++ "rand_core", ++ "rand_hc", ++] ++ ++[[package]] ++name = "rand_chacha" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" ++dependencies = [ ++ "ppv-lite86", ++ "rand_core", ++] ++ ++[[package]] ++name = "rand_core" ++version = "0.5.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" ++dependencies = [ ++ "getrandom", ++] ++ ++[[package]] ++name = "rand_hc" ++version = "0.2.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" ++dependencies = [ ++ "rand_core", ++] ++ ++[[package]] ++name = "rand_xorshift" ++version = "0.2.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" ++dependencies = [ ++ "rand_core", ++] ++ ++[[package]] ++name = "rayon" ++version = "1.5.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" ++dependencies = [ ++ "autocfg", ++ "crossbeam-deque", ++ "either", ++ "rayon-core", ++] ++ ++[[package]] ++name = "rayon-core" ++version = "1.9.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" ++dependencies = [ ++ "crossbeam-channel", ++ "crossbeam-deque", ++ "crossbeam-utils", ++ "lazy_static", ++ "num_cpus", ++] ++ ++[[package]] ++name = "redox_syscall" ++version = "0.2.5" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" ++dependencies = [ ++ "bitflags", ++] ++ ++[[package]] ++name = "regex-syntax" ++version = "0.6.22" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" ++ ++[[package]] ++name = "rustapi-module" ++version = "0.1.0" ++dependencies = [ ++ "pyo3", ++] ++ ++[[package]] ++name = "rustversion" ++version = "1.0.4" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" ++ ++[[package]] ++name = "ryu" ++version = "1.0.5" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" ++ ++[[package]] ++name = "scopeguard" ++version = "1.1.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" ++ ++[[package]] ++name = "serde" ++version = "1.0.123" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" ++dependencies = [ ++ "serde_derive", ++] ++ ++[[package]] ++name = "serde_derive" ++version = "1.0.123" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "serde_json" ++version = "1.0.62" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" ++dependencies = [ ++ "itoa", ++ "ryu", ++ "serde", ++] ++ ++[[package]] ++name = "smallvec" ++version = "1.6.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" ++ ++[[package]] ++name = "syn" ++version = "1.0.60" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "unicode-xid", ++] ++ ++[[package]] ++name = "termcolor" ++version = "1.1.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" ++dependencies = [ ++ "winapi-util", ++] ++ ++[[package]] ++name = "toml" ++version = "0.5.8" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" ++dependencies = [ ++ "serde", ++] ++ ++[[package]] ++name = "trybuild" ++version = "1.0.41" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "99471a206425fba51842a9186315f32d91c56eadc21ea4c21f847b59cf778f8b" ++dependencies = [ ++ "glob", ++ "lazy_static", ++ "serde", ++ "serde_json", ++ "termcolor", ++ "toml", ++] ++ ++[[package]] ++name = "unicode-xid" ++version = "0.2.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" ++ ++[[package]] ++name = "unindent" ++version = "0.1.7" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" ++ ++[[package]] ++name = "wasi" ++version = "0.9.0+wasi-snapshot-preview1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" ++ ++[[package]] ++name = "winapi" ++version = "0.3.9" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" ++dependencies = [ ++ "winapi-i686-pc-windows-gnu", ++ "winapi-x86_64-pc-windows-gnu", ++] ++ ++[[package]] ++name = "winapi-i686-pc-windows-gnu" ++version = "0.4.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" ++ ++[[package]] ++name = "winapi-util" ++version = "0.1.5" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" ++dependencies = [ ++ "winapi", ++] ++ ++[[package]] ++name = "winapi-x86_64-pc-windows-gnu" ++version = "0.4.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" ++ ++[[package]] ++name = "word-count" ++version = "0.1.0" ++dependencies = [ ++ "pyo3", ++ "rayon", ++] diff --git a/pkgs/development/tools/rust/maturin/pyo3-test/default.nix b/pkgs/development/tools/rust/maturin/pyo3-test/default.nix new file mode 100644 index 000000000000..b118309b36d7 --- /dev/null +++ b/pkgs/development/tools/rust/maturin/pyo3-test/default.nix @@ -0,0 +1,12 @@ +{ callPackage +, rustPlatform +}: + +callPackage ./generic.nix { + buildAndTestSubdir = "examples/word-count"; + + nativeBuildInputs = with rustPlatform; [ + cargoSetupHook + maturinBuildHook + ]; +} diff --git a/pkgs/development/tools/rust/maturin/pyo3-test/generic.nix b/pkgs/development/tools/rust/maturin/pyo3-test/generic.nix new file mode 100644 index 000000000000..f82c988fc512 --- /dev/null +++ b/pkgs/development/tools/rust/maturin/pyo3-test/generic.nix @@ -0,0 +1,45 @@ +# Derivation prototype, used by maturin and setuptools-rust +# passthrough tests. + +{ lib +, fetchFromGitHub +, python3Packages +, rustPlatform + +, nativeBuildInputs + +, buildAndTestSubdir ? null +, format ? "pyproject" +, sourceRoot ? "source" +}: + +python3Packages.buildPythonPackage rec { + pname = "word-count"; + version = "0.13.2"; + + src = fetchFromGitHub { + owner = "PyO3"; + repo = "pyo3"; + rev = "v${version}"; + hash = "sha256-NOMrrfo8WjlPhtGxWUOPJS/UDDdbLQRCXR++Zd6JmIA="; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src sourceRoot patches; + name = "${pname}-${version}"; + hash = "sha256-//TmozgWy9zrSpMKX92XdHj4fw/T1Elfgn4YhhR7ot0="; + }; + + patches = [ ./Cargo.lock.patch ]; + + inherit buildAndTestSubdir format nativeBuildInputs sourceRoot; + + pythonImportsCheck = [ "word_count" ]; + + meta = with lib; { + description = "PyO3 word count example"; + homepage = "https://github.com/PyO3/pyo3"; + license = licenses.asl20; + maintainers = [ maintainers.danieldk ]; + }; +} From 3bdae33948e227cf6db84b037fc8788bb49c85d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Thu, 18 Feb 2021 09:23:03 +0100 Subject: [PATCH 2/2] python3Packages.setuptools-rust: add passthru test that uses maturinBuildHook The test builds the PyO3 word_count example module using setuptools-rust. The motivation is to have a trivial test that does not regress for reasons unrelated to setuptools-rust or hook updates. --- .../setuptools-rust/default.nix | 5 ++++- .../setuptools-rust/pyo3-test/default.nix | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/python-modules/setuptools-rust/pyo3-test/default.nix diff --git a/pkgs/development/python-modules/setuptools-rust/default.nix b/pkgs/development/python-modules/setuptools-rust/default.nix index ee4a3b551649..cdf5e5aa27fc 100644 --- a/pkgs/development/python-modules/setuptools-rust/default.nix +++ b/pkgs/development/python-modules/setuptools-rust/default.nix @@ -1,4 +1,5 @@ -{ lib +{ callPackage +, lib , buildPythonPackage , fetchPypi , isPy27 @@ -23,6 +24,8 @@ buildPythonPackage rec { propagatedBuildInputs = [ semantic-version setuptools toml ]; + passthru.tests.pyo3 = callPackage ./pyo3-test {}; + meta = with lib; { description = "Setuptools plugin for Rust support"; homepage = "https://github.com/PyO3/setuptools-rust"; diff --git a/pkgs/development/python-modules/setuptools-rust/pyo3-test/default.nix b/pkgs/development/python-modules/setuptools-rust/pyo3-test/default.nix new file mode 100644 index 000000000000..9af17aa5159c --- /dev/null +++ b/pkgs/development/python-modules/setuptools-rust/pyo3-test/default.nix @@ -0,0 +1,21 @@ +{ callPackage +, rustPlatform +, setuptools-rust +}: + +callPackage ../../../tools/rust/maturin/pyo3-test/generic.nix { + # Isolated builds break for this package, because PyO3 is not + # in the build root of the Python Package: + # + # https://github.com/pypa/pip/issues/6276 + # + format = "setuptools"; + + nativeBuildInputs = [ setuptools-rust ] ++ (with rustPlatform; [ + cargoSetupHook + rust.cargo + rust.rustc + ]); + + sourceRoot = "source/examples/word-count"; +}