Files
Sam 5dc59002fd python312Packages.mobi: exclude standard-imghdr to fix build
Our `standard-*` packages are set up to be null on the Python versions
that still include the corresponding module in the standard library.
However, since mobi depends on standard-imghdr unconditionally, using
the package on versions of Python that still have imghdr in the standard
library fails to build due to the following sequence of steps:

1. Something calls `python312Packages.mobi`.
2. `standard-imghdr` in the dependencies resolves to `null`, since
   `imghdr` is still in the standard library on Python 3.12 and we have
   the `standard-imghdr` package set to be null on versions of Python
   where `imghdr` is in the standard library.
3. `pythonRuntimeDepsCheck` runs.
4. `pythonRuntimeDepsCheck` sees `Requires-Dist: standard-imghdr` in
   mobi's distinfo metadata and checks whether the package is installed.
5. It is not, so the runtime deps check fails the build.

We solve this issue by removing `standard-imghdr` from the list of
dependencies on versions of Python where the package is set to `null`
(those versions that have `imghdr` in the standard library). The package
continues to work because it will transparently import the standard
library version of `imghdr`.
2026-04-12 14:27:13 -07:00

49 lines
890 B
Nix

{
lib,
buildPythonPackage,
fetchFromGitHub,
loguru,
hatchling,
standard-imghdr,
pytestCheckHook,
pythonOlder,
}:
buildPythonPackage rec {
pname = "mobi";
version = "0.4.1";
pyproject = true;
src = fetchFromGitHub {
owner = "iscc";
repo = "mobi";
tag = "v${version}";
hash = "sha256-Hbw4TX/yKkuxYQ9vZZp/wasDCop8pvyQc5zWloMQbng=";
};
build-system = [ hatchling ];
pythonRelaxDeps = [ "loguru" ];
dependencies = [
loguru
standard-imghdr
];
pythonRemoveDeps = lib.optionals (pythonOlder "3.13") [ "standard-imghdr" ];
nativeCheckInputs = [
pytestCheckHook
];
pythonImportsCheck = [ "mobi" ];
meta = {
description = "Library for unpacking unencrypted mobi files";
mainProgram = "mobiunpack";
homepage = "https://github.com/iscc/mobi";
license = lib.licenses.gpl3Only;
maintainers = [ ];
};
}