1{
2 lib,
3 anthropic,
4 backoff,
5 buildPythonPackage,
6 distro,
7 fetchFromGitHub,
8 freezegun,
9 mock,
10 monotonic,
11 openai,
12 parameterized,
13 pytestCheckHook,
14 python-dateutil,
15 requests,
16 setuptools,
17 six,
18 typing-extensions,
19}:
20
21buildPythonPackage rec {
22 pname = "posthog";
23 version = "6.7.0";
24 pyproject = true;
25
26 src = fetchFromGitHub {
27 owner = "PostHog";
28 repo = "posthog-python";
29 tag = "v${version}";
30 hash = "sha256-//PjAWZF6FYsiG9UDg+MPv1x06Yp4msBkYkNAU9Rjsc=";
31 };
32
33 build-system = [ setuptools ];
34
35 dependencies = [
36 backoff
37 distro
38 monotonic
39 python-dateutil
40 requests
41 six
42 typing-extensions
43 ];
44
45 nativeCheckInputs = [
46 anthropic
47 freezegun
48 mock
49 openai
50 parameterized
51 pytestCheckHook
52 ];
53
54 pythonImportsCheck = [ "posthog" ];
55
56 disabledTests = [
57 "test_load_feature_flags_wrong_key"
58 # Tests require network access
59 "test_excepthook"
60 "test_request"
61 "test_trying_to_use_django_integration"
62 "test_upload"
63 # AssertionError: 2 != 3
64 "test_flush_interval"
65 ];
66
67 disabledTestPaths = [
68 # Revisit this at the next version bump, issue open upstream
69 # See https://github.com/PostHog/posthog-python/issues/234
70 "posthog/test/ai/openai/test_openai.py"
71 ];
72
73 meta = {
74 description = "Module for interacting with PostHog";
75 homepage = "https://github.com/PostHog/posthog-python";
76 changelog = "https://github.com/PostHog/posthog-python/blob/${src.tag}/CHANGELOG.md";
77 license = lib.licenses.mit;
78 maintainers = with lib.maintainers; [ happysalada ];
79 };
80}