Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated functions in C API #7

Open
o-santi opened this issue Apr 5, 2024 · 0 comments
Open

Outdated functions in C API #7

o-santi opened this issue Apr 5, 2024 · 0 comments

Comments

@o-santi
Copy link

o-santi commented Apr 5, 2024

Describe the bug
The C API used in this library seems to be outdated. Given that the corresponding nix-c-bindings branch has been merged to master, it might be valuable to make sure it works with the newest version.

To Reproduce
Use python-nix with an up to date version of nix with C bindings, making sure to override the nix input to the newest version. The following flake uses the most up to date (2.22) version, but I've tested other versions that also don't work (tested with 2.21 and 2.20).

# flake.nix
{
  inputs = {
    python-nix = {
      url = "github:tweag/python-nix";
      inputs.nix.follows = "nix";
    };
    nix.url = "github:NixOs/nix";
    nixpkgs.follows = "nix/nixpkgs";
  };
  outputs = inputs @ { self, python-nix, nixpkgs, ...} :
    let
      system = "x86_64-linux";
      nix = inputs.nix.packages.${system}.default;
      pkgs = import nixpkgs {
        inherit system;
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = [
          (pkgs.python3.withPackages (_: [ nix python-nix.packages.${system}.default ]))
        ];
      };
    };
}

Then, in a shell.

$ nix develop
$ python3
Python 3.11.6 (main, Oct  2 2023, 13:45:54) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nix
>>> nix.eval('1 + 1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/3rb1nsykazqlgbagx6f227sdx17w805g-python3-3.11.6-env/lib/python3.11/site-packages/nix/__init__.py", line 20, in eval
    _store = Store()
             ^^^^^^^
  File "/nix/store/3rb1nsykazqlgbagx6f227sdx17w805g-python3-3.11.6-env/lib/python3.11/site-packages/nix/store.py", line 40, in __init__
    self._store = ffi.gc(lib.nix_store_open(url_c, params_c), lib.nix_store_unref)
                                                              ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/3rb1nsykazqlgbagx6f227sdx17w805g-python3-3.11.6-env/lib/python3.11/site-packages/nix/wrap.py", line 55, in __getattr__
    r: Any = wrap_ffi(getattr(self._thing, attr))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: cffi library 'nix._nix_api_store' has no function, constant or global variable named 'nix_store_unref'. Did you mean: 'nix_store_free'?
>>> 

Expected behavior
Output the number two.

Environment

  • NixOS 24.05.20240329.d8fe5e6 (Uakari)
  • Version of the code: master.

Additional context
This seems to be a name change of the function, from nix_store_unref to nix_store_free, though I'm not sure what else changed.

@o-santi o-santi changed the title Outdated functions C API Outdated functions in C API Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant