From 43de4a0e86e46eb08f1cf92ee951e8f755f63a11 Mon Sep 17 00:00:00 2001 From: natsukium Date: Sun, 12 Jan 2025 17:17:03 +0900 Subject: [PATCH] http-prompt: refactor --- .../python-modules/prompt-toolkit/1.nix | 45 ------------ pkgs/tools/networking/http-prompt/default.nix | 68 +++++++++++++++---- 2 files changed, 55 insertions(+), 58 deletions(-) delete mode 100644 pkgs/development/python-modules/prompt-toolkit/1.nix diff --git a/pkgs/development/python-modules/prompt-toolkit/1.nix b/pkgs/development/python-modules/prompt-toolkit/1.nix deleted file mode 100644 index b50f5ef7cd4f..000000000000 --- a/pkgs/development/python-modules/prompt-toolkit/1.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - lib, - buildPythonPackage, - fetchPypi, - pytestCheckHook, - docopt, - six, - wcwidth, - pygments, -}: - -buildPythonPackage rec { - pname = "prompt-toolkit"; - version = "1.0.18"; - - src = fetchPypi { - pname = "prompt_toolkit"; - inherit version; - sha256 = "dd4fca02c8069497ad931a2d09914c6b0d1b50151ce876bc15bde4c747090126"; - }; - - propagatedBuildInputs = [ - docopt - six - wcwidth - pygments - ]; - - nativeCheckInputs = [ pytestCheckHook ]; - - disabledTests = [ "test_pathcompleter_can_expanduser" ]; - - meta = with lib; { - description = "Python library for building powerful interactive command lines"; - longDescription = '' - prompt_toolkit could be a replacement for readline, but it can be - much more than that. It is cross-platform, everything that you build - with it should run fine on both Unix and Windows systems. Also ships - with a nice interactive Python shell (called ptpython) built on top. - ''; - homepage = "https://github.com/jonathanslenders/python-prompt-toolkit"; - maintainers = [ ]; - license = licenses.bsd3; - }; -} diff --git a/pkgs/tools/networking/http-prompt/default.nix b/pkgs/tools/networking/http-prompt/default.nix index 317f253dc69b..27b5ca13a301 100644 --- a/pkgs/tools/networking/http-prompt/default.nix +++ b/pkgs/tools/networking/http-prompt/default.nix @@ -1,41 +1,83 @@ { lib, fetchFromGitHub, - python3Packages, + python3, httpie, + versionCheckHook, }: -python3Packages.buildPythonApplication rec { +let + python = python3.override { + self = python; + packageOverrides = _: super: { + prompt-toolkit = super.prompt-toolkit.overridePythonAttrs (old: rec { + version = "1.0.18"; + src = old.src.override { + inherit version; + hash = "sha256-3U/KAsgGlJetkxotCZFMaw0bUBUc6Ha8Fb3kx0cJASY="; + }; + }); + }; + }; +in +python.pkgs.buildPythonApplication rec { pname = "http-prompt"; version = "2.1.0"; + pyproject = true; src = fetchFromGitHub { - rev = "v${version}"; + tag = "v${version}"; repo = "http-prompt"; owner = "httpie"; - sha256 = "sha256-e4GyuxCeXYNsnBXyjIJz1HqSrqTGan0N3wxUFS+Hvkw="; + hash = "sha256-e4GyuxCeXYNsnBXyjIJz1HqSrqTGan0N3wxUFS+Hvkw="; }; - propagatedBuildInputs = with python3Packages; [ + build-system = [ python.pkgs.setuptools ]; + + dependencies = with python.pkgs; [ click httpie parsimonious - (python.pkgs.callPackage ../../../development/python-modules/prompt-toolkit/1.nix { }) + prompt-toolkit pygments six pyyaml ]; - checkPhase = '' - $out/bin/${pname} --version | grep -q "${version}" - ''; + pythonImportsCheck = [ "http_prompt" ]; - meta = with lib; { + nativeCheckInputs = [ + python.pkgs.mock + python.pkgs.pexpect + python.pkgs.pytest-cov-stub + python.pkgs.pytestCheckHook + versionCheckHook + ]; + + disabledTests = [ + # require network access + "test_get_and_tee" + "test_get_image" + "test_get_querystring" + "test_post_form" + "test_post_json" + "test_spec_from_http" + "test_spec_from_http_only" + # executable path is hardcoded + "test_help" + "test_interaction" + "test_version" + "test_vi_mode" + ]; + + versionCheckProgramArg = [ "--version" ]; + + meta = { description = "Interactive command-line HTTP client featuring autocomplete and syntax highlighting"; mainProgram = "http-prompt"; homepage = "https://github.com/eliangcs/http-prompt"; - license = licenses.mit; - maintainers = with maintainers; [ matthiasbeyer ]; - platforms = platforms.linux ++ platforms.darwin; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ matthiasbeyer ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; }; }