<commit_before>{ stdenv
, fetchFromGitHub
, gtk3
, gettext
, json_c
, lcms2
, libpng
, librsvg
, gobject-introspection
, libmypaint
, mypaint-brushes
, gdk-pixbuf
, pkgconfig
, python3
, swig
, wrapGAppsHook
}:

let
  inherit (python3.pkgs) pycairo pygobject3 numpy buildPythonApplication;
in buildPythonApplication rec {
  pname = "mypaint";
  version = "2.0.1";

  src = fetchFromGitHub {
    owner = "mypaint";
    repo = "mypaint";
    rev = "v${version}";
    sha256 = "rVKcxzWZRLcuxK8xRyRgvitXAh4uOEyqHswLeTdA2Mk=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    gettext
    pkgconfig
    swig
    wrapGAppsHook
    gobject-introspection # for setup hook
  ];
  buildInputs = [
    gtk3
    gdk-pixbuf
    libmypaint
    mypaint-brushes
    json_c
    lcms2
    libpng
    librsvg
    pycairo
    pygobject3
  ];

  propagatedBuildInputs = [
    numpy
    pycairo
    pygobject3
  ];

  checkInputs = [
    gtk3
  ];

  buildPhase = ''
    runHook preBuild

    ${python3.interpreter} setup.py build

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    ${python3.interpreter} setup.py managed_install --prefix=$out

    runHook postInstall
  '';

  checkPhase = ''<commit_msg>mypaint: fix crash without hicolor-icon-theme<commit_after>{ stdenv
, fetchFromGitHub
, gtk3
, gettext
, json_c
, lcms2
, libpng
, librsvg
, gobject-introspection
, libmypaint
, hicolor-icon-theme
, mypaint-brushes
, gdk-pixbuf
, pkgconfig
, python3
, swig
, wrapGAppsHook
}:

let
  inherit (python3.pkgs) pycairo pygobject3 numpy buildPythonApplication;
in buildPythonApplication rec {
  pname = "mypaint";
  version = "2.0.1";

  src = fetchFromGitHub {
    owner = "mypaint";
    repo = "mypaint";
    rev = "v${version}";
    sha256 = "rVKcxzWZRLcuxK8xRyRgvitXAh4uOEyqHswLeTdA2Mk=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    gettext
    pkgconfig
    swig
    wrapGAppsHook
    gobject-introspection # for setup hook
    hicolor-icon-theme # fór setup hook
  ];

  buildInputs = [
    gtk3
    gdk-pixbuf
    libmypaint
    mypaint-brushes
    json_c
    lcms2
    libpng
    librsvg
    pycairo
    pygobject3

    # Mypaint checks for a presence of this theme scaffold and crashes when not present.
    hicolor-icon-theme
  ];

  propagatedBuildInputs = [
    numpy
    pycairo
    pygobject3
  ];

  checkInputs = [
    gtk3
  ];

  buildPhase = ''
    runHook preBuild

    ${python3.interpreter} setup.py build

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    ${python3.interpreter} setup.py managed_install --prefix=$out

    runHook postInstall
  '';

  checkPhase = ''
{'fraction_non_alphanumeric': 0.09090909090909091, 'fraction_numerical': 0.015843078083741986, 'mean_word_length': 2.8715328467153283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3824868', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1000, 'n_words': 198}