Skip to content

Commit d1379aa

Browse files
authored
Split hashbrown dependency between Python-space and rustworkx-core (#1552)
`rustworkx-core` exposes `hashbrown` types in its own public API, which requires downstream crates match their resolved `hashbrown` versions to the one used by `rustworkx-core` in its API (up to potentially using a re-export of `hashbrown` from `rustworkx-core`, but one isn't provided, and it's not really scalable for `rustworkx-core` to claim it dictates the version of such a commonly used package). The Python-space `rustworkx` package passes `hashbrown` types between PyO3 and `petgraph` interfaces, so requires hard matches to the resolved versions used by those libraries, but that's a tighter constraint. These separate concerns motivate splitting the allowed bounds on `hashbrown`, so that downstream Rust-space consumers of `rustworkx-core` can use newer versions of `hashbrown` without being held back by the Python-space package. For example, with this commit, Qiskit can now upgrade its internal use to `hashbrown 0.16.1`, including extracting those objects from (a newer) PyO3 and passing them to `rustworkx-core`.
1 parent 15a296a commit d1379aa

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ indexmap = { version = ">=1.9, <3", features = ["rayon"] }
3131
ndarray = { version = "0.16.1", features = ["rayon"] }
3232
num-traits = "0.2"
3333
petgraph = "0.8"
34-
hashbrown = { version = ">=0.13, <0.16", features = ["rayon"] }
3534
numpy = "0.26"
3635
rand = "0.9"
3736
rand_distr = "0.5"
@@ -45,7 +44,6 @@ crate-type = ["cdylib"]
4544
[dependencies]
4645
foldhash.workspace = true
4746
fixedbitset.workspace = true
48-
hashbrown.workspace = true
4947
indexmap.workspace = true
5048
ndarray.workspace = true
5149
ndarray-stats = "0.6.0"
@@ -68,6 +66,10 @@ pest = "2.8"
6866
pest_derive = "2.8"
6967
nalgebra-sparse = { version = "=0.10", features = ["io"] }
7068

69+
[dependencies.hashbrown]
70+
version = "0.15.0" # Implicitly required to match PyO3's and `petgraph`'s via cross-API use.
71+
features = ["rayon"]
72+
7173
[dependencies.pyo3]
7274
version = "0.26"
7375
features = ["abi3-py310", "extension-module", "hashbrown", "num-bigint", "num-complex", "indexmap", "py-clone"]

rustworkx-core/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ license.workspace = true
1414
[dependencies]
1515
foldhash.workspace = true
1616
fixedbitset.workspace = true
17-
hashbrown.workspace = true
1817
indexmap.workspace = true
1918
ndarray.workspace = true
2019
num-traits.workspace = true
@@ -26,6 +25,13 @@ rand_pcg.workspace = true
2625
rayon.workspace = true
2726
rayon-cond = "0.4"
2827

28+
[dependencies.hashbrown]
29+
# The version here should allow a decent range, because it's used in the public API, meaning
30+
# downstream crates have to implicitly match us. The range must at least be compatible with the
31+
# `rustworkx` Python component.
32+
version = ">=0.15,<0.17"
33+
features = ["rayon"]
34+
2935
[dev-dependencies]
3036
quickcheck = "1.0"
31-
quickcheck_macros = "1.0"
37+
quickcheck_macros = "1.0"

0 commit comments

Comments
 (0)