From: Tim Orling Date: Wed, 21 Jan 2026 21:07:18 +0000 (-0800) Subject: lib/oeqa/files/maturin: update guessing_game X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a560f901009a65e9621213f6ea72834c2f435a7;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git lib/oeqa/files/maturin: update guessing_game Update to include changes in upstream Maturin Tutorial [1] and for newer Rust and Python. Cargo.toml: * version: 0.1.0 -> 0.3.0 (to align with [2]) * edition: 2021 -> 2024 * Dependencies: - rand: 0.8.5 -> 0.9.0 - pyo3: 0.21.2 -> 0.27.2 - abi3-py38 -> abi3-py39 (Python 3.8 reached EOL in October 2024) pyproject.toml: * restrict maturin to >=1.7 to ensure PyO3 27.0+ and python 3.13+ support src/lib.rs: * rand 0.9 API change: rand::thread_rng() was removed. Use rand::rng() or the convenience function rand::random_range(). * PyO3 0.27 has breaking API changes from 0.21. The #[pymodule] function signature changed from fn module_name(py: Python, m: &PyModule) to fn module_name(m: &Bound<'_, PyModule>). With help from Claude.ai [1] https://www.maturin.rs/tutorial.html [2] https://github.com/moto-timo/guessing-game/releases/tag/v0.3.0 Signed-off-by: Tim Orling Signed-off-by: Antonin Godard Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oeqa/files/maturin/guessing-game/Cargo.toml b/meta/lib/oeqa/files/maturin/guessing-game/Cargo.toml index a78ada2593d..5c0c06db4bc 100644 --- a/meta/lib/oeqa/files/maturin/guessing-game/Cargo.toml +++ b/meta/lib/oeqa/files/maturin/guessing-game/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "guessing-game" -version = "0.1.0" -edition = "2021" +version = "0.3.0" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,10 +11,10 @@ name = "guessing_game" crate-type = ["cdylib"] [dependencies] -rand = "0.8.4" +rand = "0.9.0" [dependencies.pyo3] -version = "0.24.1" -# "abi3-py38" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.8 -features = ["abi3-py38"] +version = "0.27.2" +# "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9 +features = ["abi3-py39"] diff --git a/meta/lib/oeqa/files/maturin/guessing-game/pyproject.toml b/meta/lib/oeqa/files/maturin/guessing-game/pyproject.toml index ff35abc472b..ecd34372a5f 100644 --- a/meta/lib/oeqa/files/maturin/guessing-game/pyproject.toml +++ b/meta/lib/oeqa/files/maturin/guessing-game/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=1.0,<2.0"] +requires = ["maturin>=1.7,<2.0"] build-backend = "maturin" [tool.maturin] diff --git a/meta/lib/oeqa/files/maturin/guessing-game/src/lib.rs b/meta/lib/oeqa/files/maturin/guessing-game/src/lib.rs index 6828466ed1a..0c757c291f1 100644 --- a/meta/lib/oeqa/files/maturin/guessing-game/src/lib.rs +++ b/meta/lib/oeqa/files/maturin/guessing-game/src/lib.rs @@ -7,7 +7,7 @@ use std::io; fn guess_the_number() { println!("Guess the number!"); - let secret_number = rand::thread_rng().gen_range(1..101); + let secret_number = rand::rng().random_range(1..101); loop { println!("Please input your guess."); @@ -40,7 +40,7 @@ fn guess_the_number() { /// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to /// import the module. #[pymodule] -fn guessing_game(_py: Python, m: &PyModule) -> PyResult<()> { +fn guessing_game(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(guess_the_number, m)?)?; Ok(())