Hi,
I’m trying to build and install a C++ library that also has python bindings. From what information I could gather, the approach in this case is to call toPythonModule
. I’ve tried this in various forms and it does not work. Here’s what I have:
feat.nix:
let
pkgs = import <nixos-unstable> {};
stdenv = pkgs.gcc10Stdenv;
eigency = pkgs.python38Packages.buildPythonPackage rec {
pname = "eigency";
version = "1.77" ;
src = pkgs.python38Packages.fetchPypi {
inherit pname version;
sha256 = "13cf96e00020fd900aa5f8905036488afd27c89212bfc07b60ac5412073ea7d7";
};
doCheck = false;
# build time deps
nativeBuildInputs = with pkgs.python38Packages; [
cython
setuptools
setuptools_scm
];
## runtime deps
propagatedBuildInputs = with pkgs; [
python38Packages.numpy
eigen
];
meta = with pkgs.stdlib; {
homepage = "https://pypi.org/project/eigency";
};
};
in
pkgs.python38Packages.toPythonModule (stdenv.mkDerivation rec {
pname = "feat";
version = "0.4";
nativeBuildInputs = with pkgs; [
cmake
autoPatchelfHook
(python38.withPackages( ps: with ps; [ cython setuptools setuptools_scm ]))
];
buildInputs = with pkgs; [
eigen shogun eigency
];
enablePython = true;
CFLAGS = "-march=znver2 -O3";
src = pkgs.fetchFromGitHub {
owner = "lacava";
repo = "feat";
rev = "b778a44ae64deeb4a5d7c652ba593154f117ef6e";
sha256 = "1y16dwdy1cx7xxg5j90rzj1jyf4ccri8xrw5lsnx0krdap5a7fz7";
};
installPhase = ''
mkdir -p $out/bin
install -m755 -D feat $out/bin/feat
install -m755 -D libfeat_lib.so $out/bin/libfeat_lib.so
'';
# This is how the Python bindings should be built
# cd ../python
# python setup.py install --home=$out
meta = with stdenv.lib; {
description = "A feature engineering automation tool for learning data representations";
homepage = "https://github.com/lacava/feat";
license = stdenv.lib.licenses.gpl3;
platforms = stdenv.lib.platforms.linux;
};
})
default.nix:
let
pkgs = import <nixos-unstable> {};
feat = import ./feat.nix;
in
pkgs.gcc10Stdenv.mkDerivation rec {
name = "feat-env";
buildInputs = [ feat ];
}
This works without errors but the python bindings are not built. If I try to add
cd ../python
python setup.py install --home=$out
in the installPhase in feat.nix then it does try to build the bindings but fails because it cannot find the Eigen include headers.
Can anyone shed some light on this issue? What would be the best practice to get this working?
Thanks.