Skip to content

Commit 1db6e45

Browse files
authored
chore: pyproject and CI update (#247)
1 parent 1daa8a8 commit 1db6e45

File tree

9 files changed

+3547
-35
lines changed

9 files changed

+3547
-35
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ jobs:
1818
with:
1919
python-version: 3.11.11
2020

21-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
2223
with:
23-
path: ~/.cache/pip
24-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
25-
restore-keys: |
26-
${{ runner.os }}-pip-
24+
enable-cache: true
25+
pyproject-file: 'pyproject.toml'
2726

2827
- name: Install dev dependencies
28+
shell: bash
2929
run: |
30-
python -m pip install -e .[dev]
31-
if: steps.cache.outputs.cache-hit != 'true'
30+
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --extra dev
3231
3332
- name: Check formatting with ruff
3433
run: |
@@ -55,9 +54,16 @@ jobs:
5554
with:
5655
python-version: ${{ matrix.python-version }}
5756

58-
- name: Install requirements.txt dependencies with pip
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
59+
with:
60+
enable-cache: true
61+
pyproject-file: 'pyproject.toml'
62+
63+
- name: Install test dependencies
64+
shell: bash
5965
run: |
60-
python -m pip install -e .[test]
66+
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --extra test
6167
6268
- name: Run posthog tests
6369
run: |

.github/workflows/release.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@ jobs:
2424

2525
- name: Set up Python
2626
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55
27+
with:
28+
python-version: 3.11.11
2729

30+
- name: Install uv
31+
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
32+
with:
33+
enable-cache: true
34+
pyproject-file: 'pyproject.toml'
35+
2836
- name: Detect version
2937
run: echo "REPO_VERSION=$(python3 posthog/version.py)" >> $GITHUB_ENV
3038

3139
- name: Prepare for building release
32-
run: pip install -U pip setuptools packaging wheel twine
40+
run: uv sync --extra build
3341

34-
- name: Push release to PyPI
42+
- name: Push releases to PyPI
3543
run: make release && make release_analytics
3644

3745
- name: Create GitHub release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ posthog-analytics
1717
.coverage
1818
pyrightconfig.json
1919
.env
20+
.DS_Store

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ Please see the [Python integration docs](https://posthog.com/docs/integrations/p
1616

1717
### Testing Locally
1818

19-
1. Run `python3 -m venv env` (creates virtual environment called "env")
20-
* or `uv venv env`
19+
We recommend using [uv](https://docs.astral.sh/uv/). It's super fast.
20+
21+
1. Run `uv venv env` (creates virtual environment called "env")
22+
* or `python3 -m venv env`
2123
2. Run `source env/bin/activate` (activates the virtual environment)
22-
3. Run `python3 -m pip install -e ".[test]"` (installs the package in develop mode, along with test dependencies)
23-
* or `uv pip install -e ".[test]"`
24+
3. Run `uv sync --extra dev --extra test` (installs the package in develop mode, along with test dependencies)
25+
* or `pip install -e ".[dev,test]"`
2426
4. you have to run `pre-commit install` to have auto linting pre commit
2527
5. Run `make test`
2628
1. To run a specific test do `pytest -k test_no_api_key`
@@ -32,7 +34,7 @@ uv python install 3.9.19
3234
uv python pin 3.9.19
3335
uv venv env
3436
source env/bin/activate
35-
uv pip install --editable ".[dev,test]"
37+
uv sync --extra dev --extra test
3638
pre-commit install
3739
make test
3840
```

pyproject.toml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ dynamic = ["version"]
88
description = "Integrate PostHog into any python application."
99
authors = [{ name = "PostHog", email = "[email protected]" }]
1010
maintainers = [{ name = "PostHog", email = "[email protected]" }]
11-
license = { text = "MIT License" }
11+
license = {text = "MIT"}
1212
readme = "README.md"
1313
requires-python = ">=3.9"
1414
classifiers = [
1515
"Development Status :: 5 - Production/Stable",
1616
"Intended Audience :: Developers",
1717
"Operating System :: OS Independent",
18+
"License :: OSI Approved :: MIT License",
1819
"Programming Language :: Python",
1920
"Programming Language :: Python :: 3.9",
2021
"Programming Language :: Python :: 3.10",
@@ -35,6 +36,8 @@ Homepage = "https://github.com/posthog/posthog-python"
3536
Repository = "https://github.com/posthog/posthog-python"
3637

3738
[project.optional-dependencies]
39+
sentry = ["sentry-sdk", "django"]
40+
langchain = ["langchain>=0.2.0"]
3841
dev = [
3942
"django-stubs",
4043
"lxml",
@@ -67,8 +70,12 @@ test = [
6770
"pydantic",
6871
"parameterized>=0.8.1",
6972
]
70-
sentry = ["sentry-sdk", "django"]
71-
langchain = ["langchain>=0.2.0"]
73+
build = [
74+
"setuptools",
75+
"packaging",
76+
"wheel",
77+
"twine",
78+
]
7279

7380
[tool.setuptools]
7481
packages = [
@@ -83,8 +90,6 @@ packages = [
8390
"posthog.exception_integrations",
8491
]
8592

86-
license-files = []
87-
8893
[tool.setuptools.dynamic]
8994
version = { attr = "posthog.version.VERSION" }
9095

setup.cfg

Lines changed: 0 additions & 12 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
author_email="[email protected]",
2929
maintainer="PostHog",
3030
maintainer_email="[email protected]",
31-
test_suite="posthog.test.all",
3231
license="MIT License",
3332
description="Integrate PostHog into any python application.",
3433
long_description=long_description,

setup_analytics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
author_email="[email protected]",
2929
maintainer="PostHog",
3030
maintainer_email="[email protected]",
31-
test_suite="posthog.test.all",
3231
license="MIT License",
3332
description="Integrate PostHog into any python application.",
3433
long_description=long_description,

0 commit comments

Comments
 (0)