Skip to content

Commit 31d513d

Browse files
authored
chore: migrate repo from poetry to uv (#1589)
1 parent 7619731 commit 31d513d

16 files changed

Lines changed: 2605 additions & 3085 deletions

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
version: 2
77
updates:
8-
- package-ecosystem: "pip" # See documentation for possible values
8+
- package-ecosystem: "uv" # See documentation for possible values
99
directory: "/" # Location of package manifests
1010
schedule:
1111
interval: "daily"

.github/workflows/ci.yml

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v3
22-
- uses: astral-sh/ruff-action@v3
22+
- name: Install uv and set Python version
23+
uses: astral-sh/setup-uv@v7
24+
with:
25+
version: "0.11.2"
26+
python-version: "3.13"
27+
enable-cache: true
28+
- name: Install dependencies
29+
run: uv sync --locked
30+
- name: Run Ruff
31+
run: uv run --frozen ruff check .
2332

2433
type-checking:
2534
runs-on: ubuntu-latest
2635
steps:
2736
- uses: actions/checkout@v3
28-
- name: Set up Python
29-
uses: actions/setup-python@v4
37+
- name: Install uv and set Python version
38+
uses: astral-sh/setup-uv@v7
3039
with:
40+
version: "0.11.2"
3141
python-version: "3.13"
32-
- name: Install poetry
33-
uses: abatilo/actions-poetry@v2
34-
- name: Setup a local virtual environment
35-
run: |
36-
poetry config virtualenvs.create true --local
37-
poetry config virtualenvs.in-project true --local
38-
- uses: actions/cache@v3
39-
name: Define a cache for the virtual environment based on the dependencies lock file
40-
with:
41-
path: ./.venv
42-
key: venv-type-check-${{ hashFiles('poetry.lock') }}
42+
enable-cache: true
4343
- uses: actions/cache@v3
4444
name: Cache mypy cache
4545
with:
@@ -48,9 +48,9 @@ jobs:
4848
restore-keys: |
4949
mypy-
5050
- name: Install dependencies
51-
run: poetry install --only=main,dev
51+
run: uv sync --locked
5252
- name: Run mypy type checking
53-
run: poetry run mypy langfuse --no-error-summary
53+
run: uv run --frozen mypy langfuse --no-error-summary
5454

5555
ci:
5656
runs-on: ubuntu-latest
@@ -154,43 +154,23 @@ jobs:
154154
done
155155
echo "Langfuse server is up and running!"
156156
157-
- name: Install Python
158-
uses: actions/setup-python@v4
159-
# see details (matrix, python-version, python-version-file, etc.)
160-
# https://github.com/actions/setup-python
157+
- name: Install uv and set Python version
158+
uses: astral-sh/setup-uv@v7
161159
with:
160+
version: "0.11.2"
162161
python-version: ${{ matrix.python-version }}
162+
enable-cache: true
163163

164-
- name: Check python version
164+
- name: Check Python version
165165
run: python --version
166166

167-
- name: Install poetry
168-
uses: abatilo/actions-poetry@v2
169-
170-
- name: Set poetry python version
171-
run: |
172-
poetry env use ${{ matrix.python-version }}
173-
poetry env info
174-
175-
- name: Setup a local virtual environment (if no poetry.toml file)
176-
run: |
177-
poetry config virtualenvs.create true --local
178-
poetry config virtualenvs.in-project true --local
179-
180-
- uses: actions/cache@v3
181-
name: Define a cache for the virtual environment based on the dependencies lock file
182-
with:
183-
path: ./.venv
184-
key: |
185-
venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
186-
187167
- name: Install the project dependencies
188-
run: poetry install --all-extras
168+
run: uv sync --locked
189169

190170
- name: Run the automated tests
191171
run: |
192172
python --version
193-
poetry run pytest -n auto --dist loadfile -s -v --log-cli-level=INFO
173+
uv run --frozen pytest -n auto --dist loadfile -s -v --log-cli-level=INFO
194174
195175
all-tests-passed:
196176
# This allows us to have a branch protection rule for tests and deploys with matrix

.github/workflows/release.yml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,12 @@ jobs:
6767
fetch-depth: 0
6868
token: ${{ secrets.GH_ACCESS_TOKEN }}
6969

70-
- name: Setup Python
71-
uses: actions/setup-python@v5
70+
- name: Install uv and set Python version
71+
uses: astral-sh/setup-uv@v7
7272
with:
73+
version: "0.11.2"
7374
python-version: "3.12"
74-
75-
- name: Install Poetry
76-
uses: snok/install-poetry@v1
77-
with:
78-
version: "1.8.4"
79-
virtualenvs-create: true
80-
virtualenvs-in-project: true
75+
enable-cache: true
8176

8277
- name: Configure Git
8378
env:
@@ -92,7 +87,7 @@ jobs:
9287
- name: Get current version
9388
id: current-version
9489
run: |
95-
current_version=$(poetry version -s)
90+
current_version=$(uv version --short)
9691
echo "version=$current_version" >> $GITHUB_OUTPUT
9792
echo "Current version: $current_version"
9893
@@ -211,27 +206,13 @@ jobs:
211206
212207
- name: Update version in pyproject.toml
213208
run: |
214-
poetry version ${{ steps.new-version.outputs.version }}
215-
216-
- name: Update version in langfuse/version.py
217-
run: |
218-
new_version="${{ steps.new-version.outputs.version }}"
219-
sed -i "s/__version__ = \".*\"/__version__ = \"$new_version\"/" langfuse/version.py
220-
echo "Updated langfuse/version.py:"
221-
cat langfuse/version.py
209+
uv version ${{ steps.new-version.outputs.version }}
222210
223211
- name: Verify version consistency
224212
run: |
225-
pyproject_version=$(poetry version -s)
226-
file_version=$(grep -oP '__version__ = "\K[^"]+' langfuse/version.py)
213+
pyproject_version=$(uv version --short)
227214
228215
echo "pyproject.toml version: $pyproject_version"
229-
echo "langfuse/version.py version: $file_version"
230-
231-
if [ "$pyproject_version" != "$file_version" ]; then
232-
echo "❌ Error: Version mismatch between pyproject.toml and langfuse/version.py"
233-
exit 1
234-
fi
235216
236217
if [ "$pyproject_version" != "${{ steps.new-version.outputs.version }}" ]; then
237218
echo "❌ Error: Version in files doesn't match expected version"
@@ -241,7 +222,7 @@ jobs:
241222
echo "✅ Versions are consistent: $pyproject_version"
242223
243224
- name: Build package
244-
run: poetry build
225+
run: uv build --no-sources
245226

246227
- name: Verify build artifacts
247228
run: |
@@ -278,9 +259,17 @@ jobs:
278259
fi
279260
echo "✅ Artifact version verified"
280261
262+
- name: Smoke test wheel
263+
run: |
264+
uv run --isolated --no-project --with dist/*.whl python -c "from importlib.metadata import version; import langfuse; assert langfuse.__version__ == version('langfuse')"
265+
266+
- name: Smoke test source distribution
267+
run: |
268+
uv run --isolated --no-project --with dist/*.tar.gz python -c "from importlib.metadata import version; import langfuse; assert langfuse.__version__ == version('langfuse')"
269+
281270
- name: Commit version changes
282271
run: |
283-
git add pyproject.toml langfuse/version.py
272+
git add pyproject.toml uv.lock
284273
git commit -m "chore: release v${{ steps.new-version.outputs.version }}"
285274
286275
- name: Create and push tag
@@ -292,9 +281,7 @@ jobs:
292281
293282
- name: Publish to PyPI
294283
id: publish-pypi
295-
uses: pypa/gh-action-pypi-publish@release/v1
296-
with:
297-
print-hash: true
284+
run: uv publish --trusted-publishing always
298285

299286
- name: Create GitHub Release
300287
id: create-release

.pre-commit-config.yaml

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.15.2
2+
- repo: https://github.com/astral-sh/uv-pre-commit
3+
rev: 0.11.2
4+
hooks:
5+
- id: uv-lock
6+
7+
- repo: local
48
hooks:
59
# Run the linter and fix
6-
- id: ruff-check
10+
- id: uv-ruff-check
11+
name: ruff-check
12+
entry: uv run --frozen ruff check --fix
13+
language: system
714
types_or: [python, pyi, jupyter]
8-
args: [--fix]
15+
exclude: ^langfuse/api/
916

1017
# Run the formatter.
11-
- id: ruff-format
18+
- id: uv-ruff-format
19+
name: ruff-format
20+
entry: uv run --frozen ruff format
21+
language: system
1222
types_or: [python, pyi, jupyter]
23+
exclude: ^langfuse/api/
1324

14-
- repo: https://github.com/pre-commit/mirrors-mypy
15-
rev: v1.18.2
16-
hooks:
17-
- id: mypy
18-
additional_dependencies:
19-
- types-requests
20-
- types-setuptools
21-
- httpx
22-
- pydantic>=1.10.7
23-
- backoff>=1.10.0
24-
- openai>=0.27.8
25-
- wrapt
26-
- packaging>=23.2
27-
- opentelemetry-api
28-
- opentelemetry-sdk
29-
- opentelemetry-exporter-otlp
30-
- numpy
31-
- langchain>=0.0.309
32-
- langchain-core
33-
- langgraph
34-
args: [--no-error-summary]
25+
- id: uv-mypy
26+
name: mypy
27+
entry: uv run --frozen mypy langfuse --no-error-summary
28+
language: system
3529
files: ^langfuse/
30+
pass_filenames: false

CLAUDE.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,57 @@ This is the Langfuse Python SDK, a client library for accessing the Langfuse obs
1111
### Setup
1212

1313
```bash
14-
# Install Poetry plugins (one-time setup)
15-
poetry self add poetry-dotenv-plugin
16-
17-
# Install all dependencies including optional extras
18-
poetry install --all-extras
14+
# Install the project and development dependencies
15+
uv sync
1916

2017
# Setup pre-commit hooks
21-
poetry run pre-commit install
18+
uv run pre-commit install
2219
```
2320

2421
### Testing
2522

2623
```bash
2724
# Run all tests with verbose output
28-
poetry run pytest -s -v --log-cli-level=INFO
25+
uv run --env-file .env pytest -s -v --log-cli-level=INFO
2926

3027
# Run a specific test
31-
poetry run pytest -s -v --log-cli-level=INFO tests/test_core_sdk.py::test_flush
28+
uv run --env-file .env pytest -s -v --log-cli-level=INFO tests/test_core_sdk.py::test_flush
3229

3330
# Run tests in parallel (faster)
34-
poetry run pytest -s -v --log-cli-level=INFO -n auto
31+
uv run --env-file .env pytest -s -v --log-cli-level=INFO -n auto
3532
```
3633

3734
### Code Quality
3835

3936
```bash
4037
# Format code with Ruff
41-
poetry run ruff format .
38+
uv run ruff format .
4239

4340
# Run linting (development config)
44-
poetry run ruff check .
41+
uv run ruff check .
4542

4643
# Run type checking
47-
poetry run mypy .
44+
uv run mypy .
4845

4946
# Run pre-commit hooks manually
50-
poetry run pre-commit run --all-files
47+
uv run pre-commit run --all-files
5148
```
5249

5350
### Building and Releasing
5451

5552
```bash
5653
# Build the package locally (for testing)
57-
poetry build
54+
uv build --no-sources
5855

5956
# Generate documentation
60-
poetry run pdoc -o docs/ --docformat google --logo "https://langfuse.com/langfuse_logo.svg" langfuse
57+
uv run --group docs pdoc -o docs/ --docformat google --logo "https://langfuse.com/langfuse_logo.svg" langfuse
6158
```
6259

6360
Releases are automated via GitHub Actions. To release:
6461

6562
1. Go to Actions > "Release Python SDK" workflow
6663
2. Click "Run workflow"
67-
3. Select version bump type (patch/minor/major/prerelease)
64+
3. Select version bump type (patch/minor/major/prepatch/preminor/premajor)
6865
4. For prereleases, select the type (alpha/beta/rc)
6966

7067
The workflow handles versioning, building, PyPI publishing (via OIDC), and GitHub release creation.
@@ -120,16 +117,16 @@ Environment variables (defined in `_client/environment_variables.py`):
120117

121118
## Important Files
122119

123-
- `pyproject.toml`: Poetry configuration, dependencies, and tool settings
124-
- `langfuse/version.py`: Version string (updated by CI release workflow)
120+
- `pyproject.toml`: uv project metadata, dependencies, and tool settings
121+
- `uv.lock`: Locked dependency graph for local development and CI
125122

126123
## API Generation
127124

128125
The `langfuse/api/` directory is auto-generated from the Langfuse OpenAPI specification using Fern. To update:
129126

130127
1. Generate new SDK in main Langfuse repo
131128
2. Copy generated files from `generated/python` to `langfuse/api/`
132-
3. Run `poetry run ruff format .` to format the generated code
129+
3. Run `uv run ruff format .` to format the generated code
133130

134131
## Testing Guidelines
135132

0 commit comments

Comments
 (0)