Thanks for your interest in improving the PostHog Python SDK.
This repo requires all commits to be signed. To configure commit signing, see the PostHog handbook.
We recommend using uv.
uv venv
source .venv/bin/activate
uv sync --extra dev --extra testRun the same core checks CI uses before opening a PR:
ruff format --check .
ruff check .
mypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter
pytest --verbose --timeout=30
python -W error -c "import posthog"Assuming you have a local version of PostHog running, you can run python3 example.py to see the library in action.
Run make prep_local to create a sibling folder named posthog-python-local. You can then import it into the PostHog app by changing pyproject.toml like this:
dependencies = [
...
"posthoganalytics" #NOTE: no version number
...
]
...
[tools.uv.sources]
posthoganalytics = { path = "../posthog-python-local" }This lets you test SDK changes fully locally inside the PostHog app stack. It mainly takes care of the posthog -> posthoganalytics module renaming. Re-run make prep_local each time you make a change, and then run uv sync --active in the PostHog app project.