Commit 9f384078 authored by Anderson Torres's avatar Anderson Torres
Browse files

pyp: refactor

- Merge and refactor the two packages
  - pyp and python3Packages.pyp should be the same file!
- set bc and jq appropriately
- get rid of rec
- get rid of nested with
- set pyproject
- set meta.mainProgram
parent 4387bbfa
Loading
Loading
Loading
Loading

pkgs/by-name/py/pyp/package.nix

deleted100644 → 0
+0 −51
Original line number Diff line number Diff line
{ lib
, fetchFromGitHub
, python3
, bc
, jq
}:

let
  version = "1.1.0";
in python3.pkgs.buildPythonApplication {
  pname = "pyp";
  inherit version;
  format = "pyproject";

  src = fetchFromGitHub {
    owner = "hauntsaninja";
    repo = "pyp";
    rev = "v${version}";
    hash = "sha256-A1Ip41kxH17BakHEWEuymfa24eBEl5FIHAWL+iZFM4I=";
  };

  nativeBuildInputs = [
    python3.pkgs.flit-core
  ];

  nativeCheckInputs = [
    python3.pkgs.pytestCheckHook
    bc
    jq
  ];

  # without this, the tests fail because they are unable to find the pyp tool
  # itself...
  preCheck = ''
     _OLD_PATH_=$PATH
     PATH=$out/bin:$PATH
  '';

  # And a cleanup
  postCheck = ''
    PATH=$_OLD_PATH_
  '';

  meta = {
    homepage = "https://github.com/hauntsaninja/pyp";
    description = "Easily run Python at the shell";
    changelog = "https://github.com/hauntsaninja/pyp/blob/${version}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ AndersonTorres ];
  };
}
+58 −46
Original line number Diff line number Diff line
{ lib
, astunparse
, bc
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, coreutils
, pythonOlder
, astunparse
, flit-core
, jq
, bc
, pytestCheckHook
, pythonOlder
}:

buildPythonPackage rec {
let
  finalAttrs = {
    pname = "pyp";
    version = "1.2.0";
  format = "pyproject";

  disabled = pythonOlder "3.6";

    src = fetchFromGitHub {
      owner = "hauntsaninja";
    repo = pname;
    rev = "refs/tags/v${version}";
      repo = "pyp";
      rev = "refs/tags/v${finalAttrs.version}";
      hash = "sha256-hnEgqWOIVj2ugOhd2aS9IulfkVnrlkhwOtrgH4qQqO8=";
    };

    pyproject = true;

    disabled = pythonOlder "3.6";

    nativeBuildInputs = [
      flit-core
    ];

  propagatedBuildInputs = lib.optionals (pythonOlder "3.9") [
    astunparse
  ];

  preCheck = ''
    export PATH=$out/bin:$PATH
  '';

    nativeCheckInputs = [
      pytestCheckHook
    coreutils
    jq
      bc
      jq
    ];

    propagatedBuildInputs = lib.optionals (pythonOlder "3.9") [
      astunparse
    ];

    pythonImportsCheck = [
      "pyp"
    ];

  meta = with lib; {
    description = "Easily run Python at the shell! Magical, but never mysterious";
    # without this, the tests fail because they are unable to find the pyp tool
    # itself...
    preCheck = ''
      _OLD_PATH_=$PATH
      PATH=$out/bin:$PATH
   '';

    # And a cleanup!
    postCheck = ''
      PATH=$_OLD_PATH_
    '';

    meta = {
      homepage = "https://github.com/hauntsaninja/pyp";
    license = licenses.mit;
    maintainers = with maintainers; [ rmcgibbo ];
      description = "Easily run Python at the shell";
      changelog = "https://github.com/hauntsaninja/pyp/blob/${finalAttrs.version}/CHANGELOG.md";
      license = with lib.licenses; [ mit ];
      mainProgram = "pyp";
      maintainers = with lib.maintainers; [ rmcgibbo AndersonTorres ];
    };
  };
}
in
buildPythonPackage finalAttrs
+3 −0
Original line number Diff line number Diff line
@@ -12341,6 +12341,9 @@ with pkgs;
  pywal = with python3Packages; toPythonApplication pywal;
  # pyp: tests fail on Python 3.11 -- why?
  pyp = with python310Packages; toPythonApplication pyp;
  pystring = callPackage ../development/libraries/pystring { };
  raysession = python3Packages.callPackage ../applications/audio/raysession {};
+1 −1
Original line number Diff line number Diff line
@@ -11160,7 +11160,7 @@ self: super: with self; {
  pyomo = callPackage ../development/python-modules/pyomo { };
  pyp = callPackage ../development/python-modules/pyp {
    inherit (pkgs) jq;
    inherit (pkgs) bc jq;
  };
  pypng = callPackage ../development/python-modules/pypng { };