Hello! My first nixos discourse post. I’m encountering the slightly puzzling error above when I try to build a certain python package from Pypi. Here’s a minimal flake that reproduces the problem:
{
description = "A very basic flake";
outputs = { self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
pyPkgs = pkgs.python311.pkgs;
pypcode = pyPkgs.buildPythonPackage rec {
pname = "pypcode";
version = "2.0.0";
src = pyPkgs.fetchPypi {
inherit pname version;
sha256 = "sha256-MO2Mcyy7IFp5BnuD8e/UpoZ9wGyiEtupmW5nEfUdo5g=";
};
doCheck = false;
propagatedBuildInputs = [
pkgs.cmake
];
};
in {
packages.x86_64-linux.pypcode = pypcode;
};
}
Any ideas? Thanks for your help!
vazae
February 21, 2024, 10:00am
2
The main issue is that pkgs.cmake
should be in nativeBuildInputs
, not propagatedBuildInputs
. In addition, dontUseCmakeBuildDir
should be set to true
to avoid losing setup.py
.
Here’s a working flake that builds successfully (I haven’t tested the actual package).
{
description = "A very basic flake";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
pyPkgs = pkgs.python311.pkgs;
nanobind = pyPkgs.buildPythonPackage {
pname = "nanobind";
version = "1.9.0";
src = pkgs.fetchFromGitHub {
owner = "wjakob";
repo = "nanobind";
rev = "v1.9.0";
sha256 = "sha256-eFKFtbnK5VbaMgmawjjTrzGNX2TOLWGvKxLogtMSI3Q=";
fetchSubmodules = true;
};
format = "pyproject";
dontUseCmakeBuildDir = true;
nativeBuildInputs = [
pyPkgs.scikit-build
pyPkgs.cmake
pyPkgs.ninja
];
buildInputs = [
pkgs.eigen
];
};
pypcode = pyPkgs.buildPythonPackage rec {
pname = "pypcode";
version = "2.0.0";
src = pyPkgs.fetchPypi {
inherit pname version;
sha256 = "sha256-MO2Mcyy7IFp5BnuD8e/UpoZ9wGyiEtupmW5nEfUdo5g=";
};
format = "pyproject";
doCheck = false;
dontUseCmakeBuildDir = true;
nativeBuildInputs = [
pyPkgs.setuptools
pyPkgs.cmake
];
buildInputs = [
nanobind
];
};
in
{
packages.x86_64-linux.pypcode = pypcode;
};
}
Note that there is an open PR for nanobind
.
1 Like
Thank you! I was able to use this to get everything working properly.