diff --git a/pkgs/by-name/py/pywal16/package.nix b/pkgs/by-name/py/pywal16/package.nix index dd1012e9f8eb..b7a340e45819 100644 --- a/pkgs/by-name/py/pywal16/package.nix +++ b/pkgs/by-name/py/pywal16/package.nix @@ -2,9 +2,17 @@ lib, python3, fetchFromGitHub, - imagemagick, installShellFiles, nix-update-script, + + imagemagick, + colorz, + + withColorthief ? false, + withColorz ? false, + withFastColorthief ? false, + withHaishoku ? false, + withModernColorthief ? false, }: python3.pkgs.buildPythonApplication rec { @@ -23,11 +31,22 @@ python3.pkgs.buildPythonApplication rec { nativeBuildInputs = [ installShellFiles ]; + dependencies = + lib.optionals withColorthief optional-dependencies.colorthief + ++ lib.optionals withColorz optional-dependencies.colorz + ++ lib.optionals withFastColorthief optional-dependencies.fast-colorthief + ++ lib.optionals withHaishoku optional-dependencies.haishoku + ++ lib.optionals withModernColorthief optional-dependencies.modern_colorthief; + nativeCheckInputs = [ python3.pkgs.pytestCheckHook imagemagick ]; + makeWrapperArgs = [ + "--prefix PATH : ${lib.makeBinPath ([ imagemagick ] ++ lib.optional withColorz colorz)}" + ]; + postInstall = '' installManPage data/man/man1/wal.1 ''; @@ -43,11 +62,13 @@ python3.pkgs.buildPythonApplication rec { colorz = [ colorz ]; fast-colorthief = [ fast-colorthief ]; haishoku = [ haishoku ]; + modern_colorthief = [ modern-colorthief ]; all = [ colorthief colorz - ast-colorthief + fast-colorthief haishoku + modern-colorthief ]; }; diff --git a/pkgs/development/python-modules/fast-colorthief/default.nix b/pkgs/development/python-modules/fast-colorthief/default.nix new file mode 100644 index 000000000000..4568b8d66b91 --- /dev/null +++ b/pkgs/development/python-modules/fast-colorthief/default.nix @@ -0,0 +1,56 @@ +{ + lib, + buildPythonPackage, + fetchPypi, + setuptools, + cmake, + nix-update-script, + + numpy, + pillow, +}: + +buildPythonPackage rec { + pname = "fast-colorthief"; + version = "0.0.5"; + pyproject = true; + + # No tags on github + src = fetchPypi { + inherit pname version; + hash = "sha256-yUO1vnOt2NPyldPjFMn0jbhVX8zHcKsJ2IFVugYBZa4="; + }; + + postPatch = '' + substituteInPlace CMakeLists.txt --replace-fail \ + "cmake_minimum_required(VERSION 2.8.12)" \ + "cmake_minimum_required(VERSION 3.10)" + substituteInPlace pybind11/CMakeLists.txt --replace-fail \ + "cmake_minimum_required(VERSION 3.4)" \ + "cmake_minimum_required(VERSION 3.10)" + ''; + + build-system = [ + setuptools + cmake + ]; + + dependencies = [ + pillow + numpy + ]; + + # return to project root to locate pyproject.toml for build + preBuild = "cd .."; + + pythonImportsCheck = [ "fast_colorthief" ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Selection of most dominant colors in image using Modified Median Cut Quantization"; + homepage = "https://github.com/bedapisl/fast-colorthief"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ moraxyc ]; + }; +} diff --git a/pkgs/development/python-modules/haishoku/default.nix b/pkgs/development/python-modules/haishoku/default.nix new file mode 100644 index 000000000000..d8f066185a25 --- /dev/null +++ b/pkgs/development/python-modules/haishoku/default.nix @@ -0,0 +1,40 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + nix-update-script, + + pillow, +}: + +buildPythonPackage rec { + pname = "haishoku"; + version = "1.1.8"; + pyproject = true; + + src = fetchFromGitHub { + owner = "LanceGin"; + repo = "haishoku"; + tag = "v${version}"; + hash = "sha256-LSoZopCaM5vbknGS9gG13OZIgghgqJvPtktUkBCH04Q="; + }; + + build-system = [ setuptools ]; + + dependencies = [ pillow ]; + + # no test + doCheck = false; + + pythonImportsCheck = [ "haishoku" ]; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Development tool for grabbing the dominant color or representative color palette from an image"; + homepage = "https://github.com/LanceGin/haishoku"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ moraxyc ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 997a8b53bdce..e1564a7a7234 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5208,6 +5208,8 @@ self: super: with self; { fast-array-utils = callPackage ../development/python-modules/fast-array-utils { }; + fast-colorthief = callPackage ../development/python-modules/fast-colorthief { }; + fast-histogram = callPackage ../development/python-modules/fast-histogram { }; fast-query-parsers = callPackage ../development/python-modules/fast-query-parsers { }; @@ -6676,6 +6678,8 @@ self: super: with self; { hacking = callPackage ../development/python-modules/hacking { }; + haishoku = callPackage ../development/python-modules/haishoku { }; + hakuin = callPackage ../development/python-modules/hakuin { }; halide =