You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your interest in improving the PostHog Python SDK.
4
+
5
+
## Commit signing
6
+
7
+
This repo requires all commits to be signed. To configure commit signing, see the [PostHog handbook](https://posthog.com/handbook/engineering/security#commit-signing).
8
+
9
+
## Testing locally
10
+
11
+
We recommend using [uv](https://docs.astral.sh/uv/).
12
+
13
+
1. Create a virtual environment:
14
+
-`uv venv env`
15
+
- or `python3 -m venv env`
16
+
2. Activate it:
17
+
-`source env/bin/activate`
18
+
3. Install the package in editable mode with development and test dependencies:
19
+
-`uv sync --extra dev --extra test`
20
+
- or `pip install -e ".[dev,test]"`
21
+
4. Install pre-commit hooks:
22
+
-`pre-commit install`
23
+
5. Run the test suite:
24
+
-`make test`
25
+
6. Run a specific test if needed:
26
+
-`pytest -k test_no_api_key`
27
+
28
+
## Recommended `uv` workflow
29
+
30
+
```bash
31
+
uv python install 3.12
32
+
uv python pin 3.12
33
+
uv venv
34
+
source .venv/bin/activate
35
+
uv sync --extra dev --extra test
36
+
pre-commit install
37
+
make test
38
+
```
39
+
40
+
## Running locally
41
+
42
+
Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.
43
+
44
+
## Testing changes locally with the PostHog app
45
+
46
+
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:
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.
This repo requires all commits to be signed. To configure commit signing, see the [PostHog handbook](https://posthog.com/handbook/engineering/security#commit-signing).
26
-
27
-
### Testing Locally
28
-
29
-
We recommend using [uv](https://docs.astral.sh/uv/). It's super fast.
30
-
31
-
1. Run `uv venv env` (creates virtual environment called "env")
32
-
- or `python3 -m venv env`
33
-
2. Run `source env/bin/activate` (activates the virtual environment)
34
-
3. Run `uv sync --extra dev --extra test` (installs the package in develop mode, along with test dependencies)
35
-
- or `pip install -e ".[dev,test]"`
36
-
4. you have to run `pre-commit install` to have auto linting pre commit
37
-
5. Run `make test`
38
-
6. To run a specific test do `pytest -k test_no_api_key`
39
-
40
-
## PostHog recommends `uv` so...
41
-
42
-
```bash
43
-
uv python install 3.12
44
-
uv python pin 3.12
45
-
uv venv
46
-
source env/bin/activate
47
-
uv sync --extra dev --extra test
48
-
pre-commit install
49
-
make test
50
-
```
51
-
52
-
### Running Locally
53
-
54
-
Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.
55
-
56
-
### Testing changes locally with the PostHog app
57
-
58
-
You can run `make prep_local`, and it'll create a new folder alongside the SDK repo one called `posthog-python-local`, which you can then import into the posthog project by changing pyproject.toml to look like this:
This'll let you build and test SDK changes fully locally, incorporating them into your local posthog app stack. It mainly takes care of the `posthog -> posthoganalytics` module renaming. You'll need to re-run `make prep_local` each time you make a change, and re-run `uv sync --active` in the posthog app project.
25
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, test, and development workflow instructions.
0 commit comments