metno / hdf5-rust

HDF5 for Rust
https://docs.rs/hdf5
Apache License 2.0
9 stars 1 forks source link

rust ndarray version number of this crate keeps changing for different installation types #13

Closed robinpaul85 closed 3 days ago

robinpaul85 commented 1 week ago

I have installed hdf5-rust-metno on two different systems: x86_64 and aarch64. The ndarray version used by the hdf5-metno is different for both the systems:

In case of x86_64

$ cargo tree
rust_hdf5 v0.1.0 (/Users/rpaul1/Documents/test/rust_hdf5)
├── hdf5-metno v0.9.2
│   ├── bitflags v2.6.0
│   ├── cfg-if v1.0.0
│   ├── hdf5-metno-derive v0.9.0 (proc-macro)
│   │   ├── proc-macro-error v1.0.4
│   │   │   ├── proc-macro-error-attr v1.0.4 (proc-macro)
│   │   │   │   ├── proc-macro2 v1.0.86
│   │   │   │   │   └── unicode-ident v1.0.12
│   │   │   │   └── quote v1.0.36
│   │   │   │       └── proc-macro2 v1.0.86 (*)
│   │   │   │   [build-dependencies]
│   │   │   │   └── version_check v0.9.5
│   │   │   ├── proc-macro2 v1.0.86 (*)
│   │   │   └── quote v1.0.36 (*)
│   │   │   [build-dependencies]
│   │   │   └── version_check v0.9.5
│   │   ├── proc-macro2 v1.0.86 (*)
│   │   ├── quote v1.0.36 (*)
│   │   └── syn v2.0.75
│   │       ├── proc-macro2 v1.0.86 (*)
│   │       ├── quote v1.0.36 (*)
│   │       └── unicode-ident v1.0.12
│   ├── hdf5-metno-sys v0.9.1
│   │   ├── libc v0.2.158
│   │   └── parking_lot v0.12.3
│   │       ├── lock_api v0.4.12
│   │       │   └── scopeguard v1.2.0
│   │       │   [build-dependencies]
│   │       │   └── autocfg v1.3.0
│   │       └── parking_lot_core v0.9.10
│   │           ├── cfg-if v1.0.0
│   │           ├── libc v0.2.158
│   │           └── smallvec v1.13.2
│   │   [build-dependencies]
│   │   ├── libloading v0.8.5
│   │   │   └── cfg-if v1.0.0
│   │   └── regex v1.10.6
│   │       ├── aho-corasick v1.1.3
│   │       │   └── memchr v2.7.4
│   │       ├── memchr v2.7.4
│   │       ├── regex-automata v0.4.7
│   │       │   ├── aho-corasick v1.1.3 (*)
│   │       │   ├── memchr v2.7.4
│   │       │   └── regex-syntax v0.8.4
│   │       └── regex-syntax v0.8.4
│   ├── hdf5-metno-types v0.9.0
│   │   ├── ascii v1.1.0
│   │   ├── cfg-if v1.0.0
│   │   ├── hdf5-metno-sys v0.9.1 (*)
│   │   └── libc v0.2.158
│   ├── lazy_static v1.5.0
│   ├── libc v0.2.158
│   ├── ndarray v0.15.6
│   │   ├── matrixmultiply v0.3.9
│   │   │   └── rawpointer v0.2.1
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.3.0
│   │   ├── num-complex v0.4.6
│   │   │   └── num-traits v0.2.19
│   │   │       [build-dependencies]
│   │   │       └── autocfg v1.3.0
│   │   ├── num-integer v0.1.46
│   │   │   └── num-traits v0.2.19 (*)
│   │   ├── num-traits v0.2.19 (*)
│   │   └── rawpointer v0.2.1
│   └── paste v1.0.15 (proc-macro)
├── json v0.12.4
└── ndarray v0.16.1 
    ├── matrixmultiply v0.3.9 (*)
    ├── num-complex v0.4.6 (*)
    ├── num-integer v0.1.46 (*)
    ├── num-traits v0.2.19 (*)
    └── rawpointer v0.2.1

whereas in the aarch64 system it looks like this:

