<commit_before>{ lib
, fetchFromGitHub
, buildPythonPackage
, pythonOlder
, smbus-cffi
, urwid
}:

buildPythonPackage rec {
  pname = "pijuice";
  version = "1.7";
  disabled = pythonOlder "3.6";

  src = fetchFromGitHub {
    owner = "PiSupply";
    repo = "PiJuice";
    # rev hash retrieved from the latest modification on file Software/Source/VERSION, as this project
    # does not use Github tags facility
    rev = "3ba6719ab614a3dc7495d5d9c900dd4ea977c7e3";
    sha256 = "GoNN07YgVaktpeY5iYDbfpy5fxkU1x0V3Sb1hgGAQt4=";
  };

  patches = [
    # The pijuice_cli.cli file doesn't have a shebang as the first line of the
    # script. Without it, the pythonWrapPrograms hook will not wrap the program.
    # Add a python shebang here so that the the hook is triggered.
    ./patch-shebang.diff
  ];

  PIJUICE_BUILD_BASE = 1;

  preBuild = ''
    cd Software/Source
  '';

  propagatedBuildInputs = [ smbus-cffi urwid ];

  # Remove the following files from the package:
  #
  # pijuice_cli - A precompiled ELF binary that is a setuid wrapper for calling
  #               pijuice_cli.py
  #
  # pijuiceboot - a precompiled ELF binary for flashing firmware. Not needed for
  #               the python library.
  #
  # pijuice_sys.py - A program that acts as a system daemon for monitoring the
  #                  pijuice.
  preFixup = ''
    rm $out/bin/pijuice_cli
    rm $out/bin/pijuice_sys.py
    rm $out/bin/pijuiceboot
    mv $out/bin/pijuice_cli.py $out/bin/pijuice_cli
   '';

  meta = with lib; {
    description = "Library and resources for PiJuice HAT for Raspberry Pi";
    homepage = "https://github.com/PiSupply/PiJuice";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ hexagonal-sun ];
  };
}
<commit_msg>pijuice: fix for python 3.9<commit_after>{ lib
, fetchFromGitHub
, buildPythonPackage
, pythonOlder
, smbus-cffi
, urwid
}:

buildPythonPackage rec {
  pname = "pijuice";
  version = "1.7";
  disabled = pythonOlder "3.6";

  src = fetchFromGitHub {
    owner = "PiSupply";
    repo = "PiJuice";
    # Latest commit that fixes using the library against python 3.9 by renaming
    # isAlive() to is_alive(). The former function was removed in python 3.9.
    rev = "e2dca1f8dcfa12e009952a882c0674a545d193d6";
    sha256 = "07Jr7RSjqI8j0tT0MNAjrN1sjF1+mI+V0vtKInvtxj8=";
  };

  patches = [
    # The pijuice_cli.cli file doesn't have a shebang as the first line of the
    # script. Without it, the pythonWrapPrograms hook will not wrap the program.
    # Add a python shebang here so that the the hook is triggered.
    ./patch-shebang.diff
  ];

  PIJUICE_BUILD_BASE = 1;

  preBuild = ''
    cd Software/Source
  '';

  propagatedBuildInputs = [ smbus-cffi urwid ];

  # Remove the following files from the package:
  #
  # pijuice_cli - A precompiled ELF binary that is a setuid wrapper for calling
  #               pijuice_cli.py
  #
  # pijuiceboot - a precompiled ELF binary for flashing firmware. Not needed for
  #               the python library.
  #
  # pijuice_sys.py - A program that acts as a system daemon for monitoring the
  #                  pijuice.
  preFixup = ''
    rm $out/bin/pijuice_cli
    rm $out/bin/pijuice_sys.py
    rm $out/bin/pijuiceboot
    mv $out/bin/pijuice_cli.py $out/bin/pijuice_cli
   '';

  meta = with lib; {
    description = "Library and resources for PiJuice HAT for Raspberry Pi";
    homepage = "https://github.com/PiSupply/PiJuice";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ hexagonal-sun ];
  };
}

{'fraction_non_alphanumeric': 0.09039387928591669, 'fraction_numerical': 0.02606970813261547, 'mean_word_length': 2.879120879120879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4621485', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1237, 'n_words': 346}