Package: python-cotengrust Version: 0.2.0-1 We hope to update rust-rand to version 0.10 soon, python-cotengrust will need a small adjustment for the new version, removing the rand 0.8 related changes and adding some minor changes for rand 0.10.
While working on the update, I noticed a couple of other issues, firstly the clean target was broken. Secondly the pyo3 related changes in "002-fix-rand-PyO3-api.patch" fix the build with 0.25 but break it with 0.28. Since debian currently has 0.27 and will probablly update to 0.28 at some time in the not too distant future I think these changes have outlived their usefulness.
diff -Nru python-cotengrust-0.2.0/debian/changelog python-cotengrust-0.2.0/debian/changelog --- python-cotengrust-0.2.0/debian/changelog 2025-10-13 02:01:45.000000000 +0000 +++ python-cotengrust-0.2.0/debian/changelog 2026-03-14 10:24:29.000000000 +0000 @@ -1,3 +1,14 @@ +python-cotengrust (0.2.0-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Drop 002-fix-rand-PyO3-api.patch + * Add patch 002-rand-0.10.patch + * Establish minimum pyo3 version as 0.26 + * Establish minimum rand version as 0.10 + * Fix clean target. + + -- Peter Michael Green <[email protected]> Sat, 14 Mar 2026 10:24:29 +0000 + python-cotengrust (0.2.0-1) unstable; urgency=medium * New upstream version 0.2.0. diff -Nru python-cotengrust-0.2.0/debian/control python-cotengrust-0.2.0/debian/control --- python-cotengrust-0.2.0/debian/control 2025-10-13 02:01:45.000000000 +0000 +++ python-cotengrust-0.2.0/debian/control 2026-03-14 10:24:29.000000000 +0000 @@ -12,8 +12,8 @@ librust-bit-set-dev, librust-ordered-float-dev, librust-pep440-rs-dev, - librust-pyo3-dev, - librust-rand-dev, + librust-pyo3-dev (>= 0.26), + librust-rand-dev (>= 0.10), librust-rustc-hash-dev, pybuild-plugin-pyproject, python3-all, diff -Nru python-cotengrust-0.2.0/debian/patches/001-relax-cargo-depends.patch python-cotengrust-0.2.0/debian/patches/001-relax-cargo-depends.patch --- python-cotengrust-0.2.0/debian/patches/001-relax-cargo-depends.patch 2025-10-13 02:01:45.000000000 +0000 +++ python-cotengrust-0.2.0/debian/patches/001-relax-cargo-depends.patch 2026-03-14 10:24:29.000000000 +0000 @@ -5,8 +5,10 @@ Author: Yogeswaran Umasankar <[email protected]> Last-Update: 2025-10-12 ---- a/Cargo.toml -+++ b/Cargo.toml +Index: python-cotengrust-0.2.0.new/Cargo.toml +=================================================================== +--- python-cotengrust-0.2.0.new.orig/Cargo.toml ++++ python-cotengrust-0.2.0.new/Cargo.toml @@ -9,12 +9,12 @@ name = "cotengrust" crate-type = ["cdylib"] @@ -15,13 +17,12 @@ -num-traits = "0.2" -ordered-float = "5.1" -pyo3 = "0.26" --rand = "0.9" --rustc-hash = "2.1" +bit-set = "*" +num-traits = "*" +ordered-float = "*" -+pyo3 = "*" -+rand = "*" ++pyo3 = ">= 0.26" + rand = "0.9" +-rustc-hash = "2.1" +rustc-hash = "*" [profile.release] diff -Nru python-cotengrust-0.2.0/debian/patches/002-fix-rand-PyO3-api.patch python-cotengrust-0.2.0/debian/patches/002-fix-rand-PyO3-api.patch --- python-cotengrust-0.2.0/debian/patches/002-fix-rand-PyO3-api.patch 2025-10-13 02:01:45.000000000 +0000 +++ python-cotengrust-0.2.0/debian/patches/002-fix-rand-PyO3-api.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -Description: Fix rand and PyO3 API incompatibilities - This fix is for using the rand and PyO3 crates available - in Debian. It resolves build failures under maturin and - dpkg-buildpackage. -Forwarded: not-needed -Author: Yogeswaran Umasankar <[email protected]> -Last-Update: 2025-10-12 - ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -2,8 +2,8 @@ use bit_set::BitSet; - use num_traits::{AsPrimitive, Bounded, PrimInt}; - use ordered_float::OrderedFloat; - use pyo3::prelude::*; --use rand::Rng; --use rand::SeedableRng; -+use rand::{Rng, SeedableRng}; -+use rand::rngs::{OsRng, StdRng}; - use rustc_hash::FxHashMap; - use std::collections::{BTreeSet, BinaryHeap, HashSet}; - use std::f32; -@@ -467,7 +467,7 @@ impl<Ix: IndexType, Node: NodeType> Cont - let mut rng = if coeff_t != 0.0 { - Some(match seed { - Some(seed) => rand::rngs::StdRng::seed_from_u64(seed), -- None => rand::rngs::StdRng::from_os_rng(), -+ None => StdRng::from_rng(OsRng).expect("OsRng unavailable"), - }) - } else { - // zero temp - no need for rng -@@ -476,7 +476,7 @@ impl<Ix: IndexType, Node: NodeType> Cont - - let mut local_score = |sa: Score, sb: Score, sab: Score| -> Score { - let gumbel = if let Some(rng) = &mut rng { -- coeff_t * -f32::ln(-f32::ln(rng.random())) -+ coeff_t * -f32::ln(-f32::ln(rng.gen::<f32>())) - } else { - 0.0 as f32 - }; -@@ -1047,13 +1047,13 @@ fn run_random_greedy_optimization<Ix: In - let costmod = if is_const_costmod { - costmod_min - } else { -- costmod_min + rng.random::<f32>() * costmod_diff -+ costmod_min + rng.gen::<f32>() * costmod_diff - }; - - let temperature = if is_const_temp { - temp_min - } else { -- f32::exp(log_temp_min + rng.random::<f32>() * log_temp_diff) -+ f32::exp(log_temp_min + rng.gen::<f32>() * log_temp_diff) - }; - - let success = -@@ -1245,7 +1245,7 @@ fn optimize_greedy( - simplify: Option<bool>, - use_ssa: Option<bool>, - ) -> SSAPath { -- py.detach(|| { -+ py.allow_threads(|| { - let n = inputs.len(); - let num_indices = size_dict.len(); - let max_nodes = 2 * n; -@@ -1372,7 +1372,7 @@ fn optimize_random_greedy_track_flops( - simplify: Option<bool>, - use_ssa: Option<bool>, - ) -> (SSAPath, Score) { -- py.detach(|| { -+ py.allow_threads(|| { - let (costmod_min, costmod_max) = costmod.unwrap_or((0.1, 4.0)); - let costmod_diff = (costmod_max - costmod_min).abs(); - let is_const_costmod = costmod_diff < Score::EPSILON; -@@ -1385,9 +1385,9 @@ fn optimize_random_greedy_track_flops( - - let mut rng = match seed { - Some(seed) => rand::rngs::StdRng::seed_from_u64(seed), -- None => rand::rngs::StdRng::from_os_rng(), -+ None => StdRng::from_rng(OsRng).expect("OsRng unavailable"), - }; -- let seeds = (0..ntrials).map(|_| rng.random()).collect::<Vec<u64>>(); -+ let seeds = (0..ntrials).map(|_| rng.gen::<u64>()).collect::<Vec<u64>>(); - - let n: usize = inputs.len(); - let num_indices = size_dict.len(); -@@ -1530,7 +1530,7 @@ fn optimize_optimal( - simplify: Option<bool>, - use_ssa: Option<bool>, - ) -> SSAPath { -- py.detach(|| { -+ py.allow_threads(|| { - let n = inputs.len(); - let num_indices = size_dict.len(); - let max_nodes = 2 * n; diff -Nru python-cotengrust-0.2.0/debian/patches/002-rand-0.10.patch python-cotengrust-0.2.0/debian/patches/002-rand-0.10.patch --- python-cotengrust-0.2.0/debian/patches/002-rand-0.10.patch 1970-01-01 00:00:00.000000000 +0000 +++ python-cotengrust-0.2.0/debian/patches/002-rand-0.10.patch 2026-03-14 10:24:29.000000000 +0000 @@ -0,0 +1,48 @@ +Description: Update code for rand 0.10 + Rand 0.10 renamed the Rng trait to RngExt and renamed the RngCore trait to + Rng. It also removed the StdRng::from_os_rng function, so we must build + the rng manually. +Forwarded: no +Author: Peter Michael Green <[email protected]> +Last-Update: 2026-03-14 + +Index: python-cotengrust-0.2.0.new/Cargo.toml +=================================================================== +--- python-cotengrust-0.2.0.new.orig/Cargo.toml ++++ python-cotengrust-0.2.0.new/Cargo.toml +@@ -16,1 +16,1 @@ +-rand = "0.9" ++rand = ">= 0.10" +Index: python-cotengrust-0.2.0.new/src/lib.rs +=================================================================== +--- python-cotengrust-0.2.0.new.orig/src/lib.rs ++++ python-cotengrust-0.2.0.new/src/lib.rs +@@ -2,7 +2,7 @@ use bit_set::BitSet; + use num_traits::{AsPrimitive, Bounded, PrimInt}; + use ordered_float::OrderedFloat; + use pyo3::prelude::*; +-use rand::Rng; ++use rand::RngExt; + use rand::SeedableRng; + use rustc_hash::FxHashMap; + use std::collections::{BTreeSet, BinaryHeap, HashSet}; +@@ -467,7 +467,7 @@ impl<Ix: IndexType, Node: NodeType> Cont + let mut rng = if coeff_t != 0.0 { + Some(match seed { + Some(seed) => rand::rngs::StdRng::seed_from_u64(seed), +- None => rand::rngs::StdRng::from_os_rng(), ++ None => rand::rngs::StdRng::from_rng(&mut rand::rand_core::UnwrapErr(rand::rngs::SysRng)), + }) + } else { + // zero temp - no need for rng +--- python-cotengrust-0.2.0.orig/src/lib.rs ++++ python-cotengrust-0.2.0/src/lib.rs +@@ -1385,7 +1385,7 @@ fn optimize_random_greedy_track_flops( + + let mut rng = match seed { + Some(seed) => rand::rngs::StdRng::seed_from_u64(seed), +- None => rand::rngs::StdRng::from_os_rng(), ++ None => rand::rngs::StdRng::from_rng(&mut rand::rand_core::UnwrapErr(rand::rngs::SysRng)), + }; + let seeds = (0..ntrials).map(|_| rng.random()).collect::<Vec<u64>>(); + diff -Nru python-cotengrust-0.2.0/debian/patches/series python-cotengrust-0.2.0/debian/patches/series --- python-cotengrust-0.2.0/debian/patches/series 2025-10-13 02:01:45.000000000 +0000 +++ python-cotengrust-0.2.0/debian/patches/series 2026-03-14 10:24:29.000000000 +0000 @@ -1,2 +1,2 @@ -002-fix-rand-PyO3-api.patch 001-relax-cargo-depends.patch +002-rand-0.10.patch diff -Nru python-cotengrust-0.2.0/debian/rules python-cotengrust-0.2.0/debian/rules --- python-cotengrust-0.2.0/debian/rules 2025-10-13 02:01:45.000000000 +0000 +++ python-cotengrust-0.2.0/debian/rules 2026-03-14 10:24:29.000000000 +0000 @@ -6,6 +6,8 @@ override_dh_auto_clean: if test -f Cargo.lock.saved; then mv Cargo.lock.saved Cargo.lock; fi rm -rf target + rm -rf debian/cargo_home/registry + rm -f debian/cargo_home/.*cache* dh_auto_clean override_dh_auto_build:

