aldanor / hdf5-rust

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

Doesn't seem to register HDF5 1.14.2 as a version. #257

Open trippalamb opened 1 year ago

trippalamb commented 1 year ago

Had to roll back to 1.10.10 in order for hdf5-sys to register a version of HDF5 during the cargo build process.

mulimoen commented 1 year ago

Do you have the version string? In #243 I saw and implemented support for strings like 1.14.1.2

TrippLamb commented 1 year ago

I'm sorry. I don't understand what that means.

mulimoen commented 1 year ago

If you look in the H5pubconf.h header of the install, what is the value of H5_VERSION?

trippalamb commented 1 year ago

It is the same as this issue title "1.14.2"

/* Version number of package */
#define H5_VERSION "1.14.2"
loenard97 commented 11 months ago

I'm having the same problem. On Arch linux 6.5.8 with the latest hdf5 1.14.2-1 package installed, cargo fails when building a project with hdf5 0.8.1 as a dependency. cargo build ends with the following error:

  Found HDF5 pkg-config entry
      Include paths:
      - "/usr/include"
      Link paths:
      - "/usr/lib"
  Located HDF5 headers at:
      "/usr/include"
  Parsing HDF5 config from:
      "/usr/include/H5pubconf.h"

  --- stderr
  thread 'main' panicked at /home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hdf5-sys-0.8.1/build.rs:200:21:
  Invalid H5_VERSION: "1.14.2"
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
     1: core::panicking::panic_fmt
               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
     2: build_script_build::Header::parse
     3: build_script_build::LibrarySearcher::finalize
     4: build_script_build::main
     5: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

My /usr/include/H5pubconf.h header also reports version 1.14.2, same as @trippalamb:

/* Version number of package */
#define H5_VERSION "1.14.2"
mulimoen commented 11 months ago

Are you using the version from crates.io or using themaster branch from here?

loenard97 commented 11 months ago

I was using cargo add hdf5, so the crates.io version. I tried again with the latest version from here and it works now. Thank you.

mulimoen commented 11 months ago

@aldanor Maybe we should release a new version soon?

nleroy917 commented 11 months ago

I'm having this problem as well on an M1 mac:

        Setting HDF5 root from environment variable:
            HDF5_DIR = "/opt/homebrew/opt/hdf5"
        Custom HDF5_DIR provided; rpath can be set via:
            RUSTFLAGS="-C link-args=-Wl,-rpath,/opt/homebrew/opt/hdf5/lib"
        On some OS X installations, you may also need to set:
            DYLD_FALLBACK_LIBRARY_PATH="/opt/homebrew/opt/hdf5/lib"
        Parsing HDF5 config from:
            "/opt/homebrew/opt/hdf5/include/H5pubconf.h"

        --- stderr
        thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hdf5-sys-0.8.1/build.rs:200:21:
        Invalid H5_VERSION: "1.14.2"

I've attempted setting those flags as suggested in the error.

loenard97 commented 11 months ago

@nleroy917 try to set the hdf5 dependency to the git repo in your Cargo.toml. That did it for me.

[dependencies]
hdf5 = { git = "https://github.com/aldanor/hdf5-rust.git" }
nleroy917 commented 11 months ago

I just saw your comment above. Thank you, I will try this. I'm actually getting this build error in someone elses project, so I need to do a clone, change the Cargo.toml, then try a custom build... will report back...

mulimoen commented 11 months ago

@nleroy917 Is it possible to add an override? https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html

nleroy917 commented 11 months ago

😱 That worked super well. Even better since hdf5 was going to be a dependency of a dependency. I've got another problem now about not having a threadsafe version of hdf5 installed, but I think that one is unrelated to this issue 😅

mulimoen commented 11 months ago

Could be easier to use the static version of hdf5, try enabling the static feature (still only in master).

nleroy917 commented 11 months ago

Oh, it looks like its actually an issue with hdf5-sys:

thread 'main' panicked at ~/.cargo/git/checkouts/hdf5-rust-c1072d7a2617f7d8/26046fb/hdf5-sys/build.rs:697:17:
        Enabled feature "threadsafe" but the HDF5 library was not built with HDF5_ENABLE_THREADSAFE
        note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features pyo3/extension-module --crate-type cdylib -- -C 'link-args=-undefined dynamic_lookup -Wl,-install_name,@rpath/_snapatac2.cpython-311-darwin.so'` failed with code 101

Interestingly, I don't even have threadsafe set:

[patch.crates-io]
hdf5 = { git = "https://github.com/aldanor/hdf5-rust.git" }
hdf5-sys = { git = "https://github.com/aldanor/hdf5-rust.git", features = ["static", "zlib"]}
TrippLamb commented 11 months ago

@nleroy917 try to set the hdf5 dependency to the git repo in your Cargo.toml. That did it for me.

[dependencies]
hdf5 = { git = "https://github.com/aldanor/hdf5-rust.git" }

If I do this, it breaks my dependency on hdf5-sys. Is there a way to adjust for this? I'm reasonably new to rust and don't have a great grasp on the way the cargo works.

mulimoen commented 11 months ago

@trippalamb Add another line with hdf5-sys and the same contents

TrippLamb commented 11 months ago

That did indeed seem to fix it. I appreciate it.

nleroy917 commented 11 months ago

I was able to solve my problem by just unset-ing my HDF5_DIR variable. I have it in my .zshrc since I need it so often, but this time it was causing problems I guess.