diff --git a/pkgs/development/python-modules/httpcore2/default.nix b/pkgs/development/python-modules/httpcore2/default.nix new file mode 100644 index 000000000000..f7708b751017 --- /dev/null +++ b/pkgs/development/python-modules/httpcore2/default.nix @@ -0,0 +1,95 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + hatchling, + hatch-fancy-pypi-readme, + uv-dynamic-versioning, + + # dependencies + certifi, + h11, + + # optional dependencies + h2, + socksio, + trio, + anyio, + + # tests + pytestCheckHook, + pytest-httpbin, + pytest-trio, + + # reverse deps + httpx2, +}: + +buildPythonPackage (finalAttrs: { + pname = "httpcore2"; + version = "2.2.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "pydantic"; + repo = "httpx2"; + tag = "v${finalAttrs.version}"; + hash = "sha256-RdoMDF5XVOkb4JCmytdF0JmBfTUcHuM1N+SD8r+RNiU="; + }; + + postPatch = '' + pushd src/httpcore2 + ''; + + build-system = [ + hatchling + hatch-fancy-pypi-readme + uv-dynamic-versioning + ]; + + dependencies = [ + certifi + h11 + ]; + + optional-dependencies = { + asyncio = [ anyio ]; + http2 = [ h2 ]; + socks = [ socksio ]; + trio = [ trio ]; + }; + + pythonImportsCheck = [ + "httpcore2" + ]; + + preCheck = '' + popd + ''; + + nativeCheckInputs = [ + pytestCheckHook + pytest-httpbin + pytest-trio + ] + ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies; + + pytestFlags = [ "tests/httpcore2" ]; + + passthru.tests = { + inherit httpx2; + }; + + __darwinAllowLocalNetworking = true; + __structuredAttrs = true; + + meta = { + description = "A next generation HTTP client for Python"; + homepage = "https://github.com/pydantic/httpx2"; + changelog = "https://github.com/pydantic/httpx2/blob/${finalAttrs.src.tag}/src/httpcore2/CHANGELOG.md"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ hexa ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 4ed1ce5b08d2..4dcc253b0909 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7299,6 +7299,8 @@ self: super: with self; { httpcore = callPackage ../development/python-modules/httpcore { }; + httpcore2 = callPackage ../development/python-modules/httpcore2 { }; + httpie = callPackage ../development/python-modules/httpie { }; httpie-ntlm = callPackage ../development/python-modules/httpie-ntlm { };