From eeb13b181f785d928c85384de94483453e3d0be9 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 15:31:53 +0100 Subject: [PATCH 1/9] grin: modernize --- pkgs/tools/text/grin/default.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/text/grin/default.nix b/pkgs/tools/text/grin/default.nix index 5217451a984b..a993ded3c884 100644 --- a/pkgs/tools/text/grin/default.nix +++ b/pkgs/tools/text/grin/default.nix @@ -1,13 +1,19 @@ -{ lib, fetchFromGitHub, fetchpatch, python3Packages }: +{ + lib, + fetchFromGitHub, + fetchpatch, + python3Packages, +}: -python3Packages.buildPythonApplication rec { +python3Packages.buildPythonApplication { pname = "grin"; version = "1.3.0"; namePrefix = ""; + pyproject = true; src = fetchFromGitHub { owner = "matthew-brett"; - repo = pname; + repo = "grin"; rev = "1.3.0"; hash = "sha256-exKUy7LaDtpq0rJLSuNYsIcynpB4QLtLIE6T/ncB7RQ="; }; @@ -21,9 +27,9 @@ python3Packages.buildPythonApplication rec { }) ]; - nativeCheckInputs = with python3Packages; [ - nose3 - ]; + build-system = [ python3Packages.setuptools ]; + + nativeCheckInputs = with python3Packages; [ nose3 ]; meta = { homepage = "https://github.com/matthew-brett/grin"; From 22af46b51256a504531630d48425256374299911 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 15:31:53 +0100 Subject: [PATCH 2/9] grin: 1.3.0 -> 1.3.0-unstable-2023-08-30 --- pkgs/tools/text/grin/default.nix | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pkgs/tools/text/grin/default.nix b/pkgs/tools/text/grin/default.nix index a993ded3c884..4a8e0d7a916f 100644 --- a/pkgs/tools/text/grin/default.nix +++ b/pkgs/tools/text/grin/default.nix @@ -1,35 +1,25 @@ { lib, fetchFromGitHub, - fetchpatch, python3Packages, }: python3Packages.buildPythonApplication { pname = "grin"; - version = "1.3.0"; + version = "1.3.0-unstable-2023-08-30"; namePrefix = ""; pyproject = true; src = fetchFromGitHub { owner = "matthew-brett"; repo = "grin"; - rev = "1.3.0"; - hash = "sha256-exKUy7LaDtpq0rJLSuNYsIcynpB4QLtLIE6T/ncB7RQ="; + rev = "00e11ebf17bbb37dc33d282eac1282c0bcc07e82"; + hash = "sha256-0lrCOXFb2v0hCxWd9O7ysbn8CjPd8NHOJhARYzJJcYg="; }; - patches = [ - # https://github.com/matthew-brett/grin/pull/4 - (fetchpatch { - name = "replace-nose-with-nose3.patch"; - url = "https://github.com/matthew-brett/grin/commit/ba473fa4f5da1b337ee80d7d31772a4e41ffa62d.patch"; - hash = "sha256-CnWHynKSsXYjSsTLdPuwpcIndrCdq3cQYS8teg5EM0A="; - }) - ]; - build-system = [ python3Packages.setuptools ]; - nativeCheckInputs = with python3Packages; [ nose3 ]; + nativeCheckInputs = [ python3Packages.pytestCheckHook ]; meta = { homepage = "https://github.com/matthew-brett/grin"; From 4094f03ffdaa27004b7e8a0b721d24ca028a9f8e Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 16:33:25 +0100 Subject: [PATCH 3/9] svtplay-dl: use `buildPythonApplication` --- pkgs/tools/misc/svtplay-dl/default.nix | 88 ++++++++++++++++---------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/pkgs/tools/misc/svtplay-dl/default.nix b/pkgs/tools/misc/svtplay-dl/default.nix index 29ab8c493219..2805d07b2d26 100644 --- a/pkgs/tools/misc/svtplay-dl/default.nix +++ b/pkgs/tools/misc/svtplay-dl/default.nix @@ -1,27 +1,36 @@ -{ lib -, stdenv -, fetchFromGitHub -, makeWrapper -, python3Packages -, perl -, zip -, gitMinimal -, ffmpeg +{ + lib, + fetchFromGitHub, + installShellFiles, + python3Packages, + perl, + ffmpeg, + gitMinimal, }: let inherit (python3Packages) - python pytest nose3 cryptography pyyaml requests mock requests-mock - python-dateutil setuptools; + buildPythonApplication + setuptools + requests + pysocks + cryptography + pyyaml + nose3 + pytest + mock + requests-mock + ; version = "4.97.1"; in -stdenv.mkDerivation rec { +buildPythonApplication { pname = "svtplay-dl"; inherit version; + pyproject = true; src = fetchFromGitHub { owner = "spaam"; @@ -30,47 +39,56 @@ stdenv.mkDerivation rec { hash = "sha256-9h3hHRRL7DKeCpEXL5w72hYi1nTS+a+x5e9ArMmVgYQ="; }; - pythonPaths = [ cryptography pyyaml requests ]; - buildInputs = [ python perl python-dateutil setuptools ] ++ pythonPaths; - nativeBuildInputs = [ gitMinimal zip makeWrapper ]; - nativeCheckInputs = [ nose3 pytest mock requests-mock ]; + build-system = [ setuptools ]; - postPatch = '' - substituteInPlace scripts/run-tests.sh \ - --replace 'PYTHONPATH=lib' 'PYTHONPATH=lib:$PYTHONPATH' + dependencies = [ + requests + pysocks + cryptography + pyyaml + ]; - sed -i '/def test_sublang2\?(/ i\ @unittest.skip("accesses network")' \ - lib/svtplay_dl/tests/test_postprocess.py - ''; + nativeBuildInputs = [ + # For `pod2man(1)`. + perl + installShellFiles + ]; - makeFlags = [ "PREFIX=$(out)" "SYSCONFDIR=$(out)/etc" "PYTHON=${python.interpreter}" ]; + nativeCheckInputs = [ + nose3 + pytest + mock + requests-mock + gitMinimal + ]; - postInstall = '' - wrapProgram "$out/bin/svtplay-dl" \ - --prefix PATH : "${ffmpeg}" \ - --prefix PYTHONPATH : "$PYTHONPATH" + postBuild = '' + make svtplay-dl.1 ''; doCheck = python3Packages.pythonOlder "3.12"; + checkPhase = '' runHook preCheck - sh scripts/run-tests.sh -2 + nosetests --all-modules --with-doctest runHook postCheck ''; - doInstallCheck = true; - installCheckPhase = '' - runHook preInstallCheck - $out/bin/svtplay-dl --help > /dev/null - runHook postInstallCheck + postInstall = '' + installManPage svtplay-dl.1 + makeWrapperArgs+=(--prefix PATH : "${lib.makeBinPath [ ffmpeg ]}") ''; - meta = with lib; { + postInstallCheck = '' + $out/bin/svtplay-dl --help > /dev/null + ''; + + meta = { homepage = "https://github.com/spaam/svtplay-dl"; description = "Command-line tool to download videos from svtplay.se and other sites"; - license = licenses.mit; + license = lib.licenses.mit; platforms = lib.platforms.unix; mainProgram = "svtplay-dl"; }; From 0fa536d5b27978048fd06e6547eea8f640c8d731 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 21:58:24 +0100 Subject: [PATCH 4/9] svtplay-dl: migrate to pytest --- pkgs/tools/misc/svtplay-dl/default.nix | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/pkgs/tools/misc/svtplay-dl/default.nix b/pkgs/tools/misc/svtplay-dl/default.nix index 2805d07b2d26..e0a0cfe9804c 100644 --- a/pkgs/tools/misc/svtplay-dl/default.nix +++ b/pkgs/tools/misc/svtplay-dl/default.nix @@ -5,7 +5,6 @@ python3Packages, perl, ffmpeg, - gitMinimal, }: let @@ -17,8 +16,7 @@ let pysocks cryptography pyyaml - nose3 - pytest + pytestCheckHook mock requests-mock ; @@ -55,27 +53,20 @@ buildPythonApplication { ]; nativeCheckInputs = [ - nose3 - pytest + pytestCheckHook mock requests-mock - gitMinimal + ]; + + pytestFlagsArray = [ + "--doctest-modules" + "lib" ]; postBuild = '' make svtplay-dl.1 ''; - doCheck = python3Packages.pythonOlder "3.12"; - - checkPhase = '' - runHook preCheck - - nosetests --all-modules --with-doctest - - runHook postCheck - ''; - postInstall = '' installManPage svtplay-dl.1 makeWrapperArgs+=(--prefix PATH : "${lib.makeBinPath [ ffmpeg ]}") From 7ef27e1420a824f8ac259574fab58868df0eee20 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 16:51:26 +0100 Subject: [PATCH 5/9] python3Packages.pkutils: drop --- .../python-modules/pkutils/default.nix | 45 ------------------- pkgs/top-level/python-aliases.nix | 1 + pkgs/top-level/python-packages.nix | 2 - 3 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 pkgs/development/python-modules/pkutils/default.nix diff --git a/pkgs/development/python-modules/pkutils/default.nix b/pkgs/development/python-modules/pkutils/default.nix deleted file mode 100644 index 724e991ee143..000000000000 --- a/pkgs/development/python-modules/pkutils/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - lib, - buildPythonPackage, - fetchFromGitHub, - nose3, - pythonOlder, - semver, -}: - -buildPythonPackage rec { - pname = "pkutils"; - version = "3.0.2"; - format = "setuptools"; - - disabled = pythonOlder "3.6"; - - src = fetchFromGitHub { - owner = "reubano"; - repo = "pkutils"; - rev = "refs/tags/v${version}"; - hash = "sha256-AK+xX+LPz6IVLZedsqMUm7G28ue0s3pXgIzxS4EHHLE="; - }; - - pythonRelaxDeps = [ "semver" ]; - - - propagatedBuildInputs = [ semver ]; - - nativeCheckInputs = [ nose3 ]; - - checkPhase = '' - runHook preCheck - nosetests - runHook postCheck - ''; - - pythonImportsCheck = [ "pkutils" ]; - - meta = with lib; { - description = "Python packaging utility library"; - homepage = "https://github.com/reubano/pkutils/"; - license = licenses.mit; - maintainers = with maintainers; [ drewrisinger ]; - }; -} diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index 273eb3f16751..61eedcce492e 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -360,6 +360,7 @@ mapAliases ({ pdfposter = throw "pdfposter was promoted to a top-level attribute"; # Added 2023-06-29 pdfminer = pdfminer-six; # added 2022-05-25 pep257 = pydocstyle; # added 2022-04-12 + pkutils = throw "pkutils was removed as it was unused and is not applicable to modern Python build tools"; # added 2024-07-28 poetry = throw "poetry was promoted to a top-level attribute, use poetry-core to build Python packages"; # added 2023-01-09 poetry2conda = throw "poetry2conda was promoted to a top-level attribute"; # Added 2022-10-02 Polygon3 = polygon3; # Added 2023-08-08 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 69b4d2db6f37..36532146e9b0 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10454,8 +10454,6 @@ self: super: with self; { pyzipper = callPackage ../development/python-modules/pyzipper { }; - pkutils = callPackage ../development/python-modules/pkutils { }; - plac = callPackage ../development/python-modules/plac { }; plaid-python = callPackage ../development/python-modules/plaid-python { }; From 5db8f3da5f1fde50eae7080a0593f31ebea69a9a Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 19:29:08 +0100 Subject: [PATCH 6/9] gixy: modernize --- pkgs/tools/admin/gixy/default.nix | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pkgs/tools/admin/gixy/default.nix b/pkgs/tools/admin/gixy/default.nix index dadf70e773ce..f998818d68a2 100644 --- a/pkgs/tools/admin/gixy/default.nix +++ b/pkgs/tools/admin/gixy/default.nix @@ -1,4 +1,8 @@ -{ lib, fetchFromGitHub, python311 }: +{ + lib, + fetchFromGitHub, + python311, +}: let python = python311.override { @@ -11,9 +15,7 @@ let rev = "pyparsing_${version}"; sha256 = "14pfy80q2flgzjcx8jkracvnxxnr59kjzp3kdm5nh232gk1v6g6h"; }; - nativeBuildInputs = [ - super.setuptools - ]; + nativeBuildInputs = [ super.setuptools ]; }; }; }; @@ -21,10 +23,7 @@ in python.pkgs.buildPythonApplication rec { pname = "gixy"; version = "0.1.20"; - format = "setuptools"; - - # package is only compatible with python 2.7 and 3.5+ - disabled = with python.pkgs; !(pythonAtLeast "3.5" || isPy27); + pyproject = true; # fetching from GitHub because the PyPi source is missing the tests src = fetchFromGitHub { @@ -34,21 +33,21 @@ python.pkgs.buildPythonApplication rec { sha256 = "14arz3fjidb8z37m08xcpih1391varj8s0v3gri79z3qb4zq5k6b"; }; - postPatch = '' - sed -ie '/argparse/d' setup.py - ''; + build-system = [ python.pkgs.setuptools ]; - propagatedBuildInputs = with python.pkgs; [ + dependencies = with python.pkgs; [ cached-property configargparse pyparsing jinja2 - nose3 - setuptools six ]; - meta = with lib; { + nativeCheckInputs = [ python.pkgs.nose3 ]; + + pythonRemoveDeps = [ "argparse" ]; + + meta = { description = "Nginx configuration static analyzer"; mainProgram = "gixy"; longDescription = '' @@ -56,8 +55,9 @@ python.pkgs.buildPythonApplication rec { The main goal of Gixy is to prevent security misconfiguration and automate flaw detection. ''; homepage = "https://github.com/yandex/gixy"; - license = licenses.mpl20; - maintainers = [ maintainers.willibutz ]; - platforms = platforms.unix; + sourceProvenance = [ lib.sourceTypes.fromSource ]; + license = lib.licenses.mpl20; + maintainers = [ lib.maintainers.willibutz ]; + platforms = lib.platforms.unix; }; } From 6bd2c7576ab97dffc4c0442c24efd7e40618c459 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 19:29:08 +0100 Subject: [PATCH 7/9] gixy: add pytest migration patch --- pkgs/tools/admin/gixy/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/admin/gixy/default.nix b/pkgs/tools/admin/gixy/default.nix index f998818d68a2..8d0fe24098f8 100644 --- a/pkgs/tools/admin/gixy/default.nix +++ b/pkgs/tools/admin/gixy/default.nix @@ -1,11 +1,12 @@ { lib, fetchFromGitHub, - python311, + fetchpatch2, + python3, }: let - python = python311.override { + python = python3.override { packageOverrides = self: super: { pyparsing = super.pyparsing.overridePythonAttrs rec { version = "2.4.7"; @@ -33,6 +34,15 @@ python.pkgs.buildPythonApplication rec { sha256 = "14arz3fjidb8z37m08xcpih1391varj8s0v3gri79z3qb4zq5k6b"; }; + patches = [ + # Migrate tests to pytest + # https://github.com/yandex/gixy/pull/146 + (fetchpatch2 { + url = "https://github.com/yandex/gixy/compare/6f68624a7540ee51316651bda656894dc14c9a3e...b1c6899b3733b619c244368f0121a01be028e8c2.patch"; + hash = "sha256-6VUF2eQ2Haat/yk8I5qIXhHdG9zLQgEXJMLfe25OKEo="; + }) + ]; + build-system = [ python.pkgs.setuptools ]; dependencies = with python.pkgs; [ @@ -43,7 +53,7 @@ python.pkgs.buildPythonApplication rec { six ]; - nativeCheckInputs = [ python.pkgs.nose3 ]; + nativeCheckInputs = [ python.pkgs.pytestCheckHook ]; pythonRemoveDeps = [ "argparse" ]; From 5111b7afd7a60d34c0fd475ed286de95e9bf6747 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 22:51:58 +0100 Subject: [PATCH 8/9] =?UTF-8?q?gixy:=20pass=E2=80=90through=20nginx=20test?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These exercise Gixy through the NixOS nginx module. --- pkgs/tools/admin/gixy/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/tools/admin/gixy/default.nix b/pkgs/tools/admin/gixy/default.nix index 8d0fe24098f8..157430dcecda 100644 --- a/pkgs/tools/admin/gixy/default.nix +++ b/pkgs/tools/admin/gixy/default.nix @@ -3,6 +3,7 @@ fetchFromGitHub, fetchpatch2, python3, + nginx, }: let @@ -57,6 +58,10 @@ python.pkgs.buildPythonApplication rec { pythonRemoveDeps = [ "argparse" ]; + passthru = { + inherit (nginx.passthru) tests; + }; + meta = { description = "Nginx configuration static analyzer"; mainProgram = "gixy"; From 9b7e7d74161b4ed14bea376c1dc07c0aad0bca15 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 28 Jul 2024 22:32:06 +0100 Subject: [PATCH 9/9] python3Packages.nose3: drop --- .../python-modules/nose3/default.nix | 42 ------------------- pkgs/top-level/python-aliases.nix | 1 + pkgs/top-level/python-packages.nix | 2 - 3 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 pkgs/development/python-modules/nose3/default.nix diff --git a/pkgs/development/python-modules/nose3/default.nix b/pkgs/development/python-modules/nose3/default.nix deleted file mode 100644 index df0fde3fc4a3..000000000000 --- a/pkgs/development/python-modules/nose3/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - lib, - buildPythonPackage, - coverage, - fetchPypi, - isPyPy, - isPy311, - python, - pythonAtLeast, - stdenv, -}: - -buildPythonPackage rec { - pname = "nose3"; - version = "1.3.8"; - format = "setuptools"; - - # https://github.com/jayvdb/nose3/issues/5 - disabled = pythonAtLeast "3.12"; - - src = fetchPypi { - inherit pname version; - hash = "sha256-diquIsrbiYsAudT0u7n46H+ODd5sSaiM0MVU9OWSW3Y="; - }; - - propagatedBuildInputs = [ coverage ]; - - # PyPy hangs for unknwon reason - # Darwin and python 3.11 fail at various assertions and I didn't find an easy way to find skip those tests - doCheck = !isPyPy && !stdenv.isDarwin && !isPy311; - - checkPhase = '' - ${python.pythonOnBuildForHost.interpreter} selftest.py - ''; - - meta = with lib; { - description = "Fork of nose v1 not using lib2to3 for compatibility with Python 3"; - homepage = "https://github.com/jayvdb/nose3"; - license = licenses.lgpl3; - maintainers = with maintainers; [ SuperSandro2000 ]; - }; -} diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index 61eedcce492e..385a851fa147 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -327,6 +327,7 @@ mapAliases ({ net2grid = gridnet; # add 2022-04-22 nghttp2 = throw "in 1.52.0 removed deprecated python bindings."; # added 2023-06-08 ninja-python = ninja; # add 2022-08-03 + nose3 = throw "nose3 has been removed since it is unmaintained and does not work with Python 3.12"; # added 2024-07-28 nosejs = throw "nosejs has been removed since it has not been maintained for 15 years and there are no dependent packages"; # added 2024-05-21 nose-cov = throw "nose-cov has been removed, it was archived and unmaintained since 2012"; # added 2024-05-21 nosexcover = throw "nosexcover has been removed since it has not been maintained and there are no dependent packages"; # added 2024-05-21 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 36532146e9b0..99d2b1902bc4 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9134,8 +9134,6 @@ self: super: with self; { nose2pytest = callPackage ../development/python-modules/nose2pytest { }; - nose3 = callPackage ../development/python-modules/nose3 { }; - notebook = callPackage ../development/python-modules/notebook { }; notebook-shim = callPackage ../development/python-modules/notebook-shim { };