Help creating a derivation for pye57

I’m struggling to create a derivation for pye57. It looked like a somewhat straightforward task, but I’m struggling to get the libe57format C dependency to work correctly.

Here’s the current derivation:

{ fetchFromGitHub, pkgs }: let
  python = pkgs.python39;
  pypkgs = python.pkgs;
in
  pypkgs.buildPythonPackage {
    name = "pye57";
    src = fetchFromGitHub {
      owner = "davidcaron";
      repo = "pye57";
      rev = "v0.4.1";
      sha256 = "sha256-Kc+48fpudsAqKQS77WbfKdL9mTf5lrJ+SZkm48lorzQ=";
    };
    buildInputs = [pkgs.libe57format];
    propagatedBuildInputs = with pypkgs; [
      numpy
      pybind11
    ];
  }

And I’m testing it with: nix-build -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'

I think the issue is that the libe57format puts the header files in a subdirectory of the include, and so they aren’t being found by the linker. But I’m not really sure how to debug this, or for that matter fix it. It seems odd the libe57format package would be broken in that way too, so I assume it’s something else I’m doing wrong?

I figured it out. Turns out the package ships with an existing copy of e57format, and must use that one instead of the one I was trying to provide. It didn’t exist because it was a submodule, and I was using Github’s fetch, not git fetch; and so wasn’t getting submodules.

Here’s a work derivation:

{ fetchgit, pkgs }: let
  python = pkgs.python39;
  pypkgs = python.pkgs;
in
  pypkgs.buildPythonPackage {
    name = "pye57";
    src = fetchgit {
      url = "https://github.com/davidcaron/pye57";
      rev = "v0.4.1";
      sha256 = "sha256-IEkd+UhGYunNrHuO/3WN2rI7dofX/oj3vfn3rvyHMHM=";
      fetchSubmodules = true;
    };
    buildInputs = [
      pypkgs.pip
      pypkgs.pytest
      pypkgs.pybind11
      pkgs.xercesc.out
    ];
    propagatedBuildInputs = with pypkgs; [
      numpy
      pyquaternion
    ];
  }