Trying to package python library which has specified setuptools less thatn latest version

I am trying to package the python package sanic-ext which has some extensions for Sanic. I am running into the following error

       > ERROR Missing dependencies:
       > 	setuptools<60.0

but setuptools is specified as a dependancy in the same way that the other sanic packages does it. So I think the issue is that the latest version of setuptools on nixpkgs is later than version 60. So how should I resolve it? Just ask the sanic project for the reason of that they specified that version of setuptools and see if they can remove it? Or should I just patch it out before buildring?

Historically, we used to patch this with something like substituteInPlace .... However now we have pythonRelaxDepsHook:

  nativeBuildInputs = [

  pythonRelaxDeps = [

Should be what you want. pythonRelaxDepsHook works by modifying the .whl to remove version constraints.

That sounds good. Is that preferred to making my own patch or contacting upstream?

Good question. Depends on the project. Setuptools has been deprecating things, so pinning may have been warranted at one time.

Usually it doesn’t hurt to try.

I have gotten it to build by making my own patch, but I cannot get your supplied hook to work. Here is my current package defintion

{ lib
, python3Packages
, fetchFromGitHub

buildPythonPackage rec {
  pname = "sanic-ext";
  version = "23.12.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "sanic-org";
    repo = "sanic-ext";
    rev = "v${version}";
    hash = "sha256-KbcY480mxZw+t6WQktOz3h7oyIxWx1jR3ODOjf7psM0=";

    propagatedBuildInputs = [

  nativeBuildInputs = with python3Packages; [

  pythonImportsCheck = [ "sanic_ext" ];

  meta = with lib; {
    description = "Extended Sanic functionality";
    homepage = "";
    changelog = "${src.rev}/";
    license =;
    maintainers = with maintainers; [ ];
    mainProgram = "sanic-ext";

The hook appears to be a postbuild hook, but it fails during the build step, so I am not sure how the hook is intended to work in my case.

Sorry, you need to specify which deps you want to relax:

  pythonRelaxDeps = [

  nativeBuildInputs = [

I’ll modify my original post

Still getting the same problem unfortunatelly. Here is the build log.

Sourcing python-remove-tests-dir-hook
Sourcing pypa-build-hook
Using pypaBuildPhase
Sourcing python-runtime-deps-check-hook
Using pythonRuntimeDepsCheckHook
Sourcing pypa-install-hook
Using pypaInstallPhase
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/xk2z6h568flpyb3hif59162l51j4z70k-source
source root is source
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/tox.ini
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
Executing pypaBuildPhase
Creating a wheel...
* Getting build dependencies for wheel...
running egg_info
creating sanic_ext.egg-info
writing sanic_ext.egg-info/PKG-INFO
writing dependency_links to sanic_ext.egg-info/dependency_links.txt
writing requirements to sanic_ext.egg-info/requires.txt
writing top-level names to sanic_ext.egg-info/top_level.txt
writing manifest file 'sanic_ext.egg-info/SOURCES.txt'
reading manifest file 'sanic_ext.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'sanic_ext.egg-info/SOURCES.txt'

ERROR Missing dependencies:

I still do not get how this hook, which is a post-build hook, can solve a problem in the build step?