Skip to content

Commit 696e7b6

Browse files
chore: manage dependencies with uv (Universal-Commerce-Protocol#126)
1 parent dcfbdcb commit 696e7b6

8 files changed

Lines changed: 1622 additions & 69 deletions

File tree

.github/workflows/docs.yml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,14 @@ jobs:
5757
sudo apt-get update
5858
sudo apt-get install -y libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev
5959
60-
- name: Setup Python
61-
uses: actions/setup-python@v6
62-
with:
63-
python-version: 3.13
64-
65-
- name: Restore pip cache
66-
uses: actions/cache@v4
67-
with:
68-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-docs.txt') }}
69-
path: ~/.cache/pip
70-
restore-keys: |
71-
${{ runner.os }}-pip-
60+
- name: Install the latest version of uv
61+
uses: astral-sh/setup-uv@v7
7262

7363
- name: Install documentation dependencies
74-
run: pip install -r requirements-docs.txt
64+
run: uv sync
7565

7666
- name: Lint YAML files
77-
run: yamllint -c .github/linters/.yamllint.yml .
78-
79-
- name: Install uv
80-
run: |
81-
curl -LsSf https://astral.sh/uv/install.sh | sh
82-
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
67+
run: uv run yamllint -c .github/linters/.yamllint.yml .
8368

8469
- name: Check for changed files in spec
8570
id: spec_files_changed
@@ -102,12 +87,12 @@ jobs:
10287
10388
- name: Build Documentation (PR Check)
10489
if: github.event_name == 'pull_request'
105-
run: mkdocs build --strict
90+
run: uv run mkdocs build --strict
10691

10792
- name: Deploy development version from main branch
10893
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
10994
run: |
110-
mike deploy --push draft
95+
uv run mike deploy --push draft
11196
11297
- name: Deploy release version
11398
if: startsWith(github.ref, 'refs/heads/release/')
@@ -116,8 +101,8 @@ jobs:
116101
VERSION_NAME=${GITHUB_REF#refs/heads/release/}
117102
118103
# Deploy this version, tag it as 'latest', and set it as the default site root
119-
mike deploy --push --update-aliases $VERSION_NAME latest
120-
mike set-default --push latest
104+
uv run mike deploy --push --update-aliases $VERSION_NAME latest
105+
uv run mike set-default --push latest
121106
122107
- name: Create GitHub Release and Tag
123108
if: startsWith(github.ref, 'refs/heads/release/')

CONTRIBUTING.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ You can run many of these checks locally before committing by installing and
190190
using `pre-commit`:
191191

192192
```bash
193-
pip install pre-commit
193+
uv tool install pre-commit
194194
pre-commit install
195195
```
196196

@@ -212,12 +212,12 @@ This will set up pre-commit hooks to run automatically when you `git commit`.
212212
### Spec Development
213213

214214
1. Make relevant updates to JSON files in `source/`
215-
2. Run `python generate_schemas.py` to generate updated files in `spec/`
215+
2. Run `uv run generate_schemas.py` to generate updated files in `spec/`
216216
3. Check outputs from step above to ensure deltas are expected. You may need to
217217
extend `generate_schemas.py` if you are introducing a new generation concept
218218

219219
To validate JSON and YAML files format and references in `spec/`, run
220-
`python validate_specs.py`.
220+
`uv run validate_specs.py`.
221221

222222
If you change any JSON schemas in `spec/`, you must regenerate any SDK client
223223
libraries that depend on them. For example, to regenerate Python Pydantic
@@ -230,25 +230,26 @@ are updated to ensure there are no broken references or stale/missing contents.
230230

231231
### Documentation Development
232232

233-
1. Ensure dependencies are installed: `pip install -r requirements-docs.txt`
234-
2. Run the development server: `mkdocs serve --watch spec`
233+
1. Ensure dependencies are installed: `uv sync`
234+
2. Run the development server: `uv run mkdocs serve --watch spec`
235235
3. Open **<http://127.0.0.1:8000>** in your browser
236236
4. Before submitting a pull request with documentation changes, run
237-
`mkdocs build --strict` to ensure there are no warnings or errors. Our CI
237+
`uv run mkdocs build --strict` to ensure there are no warnings or errors. Our CI
238238
build uses this command and will fail if warnings are present (e.g.,
239239
broken links).
240240

241-
### Using a virtual environment (Recommended)
241+
### Using uv (Recommended)
242242

243-
To avoid polluting your global environment, use a virtual environment. Prefix
244-
the virtual environment name with a `.` so the versioning control systems don't
245-
track pip install files:
243+
This project uses `uv` to manage dependencies and virtual environments. To set up
244+
your development environment:
246245

247246
```bash
248-
$ sudo apt-get install virtualenv python3-venv
249-
$ virtualenv .ucp # or python3 -m venv .ucp
250-
$ source .ucp/bin/activate
251-
(.ucp) $ pip install -r requirements-docs.txt
252-
(.ucp) $ mkdocs serve --watch spec
253-
(.ucp) $ deactivate # when done
247+
# Install dependencies and set up the virtual environment
248+
$ uv sync
249+
250+
# Run development commands using 'uv run'
251+
$ uv run mkdocs serve --watch spec
254252
```
253+
254+
`uv` will automatically manage a virtual environment in the `.venv` directory.
255+
You don't need to manually activate it if you use `uv run`.

generate_schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Pass 3: Generates Embedded Protocol OpenRPC spec by aggregating methods
2424
from source/services/shopping/embedded.json and extension schemas.
2525
26-
Usage: python generate_schemas.py
26+
Usage: uv run generate_schemas.py
2727
"""
2828

2929
import copy

pyproject.toml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ version = "2026.01.23"
44
description = "Universal Commerce Protocol"
55
readme = "README.md"
66
requires-python = ">=3.10"
7-
dependencies = [
8-
"datamodel-code-generator[http]>=0.50.0",
9-
]
107

118
[tool.ruff]
129
line-length = 80
@@ -15,6 +12,22 @@ indent-width = 2
1512
[tool.setuptools]
1613
packages = []
1714

15+
[dependency-groups]
16+
dev = [
17+
"datamodel-code-generator[http]>=0.50.0",
18+
"mike==2.1.3",
19+
"mkdocs-llmstxt==0.5.0",
20+
"mkdocs-macros-plugin==1.4.0",
21+
"mkdocs-material[imaging]>=9.0.0",
22+
"mkdocs-redirects==1.2.2",
23+
"mkdocs-site-urls==0.3.1",
24+
"yamllint==1.35.1",
25+
]
26+
27+
[[tool.uv.index]]
28+
url = "https://pypi.org/simple"
29+
default = true
30+
1831
[tool.ruff.format]
1932
quote-style = "double"
2033
indent-style = "space"

requirements-docs.txt

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

scripts/ci_check_models.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ echo "Generating Pydantic models from $SCHEMA_DIR to temporary dir $OUTPUT_DIR..
4343
# Run generation using uv
4444
uv run \
4545
--link-mode=copy \
46-
--extra-index-url https://pypi.org/simple python \
46+
python \
4747
-m datamodel_code_generator \
4848
--input "$SCHEMA_DIR" \
4949
--input-file-type jsonschema \

0 commit comments

Comments
 (0)