How to package a code that provides a Python interface?

I would like to write a nix expression for this code. The code is written mostly in C, but it also includes a Python interface.

Here is what I’ve done so far. The expression builds fine, but the Python interface is installed under /nix/store/8yaqbr0r270xmj8spr3cs2zk1s1lwx01-astrochem/lib/python2.7/site-packages/astrochem, and the Python interpreter can’t find it.

How can I modify the expression so that the Python interface can be included in a Python environnement? I know the buildPythonPackage function, but can it be used together with the mkDerivation function for the C part? Or should I write two separate expressions, one for the C part, and the other one for the Python interface?

use toPythonModule to make the package work with python.buildEnv and python.withPackages.

1 Like

Quoting Frederik Rietdijk (2018-10-06 12:52:56)

use toPythonModule to make the package work with python.buildEnv and python.withPackages.

Is it possible to do so with package that provides Ruby modules? I have
a modified Nix expression for notmuch package that builds Ruby module
for it, but I want it to be inserted into RUBYPATH or similar
automatically.

I’m not familiar with the Ruby infra so I don’t know.

How do I do that in practice? Should I call toPythonModule in the default.nix I wrote, or should write a separate nix expression for the module?

There are multiple examples in Nixpkgs.
toPythonModule ( stdenv.mkDerivation { ... } )

1 Like