Skip to content

Commit 9d076ba

Browse files
authored
chore: Migrate from Poetry to uv workspace (PR-1) (#101)
1 parent aa60c82 commit 9d076ba

16 files changed

Lines changed: 230 additions & 230 deletions

File tree

.github/actions/ci/action.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@ inputs:
1212
runs:
1313
using: composite
1414
steps:
15-
- name: Set up Python ${{ inputs.python_version }}
16-
uses: actions/setup-python@v5
15+
- name: Set up uv
16+
uses: astral-sh/setup-uv@6ee6290f1cbc4156c0bdd66691b2c144ef8df19a # v7.4
1717
with:
1818
python-version: ${{ inputs.python_version }}
1919

20-
- name: Install poetry
21-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
22-
2320
- name: Install Dependencies
2421
shell: bash
25-
working-directory: ${{ inputs.workspace_path }}
26-
run: poetry install
22+
run: make -C ${{ inputs.workspace_path }} install
2723

2824
- name: Lint
2925
shell: bash

.github/workflows/ci.yml

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,13 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v4
4646

47-
- name: Set up Python ${{ matrix.python-version }}
48-
uses: actions/setup-python@v5
47+
- name: Set up uv
48+
uses: astral-sh/setup-uv@6ee6290f1cbc4156c0bdd66691b2c144ef8df19a # v7.4
4949
with:
5050
python-version: ${{ matrix.python-version }}
5151

52-
- name: Install poetry
53-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
54-
55-
- name: Install requirements
56-
working-directory: packages/sdk/server-ai
57-
run: poetry install
52+
- name: Install dependencies
53+
run: make -C packages/sdk/server-ai install
5854

5955
- name: Run tests
6056
run: make -C packages/sdk/server-ai test
@@ -90,24 +86,13 @@ jobs:
9086
steps:
9187
- uses: actions/checkout@v4
9288

93-
- name: Set up Python ${{ matrix.python-version }}
94-
uses: actions/setup-python@v5
89+
- name: Set up uv
90+
uses: astral-sh/setup-uv@6ee6290f1cbc4156c0bdd66691b2c144ef8df19a # v7.4
9591
with:
9692
python-version: ${{ matrix.python-version }}
9793

98-
- name: Install poetry
99-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
100-
101-
- name: Configure poetry for local virtualenvs
102-
run: poetry config virtualenvs.in-project true
103-
104-
- name: Install server-ai dependency first
105-
working-directory: packages/sdk/server-ai
106-
run: poetry install
107-
108-
- name: Install requirements
109-
working-directory: packages/ai-providers/server-ai-langchain
110-
run: poetry install
94+
- name: Install dependencies
95+
run: make -C packages/ai-providers/server-ai-langchain install
11196

11297
- name: Run tests
11398
run: make -C packages/ai-providers/server-ai-langchain test
@@ -143,24 +128,13 @@ jobs:
143128
steps:
144129
- uses: actions/checkout@v4
145130

146-
- name: Set up Python ${{ matrix.python-version }}
147-
uses: actions/setup-python@v5
131+
- name: Set up uv
132+
uses: astral-sh/setup-uv@6ee6290f1cbc4156c0bdd66691b2c144ef8df19a # v7.4
148133
with:
149134
python-version: ${{ matrix.python-version }}
150135

151-
- name: Install poetry
152-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
153-
154-
- name: Configure poetry for local virtualenvs
155-
run: poetry config virtualenvs.in-project true
156-
157-
- name: Install server-ai dependency first
158-
working-directory: packages/sdk/server-ai
159-
run: poetry install
160-
161-
- name: Install requirements
162-
working-directory: packages/ai-providers/server-ai-openai
163-
run: poetry install
136+
- name: Install dependencies
137+
run: make -C packages/ai-providers/server-ai-openai install
164138

165139
- name: Run tests
166140
run: make -C packages/ai-providers/server-ai-openai test

.github/workflows/release-please.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ jobs:
6363
with:
6464
fetch-depth: 0
6565

66-
- uses: actions/setup-python@v5
67-
with:
68-
python-version: '3.11'
69-
70-
- name: Install poetry
71-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # 7b6d33e44b4f08d7021a1dee3c044e9c253d6439
72-
7366
- uses: ./.github/actions/ci
7467
with:
7568
workspace_path: packages/sdk/server-ai
@@ -104,13 +97,6 @@ jobs:
10497
with:
10598
fetch-depth: 0
10699

107-
- uses: actions/setup-python@v5
108-
with:
109-
python-version: '3.11'
110-
111-
- name: Install poetry
112-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # 7b6d33e44b4f08d7021a1dee3c044e9c253d6439
113-
114100
- uses: ./.github/actions/ci
115101
with:
116102
workspace_path: packages/ai-providers/server-ai-langchain
@@ -141,13 +127,6 @@ jobs:
141127
steps:
142128
- uses: actions/checkout@v4
143129

144-
- uses: actions/setup-python@v5
145-
with:
146-
python-version: '3.11'
147-
148-
- name: Install poetry
149-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # 7b6d33e44b4f08d7021a1dee3c044e9c253d6439
150-
151130
- uses: ./.github/actions/ci
152131
with:
153132
workspace_path: ${{ inputs.workspace_path }}
@@ -210,13 +189,6 @@ jobs:
210189
with:
211190
fetch-depth: 0
212191

213-
- uses: actions/setup-python@v5
214-
with:
215-
python-version: '3.11'
216-
217-
- name: Install poetry
218-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439 # 7b6d33e44b4f08d7021a1dee3c044e9c253d6439
219-
220192
- uses: ./.github/actions/ci
221193
with:
222194
workspace_path: packages/ai-providers/server-ai-openai

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@ test-packaging-venv
7272
.vscode/
7373
.python-version
7474

75-
# Poetry
76-
poetry.lock
75+
# uv — lock file is not committed for libraries (only for applications)
76+
uv.lock
77+
.venv/

.readthedocs.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
version: 2
22

3-
build:
4-
os: "ubuntu-22.04"
5-
tools:
6-
python: "3.12"
7-
jobs:
8-
post_create_environment:
9-
- python -m pip install poetry
10-
post_install:
11-
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
12-
133
sphinx:
144
builder: html
155
configuration: docs/conf.py
166
fail_on_warning: true
7+
8+
build:
9+
os: ubuntu-24.04
10+
tools:
11+
python: "3.12"
12+
jobs:
13+
pre_create_environment:
14+
- asdf plugin add uv
15+
- asdf install uv latest
16+
- asdf global uv latest
17+
create_environment:
18+
- uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
19+
install:
20+
- UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --project packages/sdk/server-ai --group docs

CONTRIBUTING.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,29 @@ We encourage pull requests and other contributions from the community. Before su
1414

1515
### Setup
1616

17-
This project is built using [poetry](https://python-poetry.org/). To learn more about the basics of working with this tool, read [Poetry's basic usage guide](https://python-poetry.org/docs/basic-usage/).
17+
This project is built using [uv](https://docs.astral.sh/uv/). The repo is structured as a uv workspace — a single shared virtual environment at the repo root contains all packages and their dependencies, and cross-package dependencies (e.g. the provider packages depending on `launchdarkly-server-sdk-ai`) are automatically resolved from the local workspace members.
1818

19-
To begin development, ensure your dependencies are installed and (optionally) activate the virtualenv.
19+
To install uv, see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
2020

21+
To install all packages and dev dependencies into the shared workspace environment:
22+
23+
```shell
24+
make install
25+
# or directly:
26+
uv sync --all-groups
2127
```
22-
poetry install
23-
eval $(poetry env activate)
28+
29+
To activate the shared virtual environment:
30+
31+
```shell
32+
source .venv/bin/activate
33+
```
34+
35+
Alternatively, prefix any command with `uv run` to use the workspace environment without activating it:
36+
37+
```shell
38+
uv run pytest
39+
uv run mypy src/ldai
2440
```
2541

2642
### Testing
@@ -31,6 +47,14 @@ To run all unit tests:
3147
make test
3248
```
3349

50+
To run tests for a specific package:
51+
52+
```shell
53+
make test-server-ai
54+
make test-openai
55+
make test-langchain
56+
```
57+
3458
It is preferable to run tests against all supported minor versions of Python (as described in `README.md` under Requirements), or at least the lowest and highest versions, prior to submitting a pull request. However, LaunchDarkly's CI tests will run automatically against all supported versions.
3559

3660
### Building documentation

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ help: #! Show this help message
2323
#
2424

2525
.PHONY: install
26-
install: #! Install all packages
27-
$(MAKE) install-server-ai
28-
$(MAKE) install-langchain
29-
$(MAKE) install-openai
26+
install: #! Install all packages and dev dependencies into the shared workspace environment
27+
uv sync --all-groups
3028

3129
.PHONY: install-server-ai
3230
install-server-ai: #! Install server-ai package

packages/ai-providers/server-ai-langchain/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ help: #! Show this help message
99

1010
.PHONY: install
1111
install: #! Install package dependencies
12-
poetry install
12+
uv sync --all-groups
1313

1414
.PHONY: test
1515
test: #! Run unit tests
1616
test: install
17-
poetry run pytest $(PYTEST_FLAGS)
17+
uv run pytest $(PYTEST_FLAGS)
1818

1919
.PHONY: lint
2020
lint: #! Run type analysis and linting checks
2121
lint: install
22-
poetry run mypy src/ldai_langchain
23-
poetry run isort --check --atomic src/ldai_langchain
24-
poetry run pycodestyle src/ldai_langchain
22+
uv run mypy src/ldai_langchain
23+
uv run isort --check --atomic src/ldai_langchain
24+
uv run pycodestyle src/ldai_langchain
2525

2626
.PHONY: build
2727
build: #! Build distribution files
2828
build: install
29-
poetry build
29+
uv build --out-dir dist

packages/ai-providers/server-ai-langchain/pyproject.toml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
[tool.poetry]
1+
[project]
22
name = "launchdarkly-server-sdk-ai-langchain"
33
version = "0.3.2"
44
description = "LaunchDarkly AI SDK LangChain Provider"
5-
authors = ["LaunchDarkly <dev@launchdarkly.com>"]
6-
license = "Apache-2.0"
5+
authors = [{name = "LaunchDarkly", email = "dev@launchdarkly.com"}]
6+
license = {text = "Apache-2.0"}
77
readme = "README.md"
8-
homepage = "https://docs.launchdarkly.com/sdk/ai/python"
9-
repository = "https://github.com/launchdarkly/python-server-sdk-ai"
8+
requires-python = ">=3.9,<4"
109
classifiers = [
1110
"Intended Audience :: Developers",
1211
"License :: OSI Approved :: Apache Software License",
@@ -20,21 +19,32 @@ classifiers = [
2019
"Topic :: Software Development",
2120
"Topic :: Software Development :: Libraries",
2221
]
23-
packages = [{ include = "ldai_langchain", from = "src" }]
22+
dependencies = [
23+
"launchdarkly-server-sdk-ai>=0.16.0",
24+
"langchain-core>=0.2.0",
25+
"langchain>=0.2.0",
26+
]
27+
28+
[project.urls]
29+
Homepage = "https://docs.launchdarkly.com/sdk/ai/python"
30+
Repository = "https://github.com/launchdarkly/python-server-sdk-ai"
31+
32+
[dependency-groups]
33+
dev = [
34+
"pytest>=2.8",
35+
"pytest-cov>=2.4.0",
36+
"pytest-asyncio>=0.21.0",
37+
"mypy==1.18.2",
38+
"pycodestyle>=2.11.0",
39+
"isort>=5.12.0",
40+
]
2441

25-
[tool.poetry.dependencies]
26-
python = ">=3.9,<4"
27-
launchdarkly-server-sdk-ai = ">=0.16.0"
28-
langchain-core = ">=0.2.0"
29-
langchain = ">=0.2.0"
42+
[build-system]
43+
requires = ["hatchling"]
44+
build-backend = "hatchling.build"
3045

31-
[tool.poetry.group.dev.dependencies]
32-
pytest = ">=2.8"
33-
pytest-cov = ">=2.4.0"
34-
pytest-asyncio = ">=0.21.0"
35-
mypy = "==1.18.2"
36-
pycodestyle = ">=2.11.0"
37-
isort = ">=5.12.0"
46+
[tool.hatch.build.targets.wheel]
47+
packages = ["src/ldai_langchain"]
3848

3949
[tool.mypy]
4050
python_version = "3.9"
@@ -47,13 +57,7 @@ profile = "black"
4757
known_third_party = ["langchain", "langchain_core", "ldai"]
4858
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
4959

50-
5160
[tool.pytest.ini_options]
5261
addopts = ["-ra"]
5362
testpaths = ["tests"]
5463
asyncio_mode = "auto"
55-
56-
57-
[build-system]
58-
requires = ["poetry-core"]
59-
build-backend = "poetry.core.masonry.api"

packages/ai-providers/server-ai-openai/Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@ help: #! Show this help message
99

1010
.PHONY: install
1111
install: #! Install package dependencies
12-
poetry install
12+
uv sync --all-groups
1313

1414
.PHONY: test
1515
test: #! Run unit tests
1616
test: install
17-
poetry run pytest $(PYTEST_FLAGS)
17+
uv run pytest $(PYTEST_FLAGS)
1818

1919
.PHONY: lint
2020
lint: #! Run type analysis and linting checks
2121
lint: install
22-
poetry run mypy src/ldai_openai
23-
poetry run isort --check --atomic src/ldai_openai
24-
poetry run pycodestyle src/ldai_openai
22+
uv run mypy src/ldai_openai
23+
uv run isort --check --atomic src/ldai_openai
24+
uv run pycodestyle src/ldai_openai
2525

2626
.PHONY: build
2727
build: #! Build distribution files
2828
build: install
29-
poetry build
30-
29+
uv build --out-dir dist

0 commit comments

Comments
 (0)