diff --git a/pkgs/development/python-modules/perplexityai/default.nix b/pkgs/development/python-modules/perplexityai/default.nix new file mode 100644 index 000000000000..6f572887e89d --- /dev/null +++ b/pkgs/development/python-modules/perplexityai/default.nix @@ -0,0 +1,102 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + hatch-fancy-pypi-readme, + hatchling, + + # dependencies (incl. optional) + anyio, + distro, + httpx, + pydantic, + sniffio, + typing-extensions, + aiohttp, + httpx-aiohttp, + + # tests + pyright, + mypy, + respx, + pytest, + pytest-asyncio, + ruff, + time-machine, + nox, + dirty-equals, + importlib-metadata, + rich, + pytest-xdist, +}: + +buildPythonPackage (finalAttrs: { + pname = "perplexityai"; + version = "0.38.0"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "perplexityai"; + repo = "perplexity-py"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Yp5A3aoKtAjWRPZ1Un2OYwezZohWirNm2JhAWLhd6uQ="; + }; + + # Can't use relaxPythonDeps as this is a version lock in the build system + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail '"hatchling==1.26.3"' '"hatchling"' + ''; + + build-system = [ + hatch-fancy-pypi-readme + hatchling + ]; + + dependencies = [ + anyio + distro + httpx + pydantic + sniffio + typing-extensions + ]; + + optional-dependencies = { + aiohttp = [ + aiohttp + httpx-aiohttp + ]; + }; + + nativeCheckInputs = [ + pyright + mypy + respx + pytest + pytest-asyncio + ruff + time-machine + nox + dirty-equals + importlib-metadata + rich + pytest-xdist + ] + ++ finalAttrs.passthru.optional-dependencies.aiohttp; + + pythonImportsCheck = [ + "perplexity" + ]; + + meta = { + description = "API for Perplexity AI"; + homepage = "https://github.com/perplexityai/perplexity-py"; + changelog = "https://github.com/perplexityai/perplexity-py/blob/${finalAttrs.src.tag}/CHANGELOG.md"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ sarahec ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0af660bc2b5e..e852c08a6c52 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -12558,6 +12558,8 @@ self: super: with self; { permissionedforms = callPackage ../development/python-modules/permissionedforms { }; + perplexityai = callPackage ../development/python-modules/perplexityai { }; + persim = callPackage ../development/python-modules/persim { }; persist-queue = callPackage ../development/python-modules/persist-queue { };