Need help for packaging python package (package not installed error)

I am trying to package slidge but I connot trick nix to thing its dependency thumbhash is installed.

default.nix like this:

{
  python3Packages,
  fetchFromGitea,
  fetchFromGitHub,
  writeText,
}:
let
  thumbhash = python3Packages.buildPythonPackage (finalAttrs: {
    pname = "thumbhash";
    version = "0.1.2";
    pyproject = true;

    src = fetchFromGitHub {
      owner = "justinforlenza";
      repo = "thumbhash-py";
      tag = "v0.1.2";
      hash = "sha256-caOMW2hB+Be0SJToWrE51qb+ex/iVRH29oHwfsIcTXw=";
    };

    build-system = with python3Packages; [
      hatchling
    ];

    dependencies = with python3Packages; [
      pillow
    ];

    doCheck = false;

    pythonImportsCheck = [ "thumbhash" ];

    patches = [
      (writeText "pyproject-fix.patch" ''
        --- a/pyproject.toml
        +++ b/pyproject.toml
        @@ -49,6 +49,9 @@ dependencies = [
         cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=thumbhash --cov=tests {args}"
         no-cov = "cov --no-cov {args}"

        +[tool.hatch.build.targets.wheel]
        +packages = ["thumbhash"]
        +
         [[tool.hatch.envs.test.matrix]]
         python = ["37", "38", "39", "310", "311"]
      '')
    ];

    meta = {
      # ...
    };
  });
in

python3Packages.buildPythonPackage (finalAttrs: {
  pname = "slidge";
  version = "0.3.11";
  pyproject = true;
  # dontCheckRuntimeDeps = true; # it cannot detech thumbhash installation

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "slidge";
    repo = "slidge";
    tag = "v${finalAttrs.version}";
    hash = "sha256-IUfeNn/zp1iyMSu60VAtJ5A74Q9zTh37B+LFNa6VVLA=";
  };
  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail 'pillow~=11.0' 'pillow' \
      --replace-fail 'defusedxml~=0.7.1' 'defusedxml' \
      --replace-fail 'slixmpp~=1.14.1' 'slixmpp'
  '';

  build-system = with python3Packages; [
    setuptools-scm
  ];

  dependencies =
    with python3Packages;
    [
      slixmpp
      aiohttp
      qrcode
      configargparse
      blurhash

      alembic
      defusedxml
      pillow
      python-magic
      sqlalchemy
    ]
    ++ [
      thumbhash
    ];

  meta = {
    # ...
  };
})

When running nix-build --expr 'with import <nixpkgs> {}; callPackage ./default.nix {}' in the same folder, It throws error:

Successfully built slidge-0.3.11-py3-none-any.whl
Finished creating a wheel...
Finished executing pypaBuildPhase
Running phase: pythonRuntimeDepsCheckHook
@nix { "action": "setPhase", "phase": "pythonRuntimeDepsCheckHook" }
Executing pythonRuntimeDepsCheck
Checking runtime dependencies for slidge-0.3.11-py3-none-any.whl
  - thumbhash not installed

I cannot pass pythonRuntimeDepsCheck to trick thumbhash is installed unless I set dontCheckRuntimeDeps = true; and I think it is not a good solution. How can I solve this problem? Thanks!

Or is dontCheckRuntimeDeps = true; is the correct way to go? I found some packages in nixpkgs also use this line.

I just want to know why pythonRuntimeDepsCheck thinks it is not installed.

the issue is that slidge depends on “thumbhash” but thumbhash-py/pyproject.toml at 9706ca2168b32a15388a616b4795e8c0a8ff8297 · justinforlenza/thumbhash-py · GitHub name is “thumbhash-py“ , on master they renamed it to thumbhash

you can patch name in pyproject.toml, or you can update to master version, or you can use pythonRelaxDepsHook in slidge to remove check for thumbhash

Thanks, patching name in pypreject.toml works! Its name in v0.1.2 branch is incorrect but in main branch it is correct… I was tricked by the main branch as I forgot to switch it.