`buildPythonPackage`: buildtime dependency on an extra requires

hey everyone :3

i am once again going mildly insane over a python package build. i am trying to build a fork of statsmodels. statsmodels requires "setuptools_scm[toml]>=8,<9" in its pyproject.toml. i am trying to satisfy that dependency.

this is the approximate state of the build.nix (give take solution attempt):

# this nix expression fetches the heckman feature branch but pulled onto the 0.14.1 release

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz") { }
}:
let
# propagatedBuildInputs = super.propagatedBuildInputs ++ [ pkgs.python3Packages.tomli ]; 
  # setuptools-scm-with-toml = pkgs.python3Packages.setuptools-scm.override { tomli=true; };
  setuptools-scm-with-toml = pkgs.python3Packages.setuptools-scm.overrideAttrs(final: super: {
    propagatedBuildInputs = super.propagatedBuildInputs ++ [pkgs.python3Packages.tomli];
    nativeBuildInputs = super.nativeBuildInputs ++ [pkgs.python3Packages.tomli];
  });
in
pkgs.python3Packages.buildPythonPackage {
  pname = "statsmodels";
  version = "0.14.1";

  src = pkgs.fetchgit {
    url = "https://codeberg.org/lotta/heckman.rebase.statsmodels.0_14_1";
    # ref = "main";
    rev = "f6a51a72558a51f5cb4dcbd8821c71b37a12941f";
    deepClone = true;
    sha256 = "sha256-pShKeZ3eQg1QKP3QlRZdjs4ITfZ2/JBqrlj43efrsMs=";
  };

  nativeBuildInputs = [ pkgs.python3Packages.pip pkgs.git ];

  propagatedBuildInputs = with pkgs.python3Packages; [
    setuptools
    packaging
    cython
    numpy
    scipy
    setuptools-scm-with-toml
    oldest-supported-numpy
  ];

  pyproject = true;

  meta = with pkgs.lib; {
    description = "rebase of the outstanding pr adding a heckman model on top of the 0.14.1 release of statsmodels.";
    license = licenses.bsd3;
  };
}

i have tried:

  • overrideAttrs for:
    propagatedBuildInputs = super.propagatedBuildInputs ++ [pkgs.python3Packages.tomli];
    nativeBuildInputs = super.nativeBuildInputs ++ [pkgs.python3Packages.tomli];
    
  • exploring the optional-dependencies key (that only has rich and i had the conclusion that opitional dependencies is then used only to do runtime and not buildtime things idk) (see python doc and pr )
  • exploring things targetable by override so the arguments to the the nixpkg
  • also overriding the requiredPythonModules didn’t work i think that only exists post build?

what am i doing wrong here?

best regards :>

this build.nix provided by a saint was the fix where overrideAttrs is used to override the optional-dependencies and then using it as well as just skipping the build time dep check with pypaBuildFlags:

# this nix expression fetches the heckman feature branch but pulled onto the 0.14.1 release

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz") { }
}:
pkgs.python3Packages.buildPythonPackage {
  pname = "statsmodels";
  version = "0.14.1";

  src = pkgs.fetchgit {
    url = "https://codeberg.org/lotta/heckman.rebase.statsmodels.0_14_1";
    # ref = "main";
    rev = "f6a51a72558a51f5cb4dcbd8821c71b37a12941f";
    deepClone = true;
    sha256 = "sha256-pShKeZ3eQg1QKP3QlRZdjs4ITfZ2/JBqrlj43efrsMs=";
  };

  nativeBuildInputs = [ pkgs.python3Packages.pip pkgs.git ];

  propagatedBuildInputs = with pkgs.python3Packages; [
    setuptools
    packaging
    cython
    numpy
    scipy
    setuptools-scm
    (setuptools-scm.overrideAttrs (final: super: { passthru.optional-dependencies.toml = [tomli]; })).optional-dependencies.toml
    oldest-supported-numpy
  ];

  pypaBuildFlags = ["--skip-dependency-check"];

  pyproject = true;

  meta = with pkgs.lib; {
    description = "rebase of the outstanding pr adding a heckman model on top of the 0.14.1 release of statsmodels.";
    license = licenses.bsd3;
  };
}