From 9f3840785bed83234dd27b293ad30b38e4aece29 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Thu, 7 Mar 2024 21:56:58 -0300 Subject: [PATCH 1/4] 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 --- pkgs/by-name/py/pyp/package.nix | 51 --------- .../python-modules/pyp/default.nix | 104 ++++++++++-------- pkgs/top-level/all-packages.nix | 3 + pkgs/top-level/python-packages.nix | 2 +- 4 files changed, 62 insertions(+), 98 deletions(-) delete mode 100644 pkgs/by-name/py/pyp/package.nix diff --git a/pkgs/by-name/py/pyp/package.nix b/pkgs/by-name/py/pyp/package.nix deleted file mode 100644 index 1ba4629220db..000000000000 --- a/pkgs/by-name/py/pyp/package.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ 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 ]; - }; -} diff --git a/pkgs/development/python-modules/pyp/default.nix b/pkgs/development/python-modules/pyp/default.nix index 49f4c0a96577..48b49ae6ddcc 100644 --- a/pkgs/development/python-modules/pyp/default.nix +++ b/pkgs/development/python-modules/pyp/default.nix @@ -1,56 +1,68 @@ { lib +, astunparse +, bc , buildPythonPackage , fetchFromGitHub -, pytestCheckHook -, coreutils -, pythonOlder -, astunparse , flit-core , jq -, bc +, pytestCheckHook +, pythonOlder }: -buildPythonPackage rec { - pname = "pyp"; - version = "1.2.0"; - format = "pyproject"; +let + finalAttrs = { + pname = "pyp"; + version = "1.2.0"; - disabled = pythonOlder "3.6"; + src = fetchFromGitHub { + owner = "hauntsaninja"; + repo = "pyp"; + rev = "refs/tags/v${finalAttrs.version}"; + hash = "sha256-hnEgqWOIVj2ugOhd2aS9IulfkVnrlkhwOtrgH4qQqO8="; + }; - src = fetchFromGitHub { - owner = "hauntsaninja"; - repo = pname; - rev = "refs/tags/v${version}"; - hash = "sha256-hnEgqWOIVj2ugOhd2aS9IulfkVnrlkhwOtrgH4qQqO8="; + pyproject = true; + + disabled = pythonOlder "3.6"; + + nativeBuildInputs = [ + flit-core + ]; + + nativeCheckInputs = [ + pytestCheckHook + bc + jq + ]; + + propagatedBuildInputs = lib.optionals (pythonOlder "3.9") [ + astunparse + ]; + + pythonImportsCheck = [ + "pyp" + ]; + + # 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/${finalAttrs.version}/CHANGELOG.md"; + license = with lib.licenses; [ mit ]; + mainProgram = "pyp"; + maintainers = with lib.maintainers; [ rmcgibbo AndersonTorres ]; + }; }; - - nativeBuildInputs = [ - flit-core - ]; - - propagatedBuildInputs = lib.optionals (pythonOlder "3.9") [ - astunparse - ]; - - preCheck = '' - export PATH=$out/bin:$PATH - ''; - - nativeCheckInputs = [ - pytestCheckHook - coreutils - jq - bc - ]; - - pythonImportsCheck = [ - "pyp" - ]; - - meta = with lib; { - description = "Easily run Python at the shell! Magical, but never mysterious"; - homepage = "https://github.com/hauntsaninja/pyp"; - license = licenses.mit; - maintainers = with maintainers; [ rmcgibbo ]; - }; -} +in +buildPythonPackage finalAttrs diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bed825679f8c..839bb25e44e6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 {}; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 377d5e2587d1..b57def8367b5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -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 { }; From 5211205ca9a44c3eff29c940d4238bd87aa733fc Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Thu, 7 Mar 2024 22:08:17 -0300 Subject: [PATCH 2/4] pyp: remove restriction on 3.10 --- pkgs/top-level/all-packages.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 839bb25e44e6..9d6338538841 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12341,8 +12341,7 @@ with pkgs; pywal = with python3Packages; toPythonApplication pywal; - # pyp: tests fail on Python 3.11 -- why? - pyp = with python310Packages; toPythonApplication pyp; + pyp = with python3Packages; toPythonApplication pyp; pystring = callPackage ../development/libraries/pystring { }; From d6599f77f65c65cfb4dac3dd8eec52f21bd4e6ce Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Fri, 8 Mar 2024 14:42:06 -0300 Subject: [PATCH 3/4] pyp: update expression according to new guidelines --- pkgs/development/python-modules/pyp/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/pyp/default.nix b/pkgs/development/python-modules/pyp/default.nix index 48b49ae6ddcc..45ad9832aac0 100644 --- a/pkgs/development/python-modules/pyp/default.nix +++ b/pkgs/development/python-modules/pyp/default.nix @@ -23,9 +23,9 @@ let pyproject = true; - disabled = pythonOlder "3.6"; + disabled = pythonOlder "3.8"; - nativeBuildInputs = [ + build-system = [ flit-core ]; @@ -35,7 +35,7 @@ let jq ]; - propagatedBuildInputs = lib.optionals (pythonOlder "3.9") [ + dependencies = lib.optionals (pythonOlder "3.9") [ astunparse ]; From cd975261c7594517908b1c39d39a9197baf3b28d Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Fri, 8 Mar 2024 15:26:06 -0300 Subject: [PATCH 4/4] pyp: migrate it to by-name hierarchy Since it is not used as library, it makes no sense to deploy it as a library. --- .../py/pyp/package.nix} | 20 ++++++------------- pkgs/top-level/all-packages.nix | 2 -- pkgs/top-level/python-packages.nix | 4 ---- 3 files changed, 6 insertions(+), 20 deletions(-) rename pkgs/{development/python-modules/pyp/default.nix => by-name/py/pyp/package.nix} (79%) diff --git a/pkgs/development/python-modules/pyp/default.nix b/pkgs/by-name/py/pyp/package.nix similarity index 79% rename from pkgs/development/python-modules/pyp/default.nix rename to pkgs/by-name/py/pyp/package.nix index 45ad9832aac0..08f3fdc63d49 100644 --- a/pkgs/development/python-modules/pyp/default.nix +++ b/pkgs/by-name/py/pyp/package.nix @@ -1,15 +1,12 @@ { lib -, astunparse , bc -, buildPythonPackage , fetchFromGitHub -, flit-core , jq -, pytestCheckHook -, pythonOlder +, python3 }: let + pythonPackages = python3.pkgs; finalAttrs = { pname = "pyp"; version = "1.2.0"; @@ -23,22 +20,17 @@ let pyproject = true; - disabled = pythonOlder "3.8"; - - build-system = [ + build-system = with pythonPackages; [ flit-core ]; - nativeCheckInputs = [ + nativeCheckInputs = (with pythonPackages; [ pytestCheckHook + ]) ++ [ bc jq ]; - dependencies = lib.optionals (pythonOlder "3.9") [ - astunparse - ]; - pythonImportsCheck = [ "pyp" ]; @@ -65,4 +57,4 @@ let }; }; in -buildPythonPackage finalAttrs +pythonPackages.buildPythonPackage finalAttrs diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9d6338538841..bed825679f8c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12341,8 +12341,6 @@ with pkgs; pywal = with python3Packages; toPythonApplication pywal; - pyp = with python3Packages; toPythonApplication pyp; - pystring = callPackage ../development/libraries/pystring { }; raysession = python3Packages.callPackage ../applications/audio/raysession {}; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index b57def8367b5..b3fd636ee42e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -11159,10 +11159,6 @@ self: super: with self; { pyomo = callPackage ../development/python-modules/pyomo { }; - pyp = callPackage ../development/python-modules/pyp { - inherit (pkgs) bc jq; - }; - pypng = callPackage ../development/python-modules/pypng { }; phonemizer = callPackage ../development/python-modules/phonemizer { };