Python propagatedBuildInput not found

Hi there,

I’m new to Python packaging with Nix and hit a snag I can’t figure out trying to package aioprometheus for a Flake. It requires orjson (already in nixpkgs) and python-quantile (not in nixpkgs).

I’ve been able to package python-quantile in a way that I can import it from a shell env, but I can’t seem to get the derivation for aioprometheus to see it, even when provided as a propagatedBuildInput.

Here’s what I have:

flake.nix:

{
  description = "Python Packaging Experiment";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/22.05";
    utils.url = "github:numtide/flake-utils";
    utils.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, ... }@inputs:
    inputs.utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let
        pkgs = import nixpkgs { inherit system; };
        python = pkgs.python310;

        quantile-python = python.pkgs.callPackage ./quantile-python.nix { };
        aioprom =
          python.pkgs.callPackage ./aioprom.nix { inherit quantile-python; };

        pythonEnv = pkgs.python310.withPackages
          (ps: with ps; [ orjson quantile-python aioprom ]);
      in {
        devShells.default = pkgs.mkShell { buildInputs = [ pythonEnv ]; };
      });
}

quantile-python.nix:

{ lib, buildPythonPackage, fetchFromGitHub, ... }:

buildPythonPackage rec {
  pname = "quantile-python";
  version = "1.1";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "slok";
    repo = "python_quantile_estimation";
    rev = version;
    sha256 = "sha256-WcjdJfOXrH1raPbypyp5XCYaPN4Jn+lkNRi2bIPgNrc=";
  };

  pythonImportsCheck = [ "quantile" ];

  # No tests included.
  doCheck = false;
}

and finally, aioprom.nix:

{ lib, buildPythonPackage, fetchFromGitHub, orjson, quantile-python, ... }:

buildPythonPackage rec {
  pname = "aioprometheus";
  version = "22.5.0";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "claws";
    repo = "aioprometheus";
    rev = version;
    sha256 = "sha256-oXLKJDCJFRcR+yOXpTVuQgrnOfPRnS8g51Aci/qMOOw=";
  };

  pythonImportsCheck = [ pname ];

  propagatedBuildInputs = [ orjson quantile-python ];
}

The error I see running nix develop is:

error: builder for '/nix/store/wblzmnzqkvd1sz2kncram7gs92l31cnd-python3.10-aioprometheus-22.5.0.drv' failed with exit code 1;
       last 10 log lines:
       > removing build/bdist.linux-x86_64/wheel
       > Finished executing setuptoolsBuildPhase
       > installing
       > Executing pipInstallPhase
       > /build/source/dist /build/source
       > Processing ./aioprometheus-22.5.0-py3-none-any.whl
       > Requirement already satisfied: orjson in /nix/store/78akal482iljzj4md40ainl2p1hz1ifw-python3.10-orjson-3.6.7/lib/python3.10/site-packages (from aioprometheus==22.5.0) (3.6.7)
       > ERROR: Could not find a version that satisfies the requirement quantile-python>=1.1 (from aioprometheus) (from versions: none)
       > ERROR: No matching distribution found for quantile-python>=1.1
       >
       For full logs, run 'nix log /nix/store/wblzmnzqkvd1sz2kncram7gs92l31cnd-python3.10-aioprometheus-22.5.0.drv'.
error: 1 dependencies of derivation '/nix/store/d9hk70vc2kqhf8ibf7vp906rfyav1pij-python3-3.10.4-env.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qlnvj34qcqcxxj3krrczgcwzyldjs5qa-nix-shell-env.drv' failed to build

Any help would be appreciated :slight_smile: I’m sure it’s something about my approach that’s off the mark.