From 3257fd9b952359d01e1a30639e01f404f97cb9bf Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 18 Sep 2021 22:03:53 +0200 Subject: [PATCH 1/2] Re-export ndarray to avoid having to specify the correct version in downstream crates. --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 0634495b3..6b01a86aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,6 +45,8 @@ mod readonly; mod slice_box; mod sum_products; +pub use ndarray; + pub use crate::array::{ get_array_module, PyArray, PyArray0, PyArray1, PyArray2, PyArray3, PyArray4, PyArray5, PyArray6, PyArrayDyn, From f8ccfe16c4ca6a725a892e06ee2d3d8791c3bbe9 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 18 Sep 2021 22:16:51 +0200 Subject: [PATCH 2/2] Extend README to cover handling non-unified dependencies on semver-incompatible ndarray versions. --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 2f26e4c66..533f04a24 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,32 @@ You can also automatically specify python version in `setup.py`, using [setuptools-rust](https://github.com/PyO3/setuptools-rust). +## Dependency on ndarray + +This crate uses types from `ndarray` in its public API. `ndarray` is re-exported +in the crate root so that you do not need to specify it as a direct dependency. + +Furthermore, this crate is compatible multiple versions of `ndarray` and therefore depends +on a range of semver-incompatible versions, currently `>= 0.13, < 0.16`. Cargo does not +automatically choose a single version of `ndarray` by itself if you depend directly or indirectly +on anything but that exact range. It can therefore be necessary to manually unify these dependencies. + +For example, if you specify the following dependencies + +```toml +numpy = "0.14" +ndarray = "0.13" +``` + +this will currently depend on both version `0.13.1` and `0.15.3` of `ndarray` by default +even though `0.13.1` is within the range `>= 0.13, < 0.16`. To fix this, you can run + +```sh +cargo update ---package ndarray:0.15.3 --precise 0.13.1 +``` + +to achieve a single dependency on version `0.13.1` of `ndarray`. + ## Example