Skip to content

Commit cd8de7b

Browse files
authored
INTPYTHON-468 Switch from Poetry to uv (#53)
1 parent 7dd2330 commit cd8de7b

File tree

18 files changed

+3458
-4473
lines changed

18 files changed

+3458
-4473
lines changed

.github/actions/poetry_setup/action.yml

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

.github/scripts/get_min_versions.py

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

.github/workflows/_lint.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
description: "From which folder this pipeline executes"
1010

1111
env:
12-
POETRY_VERSION: "1.7.1"
1312
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
1413

1514
# This env var allows us to get inline annotations when ruff has complaints.
@@ -35,40 +34,18 @@ jobs:
3534
steps:
3635
- uses: actions/checkout@v4
3736

38-
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
39-
uses: "./.github/actions/poetry_setup"
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
4039
with:
40+
enable-cache: true
4141
python-version: ${{ matrix.python-version }}
42-
poetry-version: ${{ env.POETRY_VERSION }}
43-
working-directory: ${{ inputs.working-directory }}
44-
cache-key: lint-with-extras
45-
46-
- name: Check Poetry File
47-
shell: bash
48-
working-directory: ${{ inputs.working-directory }}
49-
run: |
50-
poetry check
51-
52-
- name: Check lock file
53-
shell: bash
54-
working-directory: ${{ inputs.working-directory }}
55-
run: |
56-
poetry lock --check
42+
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"
5743

5844
- uses: extractions/setup-just@v2
5945

6046
- name: Install dependencies
61-
# Also installs dev/lint/test/typing dependencies, to ensure we have
62-
# type hints for as many of our libraries as possible.
63-
# This helps catch errors that require dependencies to be spotted, for example:
64-
# https://github.com/langchain-ai/langchain/pull/10249/files#diff-935185cd488d015f026dcd9e19616ff62863e8cde8c0bee70318d3ccbca98341
65-
#
66-
# If you change this configuration, make sure to change the `cache-key`
67-
# in the `poetry_setup` action above to stop using the old cache.
68-
# It doesn't matter how you change it, any change will cause a cache-bust.
6947
working-directory: ${{ inputs.working-directory }}
70-
run: |
71-
just install
48+
run: just install
7249

7350
- name: Get .mypy_cache to speed up mypy
7451
uses: actions/cache@v4
@@ -77,10 +54,9 @@ jobs:
7754
with:
7855
path: |
7956
${{ env.WORKDIR }}/.mypy_cache
80-
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
57+
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/uv.lock', inputs.working-directory)) }}
8158

8259

8360
- name: Analysing the code with our lint
8461
working-directory: ${{ inputs.working-directory }}
85-
run: |
86-
just lint
62+
run: just lint

.github/workflows/_release.yml

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ on:
2020

2121
env:
2222
PYTHON_VERSION: "3.11"
23-
POETRY_VERSION: "1.7.1"
2423

2524
jobs:
2625
build:
@@ -34,13 +33,12 @@ jobs:
3433
steps:
3534
- uses: actions/checkout@v4
3635

37-
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
38-
uses: "./.github/actions/poetry_setup"
36+
- name: Install uv
37+
uses: astral-sh/setup-uv@v5
3938
with:
39+
enable-cache: true
4040
python-version: ${{ env.PYTHON_VERSION }}
41-
poetry-version: ${{ env.POETRY_VERSION }}
42-
working-directory: ${{ inputs.working-directory }}
43-
cache-key: release
41+
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"
4442

4543
# We want to keep this build stage *separate* from the release stage,
4644
# so that there's no sharing of permissions between them.
@@ -54,7 +52,7 @@ jobs:
5452
# > from the publish job.
5553
# https://github.com/pypa/gh-action-pypi-publish#non-goals
5654
- name: Build project for distribution
57-
run: poetry build
55+
run: uv build
5856
working-directory: ${{ inputs.working-directory }}
5957

6058
- name: Upload build
@@ -68,8 +66,8 @@ jobs:
6866
shell: bash
6967
working-directory: ${{ inputs.working-directory }}
7068
run: |
71-
echo pkg-name="$(poetry version | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
72-
echo version="$(poetry version --short)" >> $GITHUB_OUTPUT
69+
echo pkg-name="$(hatch project metadata | jq -r .name)" >> $GITHUB_OUTPUT
70+
echo version="$(hatch version)" >> $GITHUB_OUTPUT
7371
7472
test-pypi-publish:
7573
needs:
@@ -102,12 +100,10 @@ jobs:
102100
# - The package is published, and it breaks on the missing dependency when
103101
# used in the real world.
104102

105-
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
106-
uses: "./.github/actions/poetry_setup"
103+
- name: Install uv
104+
uses: astral-sh/setup-uv@v5
107105
with:
108106
python-version: ${{ env.PYTHON_VERSION }}
109-
poetry-version: ${{ env.POETRY_VERSION }}
110-
working-directory: ${{ inputs.working-directory }}
111107

112108
- name: Import published package
113109
shell: bash
@@ -125,12 +121,12 @@ jobs:
125121
# - attempt install again after 5 seconds if it fails because there is
126122
# sometimes a delay in availability on test pypi
127123
run: |
128-
poetry run pip install \
124+
uv run pip install \
129125
--extra-index-url https://test.pypi.org/simple/ \
130126
"$PKG_NAME==$VERSION" || \
131127
( \
132128
sleep 5 && \
133-
poetry run pip install \
129+
uv run pip install \
134130
--extra-index-url https://test.pypi.org/simple/ \
135131
"$PKG_NAME==$VERSION" \
136132
)
@@ -140,7 +136,7 @@ jobs:
140136
# If "langgraph-checkpoint-mongodb", it's a namespace package => /-/.
141137
[[ "$PKG_NAME" == "langgraph-checkpoint-mongodb" ]] && IMPORT_NAME="${PKG_NAME//-/.}"
142138
143-
poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
139+
uv run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
144140
145141
- uses: extractions/setup-just@v2
146142

@@ -156,23 +152,17 @@ jobs:
156152
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
157153
VERSION: ${{ needs.build.outputs.version }}
158154
run: |
159-
poetry run pip install \
155+
uv run pip install \
160156
--extra-index-url https://test.pypi.org/simple/ \
161157
"$PKG_NAME==$VERSION"
162158
163-
- name: Start MongoDB
164-
uses: supercharge/[email protected]
165-
166159
- name: Run unit tests
167160
run: just tests
168161
working-directory: ${{ inputs.working-directory }}
169162

170163
- name: Start local Atlas
171164
run: bash scripts/start_local_atlas.sh
172165

173-
- name: Get MongoDB URI
174-
run: cat .local_atlas_uri >> $GITHUB_ENV
175-
176166
- name: Install Ollama
177167
run: curl -fsSL https://ollama.com/install.sh | sh
178168

@@ -186,22 +176,11 @@ jobs:
186176
run: just integration_tests
187177
working-directory: ${{ inputs.working-directory }}
188178

189-
- name: Get minimum versions
190-
working-directory: ${{ inputs.working-directory }}
191-
id: min-version
192-
run: |
193-
poetry run pip install packaging
194-
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
195-
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
196-
echo "min-versions=$min_versions"
197-
198179
- name: Run unit tests with minimum dependency versions
199-
if: ${{ steps.min-version.outputs.min-versions != '' }}
200-
env:
201-
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
202180
run: |
203-
poetry run pip install $MIN_VERSIONS
204-
just tests
181+
uv sync --python=${{ matrix.python-version }} --resolution=lowest-direct
182+
just test || git checkout uv.lock
183+
git checkout uv.lock
205184
working-directory: ${{ inputs.working-directory }}
206185

207186
publish:
@@ -225,13 +204,12 @@ jobs:
225204
steps:
226205
- uses: actions/checkout@v4
227206

228-
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
229-
uses: "./.github/actions/poetry_setup"
207+
- name: Install uv
208+
uses: astral-sh/setup-uv@v5
230209
with:
210+
enable-cache: true
231211
python-version: ${{ env.PYTHON_VERSION }}
232-
poetry-version: ${{ env.POETRY_VERSION }}
233-
working-directory: ${{ inputs.working-directory }}
234-
cache-key: release
212+
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"
235213

236214
- uses: actions/download-artifact@v4
237215
with:
@@ -266,13 +244,12 @@ jobs:
266244
steps:
267245
- uses: actions/checkout@v4
268246

269-
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
270-
uses: "./.github/actions/poetry_setup"
247+
- name: Install uv
248+
uses: astral-sh/setup-uv@v5
271249
with:
250+
enable-cache: true
272251
python-version: ${{ env.PYTHON_VERSION }}
273-
poetry-version: ${{ env.POETRY_VERSION }}
274-
working-directory: ${{ inputs.working-directory }}
275-
cache-key: releaseartifact@v4
252+
cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock"
276253

277254
- uses: actions/download-artifact@v4
278255
with:

0 commit comments

Comments
 (0)