Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-maturin for openSUSE:Factory checked in at 2023-01-09 17:23:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-maturin (Old) and /work/SRC/openSUSE:Factory/.python-maturin.new.32243 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-maturin" Mon Jan 9 17:23:35 2023 rev:23 rq:1056955 version:0.14.8 Changes: -------- --- /work/SRC/openSUSE:Factory/python-maturin/python-maturin.changes 2022-12-22 16:22:13.389735747 +0100 +++ /work/SRC/openSUSE:Factory/.python-maturin.new.32243/python-maturin.changes 2023-01-09 17:23:38.107101594 +0100 @@ -1,0 +2,9 @@ +Mon Jan 9 01:59:53 UTC 2023 - Mia Herkt <m...@0x0.st> + +- Update to v0.14.8: + * Add support for packaging multiple pure Python packages + gh#PyO3/maturin#1378 + * Fallback to sysconfig interpreters for pyo3 bindings + gh#PyO3/maturin#1381 + +------------------------------------------------------------------- Old: ---- maturin-0.14.7.tar.gz New: ---- maturin-0.14.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-maturin.spec ++++++ --- /var/tmp/diff_new_pack.q5HXcW/_old 2023-01-09 17:23:39.359108678 +0100 +++ /var/tmp/diff_new_pack.q5HXcW/_new 2023-01-09 17:23:39.363108702 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-maturin # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-maturin -Version: 0.14.7 +Version: 0.14.8 Release: 0 Summary: Rust/Python Interoperability License: Apache-2.0 OR MIT ++++++ maturin-0.14.7.tar.gz -> maturin-0.14.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/Cargo.lock new/maturin-0.14.8/Cargo.lock --- old/maturin-0.14.7/Cargo.lock 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/Cargo.lock 2022-12-31 14:11:09.000000000 +0100 @@ -303,9 +303,9 @@ [[package]] name = "cargo-zigbuild" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364c8bae773d8879ae9ea3bf63e7c052b3e47c095e871f03027e176489df5477" +checksum = "b56c289fa331582c3637f30a066fdd442fa7e7388541d97e76bc9a15d5688096" dependencies = [ "anyhow", "cargo-options", @@ -398,9 +398,9 @@ [[package]] name = "chunked_transfer" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e" +checksum = "cca491388666e04d7248af3f60f0c40cfb0991c72205595d7c396e3510207d1a" [[package]] name = "cipher" @@ -413,9 +413,9 @@ [[package]] name = "clap" -version = "4.0.29" +version = "4.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" +checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" dependencies = [ "bitflags", "clap_derive", @@ -424,14 +424,14 @@ "once_cell", "strsim", "termcolor", - "terminal_size 0.2.3", + "terminal_size", ] [[package]] name = "clap_complete" -version = "4.0.6" +version = "4.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3c9eae0de7bf8e3f904a5e40612b21fb2e2e566456d177809a48b892d24da" +checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b" dependencies = [ "clap", ] @@ -490,16 +490,6 @@ ] [[package]] -name = "combine" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" -dependencies = [ - "bytes", - "memchr", -] - -[[package]] name = "concolor" version = "0.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -533,16 +523,15 @@ [[package]] name = "console" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +checksum = "5556015fe3aad8b968e5d4124980fbe2f6aaee7aeec6b749de1faaa2ca5d0a4c" dependencies = [ "encode_unicode", "lazy_static", "libc", - "terminal_size 0.1.17", "unicode-width", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -1147,15 +1136,6 @@ [[package]] name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" @@ -1276,11 +1256,11 @@ [[package]] name = "is-terminal" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" +checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi", "io-lifetimes", "rustix", "windows-sys 0.42.0", @@ -1341,9 +1321,9 @@ [[package]] name = "libc" -version = "0.2.138" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "linux-raw-sys" @@ -1398,7 +1378,7 @@ [[package]] name = "maturin" -version = "0.14.7" +version = "0.14.8" dependencies = [ "anyhow", "base64", @@ -1600,6 +1580,15 @@ ] [[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + +[[package]] name = "normalize-line-endings" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1702,11 +1691,11 @@ [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi", "libc", ] @@ -1718,9 +1707,9 @@ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "opaque-debug" @@ -1730,9 +1719,9 @@ [[package]] name = "openssl" -version = "0.10.44" +version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ "bitflags", "cfg-if", @@ -1771,9 +1760,9 @@ [[package]] name = "openssl-sys" -version = "0.9.79" +version = "0.9.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" dependencies = [ "autocfg", "cc", @@ -1921,9 +1910,9 @@ [[package]] name = "portable-atomic" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bdd679d533107e090c2704a35982fc06302e30898e63ffa26a81155c012e92" +checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" [[package]] name = "ppv-lite86" @@ -2210,9 +2199,9 @@ [[package]] name = "rustix" -version = "0.36.5" +version = "0.36.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588" +checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549" dependencies = [ "bitflags", "errno", @@ -2361,18 +2350,18 @@ [[package]] name = "serde" -version = "1.0.151" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.151" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -2599,16 +2588,6 @@ [[package]] name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "terminal_size" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb20089a8ba2b69debd491f8d2d023761cbf196e999218c591fa1e7e15a21907" @@ -2728,13 +2707,13 @@ [[package]] name = "toml_edit" -version = "0.15.0" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1541ba70885967e662f69d31ab3aeca7b1aaecfcd58679590b893e9239c3646" +checksum = "dd30deba9a1cd7153c22aecf93e86df639e7b81c622b0af8d9255e989991a7b7" dependencies = [ - "combine", "indexmap", "itertools", + "nom8", "serde", "toml_datetime", ] @@ -2816,9 +2795,9 @@ [[package]] name = "trycmd" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e381af441e13a3635303d26769620a9454aef05ec3303711efc3f1dd785a33af" +checksum = "cd0b37ad14571d245340fb1d56cec65507bd73571005adc63dc968aa38fa9d49" dependencies = [ "glob", "humantime", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/Cargo.toml new/maturin-0.14.8/Cargo.toml --- old/maturin-0.14.7/Cargo.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/maturin-0.14.8/Cargo.toml 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +1,7 @@ [package] authors = ["konstin <kons...@mailbox.org>", "messense <messe...@icloud.com>"] name = "maturin" -version = "0.14.7" +version = "0.14.8" description = "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages" exclude = ["test-crates/**/*", "sysconfig/*", "test-data/*", "ci/*", "tests/*", "guide/*", ".github/*"] homepage = "https://github.com/pyo3/maturin" @@ -38,7 +38,7 @@ sha2 = "0.10.3" tar = "0.4.38" tempfile = "3.2.0" -toml_edit = { version = "0.15.0", features = ["easy"] } +toml_edit = { version = "0.16.0", features = ["easy"] } zip = { version = "0.6.1", default-features = false, features = ["bzip2", "deflate", "time"] } thiserror = "1.0.37" dirs = "4.0.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/Changelog.md new/maturin-0.14.8/Changelog.md --- old/maturin-0.14.7/Changelog.md 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/Changelog.md 2022-12-31 14:11:09.000000000 +0100 @@ -7,6 +7,11 @@ ## [Unreleased] +## [0.14.8] - 2022-12-31 + +* Add support for packaging multiple pure Python packages in [#1378](https://github.com/PyO3/maturin/pull/1378) +* Fallback to sysconfig interpreters for pyo3 bindings in [#1381](https://github.com/PyO3/maturin/pull/1381) + ## [0.14.7] - 2022-12-20 * Add workspace lock file to sdist as a fallback in [#1362](https://github.com/PyO3/maturin/pull/1362) @@ -786,7 +791,8 @@ * Initial Release -[Unreleased]: https://github.com/pyo3/maturin/compare/v0.14.7...HEAD +[Unreleased]: https://github.com/pyo3/maturin/compare/v0.14.8...HEAD +[0.14.8]: https://github.com/pyo3/maturin/compare/v0.14.7...v0.14.8 [0.14.7]: https://github.com/pyo3/maturin/compare/v0.14.6...v0.14.7 [0.14.6]: https://github.com/pyo3/maturin/compare/v0.14.5...v0.14.6 [0.14.5]: https://github.com/pyo3/maturin/compare/v0.14.4...v0.14.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/PKG-INFO new/maturin-0.14.8/PKG-INFO --- old/maturin-0.14.7/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/maturin-0.14.8/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +1,15 @@ Metadata-Version: 2.1 Name: maturin -Version: 0.14.7 +Version: 0.14.8 Classifier: Topic :: Software Development :: Build Tools Classifier: Programming Language :: Rust Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Requires-Dist: tomli>=1.1.0 ; python_version<'3.11' -Requires-Dist: ziglang~=0.10.0; extra == 'zig' Requires-Dist: patchelf; extra == 'patchelf' -Provides-Extra: zig +Requires-Dist: ziglang~=0.10.0; extra == 'zig' Provides-Extra: patchelf +Provides-Extra: zig Summary: Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages Keywords: python,cffi,packaging,pypi,pyo3 Home-Page: https://github.com/pyo3/maturin @@ -18,16 +18,16 @@ License: MIT OR Apache-2.0 Requires-Python: >=3.7 Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM +Project-URL: Source Code, https://github.com/PyO3/maturin Project-URL: Changelog, https://maturin.rs/changelog.html Project-URL: Issues, https://github.com/PyO3/maturin/issues -Project-URL: Source Code, https://github.com/PyO3/maturin Project-URL: Documentation, https://maturin.rs # Maturin _formerly pyo3-pack_ -[](https://github.com/PyO3/maturin/actions) +[](https://github.com/PyO3/maturin/actions) [](https://cirrus-ci.com/github/PyO3/maturin) [](https://app.bors.tech/repositories/55651) [](https://crates.io/crates/maturin) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/README.md new/maturin-0.14.8/README.md --- old/maturin-0.14.7/README.md 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/README.md 2022-12-31 14:11:09.000000000 +0100 @@ -2,7 +2,7 @@ _formerly pyo3-pack_ -[](https://github.com/PyO3/maturin/actions) +[](https://github.com/PyO3/maturin/actions) [](https://cirrus-ci.com/github/PyO3/maturin) [](https://app.bors.tech/repositories/55651) [](https://crates.io/crates/maturin) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/build_context.rs new/maturin-0.14.8/src/build_context.rs --- old/maturin-0.14.7/src/build_context.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/build_context.rs 2022-12-31 14:11:09.000000000 +0100 @@ -925,16 +925,18 @@ self.excludes(Format::Wheel)?, )?; - if let Some(python_module) = &self.project_layout.python_module { - if self.target.is_wasi() { - // TODO: Can we have python code and the wasm launchers coexisting - // without clashes? - bail!("Sorry, adding python code to a wasm binary is currently not supported") - } - if !self.editable { - write_python_part(&mut writer, python_module, self.pyproject_toml.as_ref()) - .context("Failed to add the python module to the package")?; - } + if self.project_layout.python_module.is_some() && self.target.is_wasi() { + // TODO: Can we have python code and the wasm launchers coexisting + // without clashes? + bail!("Sorry, adding python code to a wasm binary is currently not supported") + } + if !self.editable { + write_python_part( + &mut writer, + &self.project_layout, + self.pyproject_toml.as_ref(), + ) + .context("Failed to add the python module to the package")?; } let mut artifacts_ref = Vec::with_capacity(artifacts.len()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/build_options.rs new/maturin-0.14.8/src/build_options.rs --- old/maturin-0.14.7/src/build_options.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/build_options.rs 2022-12-31 14:11:09.000000000 +0100 @@ -13,6 +13,7 @@ use std::env; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; +use tracing::debug; // This is used for BridgeModel::Bindings("pyo3-ffi") and BridgeModel::Bindings("pyo3"). // These should be treated almost identically but must be correctly identified @@ -218,7 +219,6 @@ ) -> Result<Vec<PythonInterpreter>> { match bridge { BridgeModel::Bindings(binding_name, _) | BridgeModel::Bin(Some((binding_name, _))) => { - let mut native_interpreters = false; let mut interpreters = Vec::new(); if let Some(config_file) = env::var_os("PYO3_CONFIG_FILE") { if !binding_name.starts_with("pyo3") { @@ -307,25 +307,12 @@ interpreters = find_interpreter_in_sysconfig(interpreter, target, min_python_minor)?; } + } else if binding_name.starts_with("pyo3") { + // Only pyo3/pyo3-ffi bindings supports bundled sysconfig interpreters + interpreters = find_interpreter(bridge, interpreter, target, min_python_minor)?; } else { - match find_interpreter_in_host(bridge, interpreter, target, min_python_minor) { - Ok(host_interps) => { - interpreters = host_interps; - native_interpreters = true; - } - Err(err) => { - if binding_name.starts_with("pyo3") && target.is_unix() { - interpreters = find_interpreter_in_sysconfig( - interpreter, - target, - min_python_minor, - ) - .map_err(|_| err)?; - } else { - return Err(err); - } - } - } + interpreters = + find_interpreter_in_host(bridge, interpreter, target, min_python_minor)?; } let interpreters_str = interpreters @@ -333,11 +320,7 @@ .map(ToString::to_string) .collect::<Vec<String>>() .join(", "); - if native_interpreters { - println!("ð Found {}", interpreters_str); - } else { - println!("ð Found cross compiling target {}", interpreters_str); - } + println!("ð Found {}", interpreters_str); Ok(interpreters) } @@ -994,6 +977,43 @@ Ok(interpreter) } +/// Find python interpreters in host machine first, +/// fallback to bundled sysconfig if not found in host machine +fn find_interpreter( + bridge: &BridgeModel, + interpreter: &[PathBuf], + target: &Target, + min_python_minor: Option<usize>, +) -> Result<Vec<PythonInterpreter>> { + let mut interpreters = Vec::new(); + if !interpreter.is_empty() { + let mut missing = Vec::new(); + for interp in interpreter { + match PythonInterpreter::check_executable(interp.clone(), target, bridge) { + Ok(Some(interp)) => interpreters.push(interp), + _ => missing.push(interp.clone()), + } + } + if !missing.is_empty() { + let sysconfig_interps = + find_interpreter_in_sysconfig(&missing, target, min_python_minor)?; + interpreters.extend(sysconfig_interps); + } + } else { + interpreters = PythonInterpreter::find_all(target, bridge, min_python_minor) + .context("Finding python interpreters failed")?; + }; + + if interpreters.is_empty() { + if let Some(minor) = min_python_minor { + bail!("Couldn't find any python interpreters with version >= 3.{}. Please specify at least one with -i", minor); + } else { + bail!("Couldn't find any python interpreters. Please specify at least one with -i"); + } + } + Ok(interpreters) +} + /// Find python interpreters in the host machine fn find_interpreter_in_host( bridge: &BridgeModel, @@ -1070,7 +1090,16 @@ python_impl, (ver_major, ver_minor), ) - .context("Failed to find a python interpreter")?; + .with_context(|| { + format!( + "Failed to find a {} {}.{} interpreter", + python_impl, ver_major, ver_minor + ) + })?; + debug!( + "Found {} {}.{} in bundled sysconfig", + sysconfig.interpreter_kind, sysconfig.major, sysconfig.minor, + ); interpreters.push(PythonInterpreter::from_config(sysconfig.clone())); } Ok(interpreters) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/module_writer.rs new/maturin-0.14.8/src/module_writer.rs --- old/maturin-0.14.7/src/module_writer.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/module_writer.rs 2022-12-31 14:11:09.000000000 +0100 @@ -295,15 +295,15 @@ project_layout: &ProjectLayout, metadata21: &Metadata21, ) -> Result<()> { - if let Some(python_module) = &project_layout.python_module { - let absolute_path = python_module.normalize()?.into_path_buf(); - if let Some(python_path) = absolute_path.parent().and_then(|p| p.to_str()) { + if project_layout.python_module.is_some() || !project_layout.python_packages.is_empty() { + let absolute_path = project_layout.python_dir.normalize()?.into_path_buf(); + if let Some(python_path) = absolute_path.to_str() { let name = metadata21.get_distribution_escaped(); let target = format!("{}.pth", name); debug!("Adding {} from {}", target, python_path); self.add_bytes(target, python_path.as_bytes())?; } else { - println!("â ï¸ source code path contains non-Unicode sequences, editable installs may not work."); + eprintln!("â ï¸ source code path contains non-Unicode sequences, editable installs may not work."); } } Ok(()) @@ -720,6 +720,10 @@ } }; + if !editable { + write_python_part(writer, project_layout, pyproject_toml) + .context("Failed to add the python module to the package")?; + } if let Some(python_module) = &project_layout.python_module { if editable { let target = project_layout.rust_module.join(&so_filename); @@ -735,9 +739,6 @@ target.display() ))?; } else { - write_python_part(writer, python_module, pyproject_toml) - .context("Failed to add the python module to the package")?; - let relative = project_layout .rust_module .strip_prefix(python_module.parent().unwrap()) @@ -789,14 +790,13 @@ ) -> Result<()> { let cffi_declarations = generate_cffi_declarations(crate_dir, target_dir, python)?; - let module; + if !editable { + write_python_part(writer, project_layout, pyproject_toml) + .context("Failed to add the python module to the package")?; + } + let module; if let Some(python_module) = &project_layout.python_module { - if !editable { - write_python_part(writer, python_module, pyproject_toml) - .context("Failed to add the python module to the package")?; - } - if editable { let base_path = python_module.join(module_name); fs::create_dir_all(&base_path)?; @@ -957,14 +957,13 @@ } = generate_uniffi_bindings(crate_dir, target_dir, target_os)?; let py_init = format!("from .{} import * # NOQA\n", binding_name); - let module; + if !editable { + write_python_part(writer, project_layout, pyproject_toml) + .context("Failed to add the python module to the package")?; + } + let module; if let Some(python_module) = &project_layout.python_module { - if !editable { - write_python_part(writer, python_module, pyproject_toml) - .context("Failed to add the python module to the package")?; - } - if editable { let base_path = python_module.join(module_name); fs::create_dir_all(&base_path)?; @@ -1096,34 +1095,47 @@ /// Adds the python part of a mixed project to the writer, pub fn write_python_part( writer: &mut impl ModuleWriter, - python_module: impl AsRef<Path>, + project_layout: &ProjectLayout, pyproject_toml: Option<&PyProjectToml>, ) -> Result<()> { - let python_module = python_module.as_ref(); - for absolute in WalkBuilder::new(python_module).hidden(false).build() { - let absolute = absolute?.into_path(); - let relative = absolute - .strip_prefix(python_module.parent().unwrap()) - .unwrap(); - if absolute.is_dir() { - writer.add_directory(relative)?; - } else { - // Ignore native libraries from develop, if any - if let Some(extension) = relative.extension() { - if extension.to_string_lossy() == "so" { - debug!("Ignoring native library {}", relative.display()); - continue; + let python_dir = &project_layout.python_dir; + let mut python_packages = Vec::new(); + if let Some(python_module) = project_layout.python_module.as_ref() { + python_packages.push(python_module.to_path_buf()); + } + for package in &project_layout.python_packages { + let package_path = python_dir.join(package); + if python_packages.iter().any(|p| *p == package_path) { + continue; + } + python_packages.push(package_path); + } + + for package in python_packages { + for absolute in WalkBuilder::new(package).hidden(false).build() { + let absolute = absolute?.into_path(); + let relative = absolute.strip_prefix(python_dir).unwrap(); + if absolute.is_dir() { + writer.add_directory(relative)?; + } else { + // Ignore native libraries from develop, if any + if let Some(extension) = relative.extension() { + if extension.to_string_lossy() == "so" { + debug!("Ignoring native library {}", relative.display()); + continue; + } } + writer + .add_file(relative, &absolute) + .context(format!("File to add file from {}", absolute.display()))?; } - writer - .add_file(relative, &absolute) - .context(format!("File to add file from {}", absolute.display()))?; } } // Include additional files if let Some(pyproject) = pyproject_toml { - let pyproject_dir = python_module.parent().unwrap(); + // FIXME: in src-layout pyproject.toml isn't located directly in python dir + let pyproject_dir = python_dir; if let Some(glob_patterns) = pyproject.include() { for pattern in glob_patterns .iter() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/project_layout.rs new/maturin-0.14.8/src/project_layout.rs --- old/maturin-0.14.7/src/project_layout.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/project_layout.rs 2022-12-31 14:11:09.000000000 +0100 @@ -3,6 +3,7 @@ use anyhow::{bail, format_err, Context, Result}; use cargo_metadata::{Metadata, MetadataCommand}; use normpath::PathExt as _; +use std::collections::HashSet; use std::env; use std::io; use std::path::{Path, PathBuf}; @@ -13,10 +14,14 @@ /// Whether this project is pure rust or rust mixed with python and whether it has wheel data #[derive(Clone, Debug, PartialEq, Eq)] pub struct ProjectLayout { + /// Contains the absolute path to the python source directory + pub python_dir: PathBuf, /// Contains the canonicalized (i.e. absolute) path to the python part of the project /// If none, we have a rust crate compiled into a shared library with only some glue python for cffi /// If some, we have a python package that is extended by a native rust module. pub python_module: Option<PathBuf>, + /// Python packages to include + pub python_packages: Vec<String>, /// Contains the canonicalized (i.e. absolute) path to the rust part of the project pub rust_module: PathBuf, /// Rust extension name @@ -135,6 +140,10 @@ } else { manifest_dir }; + let python_packages = pyproject + .and_then(|x| x.python_packages()) + .unwrap_or_default() + .to_vec(); let py_root = match pyproject.and_then(|x| x.python_source()) { Some(py_src) => project_root.join(py_src), None => match extra_metadata.python_source.as_ref() { @@ -145,14 +154,21 @@ None => match pyproject.and_then(|x| x.project_name()) { Some(project_name) => { // Detect src layout - let import_name = project_name.replace('-', "_"); let rust_cargo_toml_found = project_root.join("rust").join("Cargo.toml").is_file(); - let python_src_found = project_root - .join("src") - .join(import_name) - .join("__init__.py") - .is_file(); + let import_name = project_name.replace('-', "_"); + let mut package_init = HashSet::new(); + package_init.insert( + project_root + .join("src") + .join(import_name) + .join("__init__.py"), + ); + for package in &python_packages { + package_init + .insert(project_root.join("src").join(package).join("__init__.py")); + } + let python_src_found = package_init.iter().any(|x| x.is_file()); if rust_cargo_toml_found && python_src_found { project_root.join("src") } else { @@ -180,7 +196,8 @@ } }), }; - let project_layout = ProjectLayout::determine(project_root, extension_name, py_root, data)?; + let project_layout = + ProjectLayout::determine(project_root, extension_name, py_root, python_packages, data)?; Ok(Self { project_layout, cargo_toml_path: manifest_file, @@ -263,12 +280,18 @@ } else if let Some(project_name) = pyproject.project_name() { // Check if python source directory in `src/<project_name>` let import_name = project_name.replace('-', "_"); - if current_dir - .join("src") - .join(import_name) - .join("__init__.py") - .is_file() - { + let mut package_init = HashSet::new(); + package_init.insert( + current_dir + .join("src") + .join(import_name) + .join("__init__.py"), + ); + for package in pyproject.python_packages().unwrap_or_default() { + package_init + .insert(current_dir.join("src").join(package).join("__init__.py")); + } + if package_init.iter().any(|x| x.is_file()) { return Ok((path, pyproject_file)); } } @@ -326,6 +349,7 @@ project_root: impl AsRef<Path>, module_name: &str, python_root: PathBuf, + python_packages: Vec<String>, data: Option<PathBuf>, ) -> Result<ProjectLayout> { // A dot in the module name means the extension module goes into the module folder specified by the path @@ -348,6 +372,7 @@ }; debug!( project_root = %project_root.display(), + python_dir = %python_root.display(), rust_module = %rust_module.display(), python_module = %python_module.display(), extension_name = %extension_name, @@ -375,6 +400,8 @@ println!("ð¹ Building a mixed python/rust project"); Ok(ProjectLayout { + python_dir: python_root, + python_packages, python_module: Some(python_module), rust_module, extension_name, @@ -382,6 +409,8 @@ }) } else { Ok(ProjectLayout { + python_dir: python_root, + python_packages, python_module: None, rust_module: project_root.to_path_buf(), extension_name, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/pyproject_toml.rs new/maturin-0.14.8/src/pyproject_toml.rs --- old/maturin-0.14.7/src/pyproject_toml.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/pyproject_toml.rs 2022-12-31 14:11:09.000000000 +0100 @@ -99,6 +99,8 @@ strip: bool, /// The directory with python module, contains `<module_name>/__init__.py` python_source: Option<PathBuf>, + /// Python packages to include + python_packages: Option<Vec<String>>, /// Path to the wheel directory, defaults to `<module_name>.data` data: Option<PathBuf>, // Some customizable cargo options @@ -219,6 +221,12 @@ .and_then(|maturin| maturin.python_source.as_deref()) } + /// Returns the value of `[tool.maturin.python-packages]` in pyproject.toml + pub fn python_packages(&self) -> Option<&[String]> { + self.maturin() + .and_then(|maturin| maturin.python_packages.as_deref()) + } + /// Returns the value of `[tool.maturin.data]` in pyproject.toml pub fn data(&self) -> Option<&Path> { self.maturin().and_then(|maturin| maturin.data.as_deref()) @@ -302,6 +310,7 @@ [tool.maturin] manylinux = "2010" + python-packages = ["foo", "bar"] manifest-path = "Cargo.toml" profile = "dev" features = ["foo", "bar"] @@ -328,6 +337,10 @@ maturin.rustc_args, Some(vec!["-Z".to_string(), "unstable-options".to_string()]) ); + assert_eq!( + maturin.python_packages, + Some(vec!["foo".to_string(), "bar".to_string()]) + ); } #[test] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/python_interpreter/mod.rs new/maturin-0.14.8/src/python_interpreter/mod.rs --- old/maturin-0.14.7/src/python_interpreter/mod.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/python_interpreter/mod.rs 2022-12-31 14:11:09.000000000 +0100 @@ -11,6 +11,7 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::str::{self, FromStr}; +use tracing::debug; mod config; @@ -613,6 +614,10 @@ .context(String::from_utf8_lossy(&output.stdout).trim().to_string())?; if (message.major == 2 && message.minor != 7) || (message.major == 3 && message.minor < 5) { + debug!( + "Skipping outdated python interpreter '{}'", + executable.as_ref().display() + ); return Ok(None); } @@ -636,6 +641,15 @@ Some(message.platform.to_lowercase().replace(['-', '.'], "_")) }; + let executable = message + .executable + .map(PathBuf::from) + .unwrap_or_else(|| executable.as_ref().to_path_buf()); + debug!( + "Found {} interpreter at {}", + interpreter, + executable.display() + ); Ok(Some(PythonInterpreter { config: InterpreterConfig { major: message.major, @@ -648,10 +662,7 @@ abi_tag: message.abi_tag, pointer_width: None, }, - executable: message - .executable - .map(PathBuf::from) - .unwrap_or_else(|| executable.as_ref().to_path_buf()), + executable, platform, runnable: true, implmentation_name: message.implementation_name, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/maturin-0.14.7/src/source_distribution.rs new/maturin-0.14.8/src/source_distribution.rs --- old/maturin-0.14.7/src/source_distribution.rs 2022-12-20 10:56:19.000000000 +0100 +++ new/maturin-0.14.8/src/source_distribution.rs 2022-12-31 14:11:09.000000000 +0100 @@ -620,8 +620,20 @@ let pyproject_dir = pyproject_toml_path.parent().unwrap(); // Add python source files - if let Some(python_source) = build_context.project_layout.python_module.as_ref() { - for entry in ignore::Walk::new(python_source) { + let mut python_packages = Vec::new(); + if let Some(python_module) = build_context.project_layout.python_module.as_ref() { + python_packages.push(python_module.to_path_buf()); + } + for package in &build_context.project_layout.python_packages { + let package_path = build_context.project_layout.python_dir.join(package); + if python_packages.iter().any(|p| *p == package_path) { + continue; + } + python_packages.push(package_path); + } + + for package in python_packages { + for entry in ignore::Walk::new(package) { let source = entry?.into_path(); // Technically, `ignore` crate should handle this, // but somehow it doesn't on Alpine Linux running in GitHub Actions, ++++++ vendor.tar.xz ++++++ /work/SRC/openSUSE:Factory/python-maturin/vendor.tar.xz /work/SRC/openSUSE:Factory/.python-maturin.new.32243/vendor.tar.xz differ: char 27, line 1