diff --git a/pkgs/development/python-modules/lmstudio/default.nix b/pkgs/development/python-modules/lmstudio/default.nix new file mode 100644 index 000000000000..10fce8805d42 --- /dev/null +++ b/pkgs/development/python-modules/lmstudio/default.nix @@ -0,0 +1,94 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + pdm-backend, + + # dependencies + anyio, + httpx, + httpx-ws, + msgspec, + typing-extensions, + + # tests + pytest-asyncio, + pytestCheckHook, +}: + +buildPythonPackage (finalAttrs: { + pname = "lmstudio"; + version = "1.5.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "lmstudio-ai"; + repo = "lmstudio-python"; + tag = finalAttrs.version; + hash = "sha256-3LOoCWoQ7eXRPXHRio9Rtle07HcV3ZrWkrtVVY6mvfI="; + }; + + build-system = [ + pdm-backend + ]; + + dependencies = [ + anyio + httpx + httpx-ws + msgspec + typing-extensions + ]; + + pythonImportsCheck = [ "lmstudio" ]; + + nativeCheckInputs = [ + pytest-asyncio + pytestCheckHook + ]; + + disabledTests = [ + # lmstudio.LMStudioRuntimeError: Local API host port is not yet resolved. + "test_session_disconnected_async" + ]; + + disabledTestPaths = [ + # ModuleNotFoundError: No module named 'pytest_subtests' + "tests/async/test_model_catalog_async.py" + "tests/sync/test_model_catalog_sync.py" + "tests/test_inference.py" + + # lmstudio.LMStudioRuntimeError: Local API host port is not yet resolved. + "tests/async/test_embedding_async.py" + "tests/async/test_images_async.py" + "tests/async/test_inference_async.py" + "tests/async/test_llm_async.py" + "tests/async/test_model_handles_async.py" + "tests/async/test_repository_async.py" + "tests/async/test_sdk_bypass_async.py" + "tests/sync/test_embedding_sync.py" + "tests/sync/test_images_sync.py" + "tests/sync/test_inference_sync.py" + "tests/sync/test_llm_sync.py" + "tests/sync/test_model_handles_sync.py" + "tests/sync/test_repository_sync.py" + "tests/sync/test_sdk_bypass_sync.py" + "tests/test_convenience_api.py" + "tests/test_logging.py" + "tests/test_plugin_examples.py" + "tests/test_sessions.py" + "tests/test_timeouts.py" + ]; + + __darwinAllowLocalNetworking = true; + + meta = { + description = "LM Studio Python SDK"; + homepage = "https://github.com/lmstudio-ai/lmstudio-python"; + changelog = "https://github.com/lmstudio-ai/lmstudio-python/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 426268b1a572..59ff11bcb22c 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9209,6 +9209,8 @@ self: super: with self; { lmnotify = callPackage ../development/python-modules/lmnotify { }; + lmstudio = callPackage ../development/python-modules/lmstudio { }; + lmtpd = callPackage ../development/python-modules/lmtpd { }; lnkparse3 = callPackage ../development/python-modules/lnkparse3 { };