% rustup toolchain list
stable-aarch64-apple-darwin (default)
% cargo tree
rust_hdf5 v0.1.0 (/Users/rpaul1/Documents/test/rust_hdf5)
├── hdf5-metno v0.9.2
│   ├── bitflags v2.6.0
│   ├── cfg-if v1.0.0
│   ├── hdf5-metno-derive v0.9.0 (proc-macro)
│   │   ├── proc-macro-error v1.0.4
│   │   │   ├── proc-macro-error-attr v1.0.4 (proc-macro)
│   │   │   │   ├── proc-macro2 v1.0.86
│   │   │   │   │   └── unicode-ident v1.0.12
│   │   │   │   └── quote v1.0.37
│   │   │   │       └── proc-macro2 v1.0.86 (*)
│   │   │   │   [build-dependencies]
│   │   │   │   └── version_check v0.9.5
│   │   │   ├── proc-macro2 v1.0.86 (*)
│   │   │   └── quote v1.0.37 (*)
│   │   │   [build-dependencies]
│   │   │   └── version_check v0.9.5
│   │   ├── proc-macro2 v1.0.86 (*)
│   │   ├── quote v1.0.37 (*)
│   │   └── syn v2.0.77
│   │       ├── proc-macro2 v1.0.86 (*)
│   │       ├── quote v1.0.37 (*)
│   │       └── unicode-ident v1.0.12
│   ├── hdf5-metno-sys v0.9.1
│   │   ├── libc v0.2.158
│   │   └── parking_lot v0.12.3
│   │       ├── lock_api v0.4.12
│   │       │   └── scopeguard v1.2.0
│   │       │   [build-dependencies]
│   │       │   └── autocfg v1.3.0
│   │       └── parking_lot_core v0.9.10
│   │           ├── cfg-if v1.0.0
│   │           ├── libc v0.2.158
│   │           └── smallvec v1.13.2
│   │   [build-dependencies]
│   │   ├── libloading v0.8.5
│   │   │   └── cfg-if v1.0.0
│   │   └── regex v1.10.6
│   │       ├── aho-corasick v1.1.3
│   │       │   └── memchr v2.7.4
│   │       ├── memchr v2.7.4
│   │       ├── regex-automata v0.4.7
│   │       │   ├── aho-corasick v1.1.3 (*)
│   │       │   ├── memchr v2.7.4
│   │       │   └── regex-syntax v0.8.4
│   │       └── regex-syntax v0.8.4
│   ├── hdf5-metno-types v0.9.0
│   │   ├── ascii v1.1.0
│   │   ├── cfg-if v1.0.0
│   │   ├── hdf5-metno-sys v0.9.1 (*)
│   │   └── libc v0.2.158
│   ├── lazy_static v1.5.0
│   ├── libc v0.2.158
│   ├── ndarray v0.16.1 
│   │   ├── matrixmultiply v0.3.9
│   │   │   └── rawpointer v0.2.1
│   │   │   [build-dependencies]
│   │   │   └── autocfg v1.3.0
│   │   ├── num-complex v0.4.6
│   │   │   └── num-traits v0.2.19
│   │   │       [build-dependencies]
│   │   │       └── autocfg v1.3.0
│   │   ├── num-integer v0.1.46
│   │   │   └── num-traits v0.2.19 (*)
│   │   ├── num-traits v0.2.19 (*)
│   │   └── rawpointer v0.2.1
│   └── paste v1.0.15 (proc-macro)
├── json v0.12.4
└── ndarray v0.16.1 

I need to use ndarray in my own code (as my version of ndarray does not match with that used in rust-metno in case of x86_64) and therefore I am getting version conflict issues as shown below:

error[E0277]: the trait bound `Dim<[usize; 1]>: ndarray::dimension::dimension_trait::Dimension` is not satisfied
   --> src/main.rs:17:56
    |
17  |     let data_dim: Array1<usize> = ds_dim.read::<usize, Dim<[usize; 1]>>()?;
    |                                          ----          ^^^^^^^^^^^^^^^ the trait `ndarray::dimension::dimension_trait::Dimension` is not implemented for `Dim<[usize; 1]>`
    |                                          |
    |                                          required by a bound introduced by this call
    |
    = help: the following other types implement trait `ndarray::dimension::dimension_trait::Dimension`:
              ndarray::dimension::dim::Dim<[usize; 0]>
              ndarray::dimension::dim::Dim<[usize; 1]>
              ndarray::dimension::dim::Dim<[usize; 2]>
              ndarray::dimension::dim::Dim<[usize; 3]>
              ndarray::dimension::dim::Dim<[usize; 4]>
              ndarray::dimension::dim::Dim<[usize; 5]>
              ndarray::dimension::dim::Dim<[usize; 6]>
              ndarray::dimension::dim::Dim<ndarray::dimension::dynindeximpl::IxDynImpl>
note: required by a bound in `Container::read`
   --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hdf5-metno-0.9.2/src/hl/container.rs:557:31
    |
