python3Packages.typesense: init at 1.1.1

This commit is contained in:
June Stepp
2025-11-17 18:16:51 -06:00
parent d8d3f6cabd
commit 2af6de63ab
4 changed files with 148 additions and 0 deletions
@@ -0,0 +1,78 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
setuptools,
requests,
pytestCheckHook,
typesense,
curl,
pytest-mock,
requests-mock,
python-dotenv,
faker,
isort,
}:
buildPythonPackage rec {
pname = "typesense";
version = "1.1.1";
pyproject = true;
src = fetchFromGitHub {
owner = "typesense";
repo = "typesense-python";
tag = "v${version}";
hash = "sha256-vo9DW4kinb00zWW4yX8ibyelQxW3eVabn+oMddPEd18=";
};
patches = [
# See <https://github.com/typesense/typesense-python/pull/103>.
./linux-only-metrics.patch
./generated-temp-path.patch
];
build-system = [ setuptools ];
dependencies = [ requests ];
nativeCheckInputs = [
pytestCheckHook
typesense
curl
pytest-mock
requests-mock
python-dotenv
faker
isort
];
disabledTestMarks = [ "open_ai" ];
disabledTests = [ "import_typing_extensions" ];
__darwinAllowLocalNetworking = true;
preCheck = ''
TYPESENSE_API_KEY="xyz" \
TYPESENSE_DATA_DIR="$(mktemp -d)" \
typesense-server &
typesense_pid=$!
# Wait for typesense to finish starting.
timeout 20 bash -c '
while ! curl -s --fail localhost:8108/health; do sleep 1; done
' || false
'';
postCheck = ''
kill $typesense_pid
'';
pythonImportsCheck = [ "typesense" ];
meta = {
description = "Python client for Typesense, an open source and typo tolerant search engine";
homepage = "https://github.com/typesense/typesense-python";
license = lib.licenses.asl20;
teams = [ lib.teams.ngi ];
};
}
@@ -0,0 +1,18 @@
diff --git a/tests/operations_test.py b/tests/operations_test.py
index 34bb74c..39f9265 100644
--- a/tests/operations_test.py
+++ b/tests/operations_test.py
@@ -51,11 +51,11 @@ def test_cache_clear(actual_operations: Operations) -> None:
assert response["success"]
-def test_snapshot(actual_operations: Operations) -> None:
+def test_snapshot(actual_operations: Operations, tmp_path) -> None:
"""Test that the Operations object can perform the snapshot operation."""
response = actual_operations.perform(
"snapshot",
- {"snapshot_path": "/tmp"}, # noqa: S108
+ {"snapshot_path": str(tmp_path)}, # noqa: S108
)
assert response["success"]
@@ -0,0 +1,48 @@
From 9f0024ae3a0377d15788256c72af7a692d250afc Mon Sep 17 00:00:00 2001
From: dotlambda <github@dotlambda.de>
Date: Thu, 23 Oct 2025 13:40:33 -0700
Subject: [PATCH] test(metrics): some metrics only exists on Linux
---
tests/metrics_test.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/metrics_test.py b/tests/metrics_test.py
index 1e1ea47..fecf3c0 100644
--- a/tests/metrics_test.py
+++ b/tests/metrics_test.py
@@ -2,6 +2,8 @@
from __future__ import annotations
+import platform
+
from typesense.metrics import Metrics
@@ -9,13 +11,15 @@ def test_actual_retrieve(actual_metrics: Metrics) -> None:
"""Test that the Debug object can retrieve a debug on Typesense server and verify response structure."""
response = actual_metrics.retrieve()
- assert "system_cpu_active_percentage" in response
+ if platform.system() == "Linux":
+ assert "system_cpu_active_percentage" in response
+ assert "system_network_received_bytes" in response
+ assert "system_network_sent_bytes" in response
+
assert "system_disk_total_bytes" in response
assert "system_disk_used_bytes" in response
assert "system_memory_total_bytes" in response
assert "system_memory_used_bytes" in response
- assert "system_network_received_bytes" in response
- assert "system_network_sent_bytes" in response
assert "typesense_memory_active_bytes" in response
assert "typesense_memory_allocated_bytes" in response
assert "typesense_memory_fragmentation_ratio" in response
@@ -23,4 +27,4 @@ def test_actual_retrieve(actual_metrics: Metrics) -> None:
assert "typesense_memory_mapped_bytes" in response
assert "typesense_memory_metadata_bytes" in response
assert "typesense_memory_resident_bytes" in response
- assert "typesense_memory_retained_bytes" in response
\ No newline at end of file
+ assert "typesense_memory_retained_bytes" in response
+4
View File
@@ -19619,6 +19619,10 @@ self: super: with self; {
types-xxhash = callPackage ../development/python-modules/types-xxhash { };
typesense = callPackage ../development/python-modules/typesense {
inherit (pkgs) typesense curl;
};
typesentry = callPackage ../development/python-modules/typesentry { };
typeshed-client = callPackage ../development/python-modules/typeshed-client { };