NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.93k stars 13.95k forks source link

tblite-python is not importable / pkgconfig for mtclib, s-dftd3, dftd4 #223862

Closed ryanswrt closed 1 year ago

ryanswrt commented 1 year ago

Describe the bug

tblite is unusable in python at the moment, failing with

Traceback (most recent call last):
  File "/nix/store/pzbm5ci2h0qlnrzkqxhdm9f0vwr5kal6-python3.10-tblite-0.3.0/lib/python3.10/site-packages/tblite/library.py", line 28, in <module>
    from ._libtblite import ffi, lib
ImportError: /nix/store/pzbm5ci2h0qlnrzkqxhdm9f0vwr5kal6-python3.10-tblite-0.3.0/lib/python3.10/site-packages/tblite/_libtblite.cpython-310-x86_64-linux-gnu.so: undefined symbol: __dftd3_model_MOD___vtab_dftd3_model_D3_model

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/pzbm5ci2h0qlnrzkqxhdm9f0vwr5kal6-python3.10-tblite-0.3.0/lib/python3.10/site-packages/tblite/interface.py", line 26, in <module>
    from . import library
  File "/nix/store/pzbm5ci2h0qlnrzkqxhdm9f0vwr5kal6-python3.10-tblite-0.3.0/lib/python3.10/site-packages/tblite/library.py", line 30, in <module>
    raise ImportError("tblite C extension unimportable, cannot use C-API")
ImportError: tblite C extension unimportable, cannot use C-API

I think this is due to incorrect pkgconfig setups - look at https://github.com/NixOS/nixpkgs/blob/e608c90a1cf381dde6ac9e0f085337150f2af3e2/pkgs/development/libraries/toml-f/default.nix#L26

which is correct and outputs

prefix=/nix/store/8irr24ds1c3r08wclk11gpxp3c7f0p7w-toml-f-0.3.1
libdir=${prefix}/lib
includedir=${prefix}/include

Name: toml-f
Description: A TOML parser implementation for data serialization and deserialization in Fortran
Version: 0.3.1
Libs: -L${libdir} -ltoml-f
Cflags: -I${includedir} -I${includedir}/toml-f/GNU-12.2.0

vs

https://github.com/NixOS/nixpkgs/blob/e608c90a1cf381dde6ac9e0f085337150f2af3e2/pkgs/development/libraries/science/chemistry/mctc-lib/default.nix#L27 which is missing the trailing /

Which results in a pkgconfig of

prefix=
libdir=${prefix}//lib
includedir=${prefix}//include

Name: mctc-lib
Description: Modular computation tool chain
Requires: 
Version: 0.3.1
Libs: -L${libdir} -lmctc-lib
Cflags: -I${includedir} -I${includedir}/mctc-lib/GNU-12.2.0

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a nix environment with python3Packages.tblite
  2. In the python interpreter, run import tblite.interface as tb
  3. See failure

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

@sheepforce

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here
linminhtoo commented 1 year ago

i'm having the exact same issue as well :'(