557 |     pub fn read<T: H5Type, D: ndarray::Dimension>(&self) -> Result<Array<T, D>> {
    |                               ^^^^^^^^^^^^^^^^^^ required by this bound in `Container::read`

error[E0308]: `?` operator has incompatible types
    --> src/main.rs:17:35
     |
17   |     let data_dim: Array1<usize> = ds_dim.read::<usize, Dim<[usize; 1]>>()?;
     |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ArrayBase<OwnedRepr<...>, ...>`, found a different `ArrayBase<OwnedRepr<...>, ...>`
     |
     = note: `?` operator cannot convert from `ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<usize>, Dim<[usize; 1]>>` to `ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>`
     = note: `ArrayBase<OwnedRepr<...>, ...>` and `ArrayBase<OwnedRepr<...>, ...>` have similar names, but are actually distinct types
note: `ArrayBase<OwnedRepr<...>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/lib.rs:1280:1
     |
1280 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ArrayBase<OwnedRepr<...>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/lib.rs:1268:1
     |
1268 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: perhaps two different versions of crate `ndarray` are being used?

error[E0308]: `?` operator has incompatible types
    --> src/main.rs:64:41
     |
64   | ...ay1<usize> = ds_p.read_slice_1d(gene_index..gene_index + 2)?;
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ArrayBase<OwnedRepr<...>, ...>`, found a different `ArrayBase<OwnedRepr<...>, ...>`
     |
     = note: `?` operator cannot convert from `ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<_>, ndarray::dimension::dim::Dim<[usize; 1]>>` to `ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>`
     = note: `ArrayBase<OwnedRepr<...>, ...>` and `ArrayBase<OwnedRepr<...>, ...>` have similar names, but are actually distinct types
note: `ArrayBase<OwnedRepr<...>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/lib.rs:1280:1
     |
1280 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ArrayBase<OwnedRepr<...>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/lib.rs:1268:1
     |
1268 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: perhaps two different versions of crate `ndarray` are being used?

error[E0308]: `?` operator has incompatible types
    --> src/main.rs:81:9
     |
81   |         ds_i.read_slice_1d(array_start_point..array_stop_point - 1)?;
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ArrayBase<OwnedRepr<...>, ...>`, found a different `ArrayBase<OwnedRepr<...>, ...>`
     |
     = note: `?` operator cannot convert from `ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<_>, ndarray::dimension::dim::Dim<[usize; 1]>>` to `ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>`
     = note: `ArrayBase<OwnedRepr<...>, ...>` and `ArrayBase<OwnedRepr<...>, ...>` have similar names, but are actually distinct types
note: `ArrayBase<OwnedRepr<...>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/lib.rs:1280:1
     |
1280 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ArrayBase<OwnedRepr<...>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/lib.rs:1268:1
     |
1268 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: perhaps two different versions of crate `ndarray` are being used?
error[E0308]: `?` operator has incompatible types
    --> src/main.rs:106:9
     |
106  |         ds_x.read_slice_1d(array_start_point..array_stop_point - 1)?;
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ArrayBase<OwnedRepr<f64>, ...>`, found `ArrayBase<OwnedRepr<_>, ...>`
     |
     = note: `?` operator cannot convert from `ndarray::ArrayBase<ndarray::data_repr::OwnedRepr<_>, ndarray::dimension::dim::Dim<[usize; 1]>>` to `ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>`
     = note: `ArrayBase<OwnedRepr<_>, ...>` and `ArrayBase<OwnedRepr<f64>, ...>` have similar names, but are actually distinct types
note: `ArrayBase<OwnedRepr<_>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.15.6/src/lib.rs:1268:1
     |
1268 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ArrayBase<OwnedRepr<f64>, ...>` is defined in crate `ndarray`
    --> /Users/rpaul1/.cargo/git/checkouts/ndarray-87cffd63128355dc/7843a3b/src/lib.rs:1280:1
     |
1280 | pub struct ArrayBase<S, D>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: perhaps two different versions of crate `ndarray` are being used?

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `rust_hdf5` (bin "rust_hdf5") due to 5 previous errors

As a result, I am not able to commit the version of ndarray to git as one single ndarray version does not work on both computers. Can you please suggest, how I can resolve this error? I am not sure whether the discrepancy is due to different platforms. I tried reinstalling rust from scratch in both computers, but I am still not able to resolve the error.

magnusuMET commented 1 week ago

Both ndarray 0.15 and 0.16 are supported by this library, but you might have to tweak Cargo.lock to force the correct version. I think you can run cargo update on your x86_64 system and it will start using 0.16

robinpaul85 commented 3 days ago

Yes, that works. Thank you!