Skip to content

Commit f456d3c

Browse files
committed
⬆️ Migrate to uv
1 parent 9262835 commit f456d3c

16 files changed

+3944
-105
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ updates:
88
commit-message:
99
prefix:
1010
# Python
11-
- package-ecosystem: "pip"
11+
- package-ecosystem: "uv"
1212
directory: "/"
1313
schedule:
1414
interval: "daily"

.github/workflows/build-docs.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ on:
88
- opened
99
- synchronize
1010

11-
env:
12-
UV_SYSTEM_PYTHON: 1
13-
14-
1511
jobs:
1612
changes:
1713
runs-on: ubuntu-latest
@@ -32,8 +28,8 @@ jobs:
3228
- README.md
3329
- docs/**
3430
- docs_src/**
35-
- requirements-docs.txt
3631
- pyproject.toml
32+
- uv.lock
3733
- mkdocs.yml
3834
- mkdocs.env.yml
3935
- .github/workflows/build-docs.yml
@@ -54,25 +50,24 @@ jobs:
5450
- name: Set up Python
5551
uses: actions/setup-python@v6
5652
with:
57-
python-version: "3.11"
53+
python-version-file: ".python-version"
5854
- name: Setup uv
5955
uses: astral-sh/setup-uv@v7
6056
with:
61-
version: "0.4.15"
6257
enable-cache: true
6358
cache-dependency-glob: |
64-
requirements**.txt
6559
pyproject.toml
60+
uv.lock
6661
- name: Install docs extras
67-
run: uv pip install -r requirements-docs.txt
62+
run: uv sync --locked --group docs
6863
- uses: actions/cache@v4
6964
with:
7065
key: mkdocs-cards-${{ github.ref }}
7166
path: .cache
7267
- name: Verify README
73-
run: python ./scripts/docs.py verify-readme
68+
run: uv run ./scripts/docs.py verify-readme
7469
- name: Build Docs
75-
run: python ./scripts/docs.py build
70+
run: uv run ./scripts/docs.py build
7671
- uses: actions/upload-artifact@v5
7772
with:
7873
name: docs-site

.github/workflows/deploy-docs.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ permissions:
1212
pull-requests: write
1313
statuses: write
1414

15-
env:
16-
UV_SYSTEM_PYTHON: 1
17-
1815
jobs:
1916
deploy-docs:
2017
runs-on: ubuntu-latest
@@ -27,19 +24,18 @@ jobs:
2724
- name: Set up Python
2825
uses: actions/setup-python@v6
2926
with:
30-
python-version: "3.11"
27+
python-version-file: ".python-version"
3128
- name: Setup uv
3229
uses: astral-sh/setup-uv@v7
3330
with:
34-
version: "0.4.15"
3531
enable-cache: true
3632
cache-dependency-glob: |
37-
requirements**.txt
3833
pyproject.toml
34+
uv.lock
3935
- name: Install GitHub Actions dependencies
40-
run: uv pip install -r requirements-github-actions.txt
36+
run: uv sync --locked --group github-actions
4137
- name: Deploy Docs Status Pending
42-
run: python ./scripts/deploy_docs_status.py
38+
run: uv run ./scripts/deploy_docs_status.py
4339
env:
4440
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4541
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
@@ -70,14 +66,14 @@ jobs:
7066
command: pages deploy ./site --project-name=${{ env.PROJECT_NAME }} --branch=${{ env.BRANCH }}
7167
- name: Deploy Docs Status Error
7268
if: failure()
73-
run: python ./scripts/deploy_docs_status.py
69+
run: uv run ./scripts/deploy_docs_status.py
7470
env:
7571
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7672
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
7773
RUN_ID: ${{ github.run_id }}
7874
STATE: "error"
7975
- name: Comment Deploy
80-
run: python ./scripts/deploy_docs_status.py
76+
run: uv run ./scripts/deploy_docs_status.py
8177
env:
8278
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8379
DEPLOY_URL: ${{ steps.deploy.outputs.deployment-url }}

.github/workflows/publish.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,22 @@ jobs:
2121
- sqlmodel-slim
2222
permissions:
2323
id-token: write
24+
contents: read
2425
steps:
26+
- name: Dump GitHub context
27+
env:
28+
GITHUB_CONTEXT: ${{ toJson(github) }}
29+
run: echo "$GITHUB_CONTEXT"
2530
- uses: actions/checkout@v6
2631
- name: Set up Python
2732
uses: actions/setup-python@v6
2833
with:
29-
python-version: "3.11"
30-
- name: Install build dependencies
31-
run: pip install build
34+
python-version-file: ".python-version"
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v7
3237
- name: Build distribution
38+
run: uv build
3339
env:
3440
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
35-
run: python -m build
3641
- name: Publish
37-
uses: pypa/gh-action-pypi-publish@v1.13.0
42+
run: uv publish

.github/workflows/smokeshow.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,21 @@ on:
88
permissions:
99
statuses: write
1010

11-
env:
12-
UV_SYSTEM_PYTHON: 1
13-
1411
jobs:
1512
smokeshow:
1613
runs-on: ubuntu-latest
1714
steps:
1815
- uses: actions/checkout@v6
1916
- uses: actions/setup-python@v6
2017
with:
21-
python-version: '3.13'
18+
python-version-file: ".python-version"
2219
- name: Setup uv
2320
uses: astral-sh/setup-uv@v7
2421
with:
2522
cache-dependency-glob: |
26-
requirements**.txt
2723
pyproject.toml
28-
- run: uv pip install -r requirements-github-actions.txt
24+
uv.lock
25+
- run: uv sync --locked --group github-actions
2926
- uses: actions/download-artifact@v6
3027
with:
3128
name: coverage-html

.github/workflows/test-redistribute.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up Python
2727
uses: actions/setup-python@v6
2828
with:
29-
python-version: "3.10"
29+
python-version-file: ".python-version"
3030
- name: Install build dependencies
3131
run: pip install build
3232
- name: Build source distribution
@@ -40,7 +40,7 @@ jobs:
4040
- name: Install test dependencies
4141
run: |
4242
cd dist/sqlmodel*/
43-
pip install -r requirements-tests.txt
43+
pip install --group dev --editable .
4444
env:
4545
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
4646
- name: Run source distribution tests

.github/workflows/test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
- cron: "0 0 * * 1"
2020

2121
env:
22-
UV_SYSTEM_PYTHON: 1
22+
UV_NO_SYNC: true
2323

2424
jobs:
2525
test:
@@ -53,6 +53,8 @@ jobs:
5353
pydantic-version: pydantic-v2
5454
fail-fast: false
5555
runs-on: ${{ matrix.os }}
56+
env:
57+
UV_PYTHON: ${{ matrix.python-version }}
5658
steps:
5759
- uses: actions/checkout@v6
5860
- name: Set up Python
@@ -62,19 +64,18 @@ jobs:
6264
- name: Setup uv
6365
uses: astral-sh/setup-uv@v7
6466
with:
65-
version: "0.4.15"
6667
enable-cache: true
6768
cache-dependency-glob: |
68-
requirements**.txt
6969
pyproject.toml
70+
uv.lock
7071
# Allow debugging with tmate
7172
- name: Setup tmate session
7273
uses: mxschmitt/action-tmate@v3
7374
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
7475
with:
7576
limit-access-to-actor: true
7677
- name: Install Dependencies
77-
run: uv pip install -r requirements-tests.txt
78+
run: uv sync --locked --all-extras --dev
7879
- name: Install Pydantic v1
7980
if: matrix.pydantic-version == 'pydantic-v1'
8081
run: uv pip install --upgrade "pydantic>=1.10.0,<2.0.0"
@@ -83,10 +84,10 @@ jobs:
8384
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
8485
- name: Lint
8586
if: matrix.pydantic-version == 'pydantic-v2' && matrix.python-version != '3.8'
86-
run: bash scripts/lint.sh
87+
run: uv run bash scripts/lint.sh
8788
- run: mkdir coverage
8889
- name: Test
89-
run: bash scripts/test.sh
90+
run: uv run bash scripts/test.sh
9091
env:
9192
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
9293
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
@@ -105,33 +106,32 @@ jobs:
105106
- uses: actions/checkout@v6
106107
- uses: actions/setup-python@v6
107108
with:
108-
python-version: '3.13'
109+
python-version-file: ".python-version"
109110
- name: Setup uv
110111
uses: astral-sh/setup-uv@v7
111112
with:
112-
version: "0.4.15"
113113
enable-cache: true
114114
cache-dependency-glob: |
115-
requirements**.txt
116115
pyproject.toml
116+
uv.lock
117117
- name: Get coverage files
118118
uses: actions/download-artifact@v6
119119
with:
120120
pattern: coverage-*
121121
path: coverage
122122
merge-multiple: true
123123
- name: Install Dependencies
124-
run: uv pip install -r requirements-tests.txt
124+
run: uv sync --locked --all-extras --dev
125125
- run: ls -la coverage
126-
- run: coverage combine coverage
127-
- run: coverage html --title "Coverage for ${{ github.sha }}"
126+
- run: uv run coverage combine coverage
127+
- run: uv run coverage html --title "Coverage for ${{ github.sha }}"
128128
- name: Store coverage HTML
129129
uses: actions/upload-artifact@v5
130130
with:
131131
name: coverage-html
132132
path: htmlcov
133133
include-hidden-files: true
134-
- run: coverage report --fail-under=99
134+
- run: uv run coverage report --fail-under=99
135135

136136
# https://github.com/marketplace/actions/alls-green#why
137137
alls-green: # This job does nothing and is only used for the branch protection

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9

docs/contributing.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ First, you might want to see the basic ways to [help SQLModel and get help](help
66

77
If you already cloned the <a href="https://github.com/fastapi/sqlmodel" class="external-link" target="_blank">sqlmodel repository</a> and you want to deep dive in the code, here are some guidelines to set up your environment.
88

9-
### Virtual Environment
9+
### Install Requirements Using `uv`
1010

11-
Follow the instructions to create and activate a [virtual environment](virtual-environments.md){.internal-link target=_blank} for the internal code of `sqlmodel`.
12-
13-
### Install Requirements Using `pip`
14-
15-
After activating the environment, install the required packages:
11+
Create a virtual environment and install the required packages in one command:
1612

1713
<div class="termy">
1814

1915
```console
20-
$ pip install -r requirements.txt
16+
$ uv sync
2117

2218
---> 100%
2319
```

pyproject.toml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,46 @@ Repository = "https://github.com/fastapi/sqlmodel"
4848
Issues = "https://github.com/fastapi/sqlmodel/issues"
4949
Changelog = "https://sqlmodel.tiangolo.com/release-notes/"
5050

51+
[dependency-groups]
52+
dev = [
53+
{ include-group = "docs" },
54+
"black>=22.10",
55+
"coverage[toml]>=6.2,<8.0",
56+
"dirty-equals==0.9.0",
57+
"fastapi>=0.103.2",
58+
"httpx==0.28.1",
59+
"jinja2==3.1.6",
60+
"mypy==1.14.1 ; python_full_version < '3.9'",
61+
"mypy==1.18.2 ; python_full_version >= '3.9'",
62+
"pre-commit>=2.17.0,<5.0.0",
63+
"pytest>=7.0.1,<9.0.0",
64+
"ruff==0.14.8",
65+
"typing-extensions==4.13.2 ; python_full_version < '3.9'",
66+
"typing-extensions==4.15.0 ; python_full_version >= '3.9'",
67+
]
68+
docs = [
69+
"black>=22.10",
70+
"cairosvg==2.8.2 ; python_full_version >= '3.9'",
71+
"griffe-typingdoc==0.3.0 ; python_full_version >= '3.9'",
72+
"griffe-warnings-deprecated==1.1.0 ; python_full_version >= '3.9'",
73+
"markdown-include-variants==0.0.5 ; python_full_version >= '3.9'",
74+
"mdx-include>=1.4.1,<2.0.0",
75+
"mkdocs-macros-plugin==1.5.0",
76+
"mkdocs-material==9.7.0",
77+
"mkdocs-redirects>=1.2.1,<1.3.0",
78+
"mkdocstrings[python]==0.30.1 ; python_full_version >= '3.9'",
79+
"pillow==11.3.0 ; python_full_version >= '3.9'",
80+
"pyyaml>=5.3.1,<7.0.0",
81+
"typer==0.20.0",
82+
]
83+
github-actions = [
84+
"httpx>=0.27.0,<0.29.0",
85+
"pydantic>=2.5.3,<3.0.0",
86+
"pydantic-settings>=2.1.0,<3.0.0",
87+
"pygithub>=2.3.0,<3.0.0",
88+
"smokeshow>=0.5.0",
89+
]
90+
5191
[tool.pdm]
5292
version = { source = "file", path = "sqlmodel/__init__.py" }
5393
distribution = true
@@ -56,10 +96,9 @@ distribution = true
5696
source-includes = [
5797
"tests/",
5898
"docs_src/",
59-
"requirements*.txt",
6099
"scripts/",
61100
"sqlmodel/sql/expression.py.jinja2",
62-
]
101+
]
63102

64103
[tool.tiangolo._internal-slim-build.packages.sqlmodel-slim.project]
65104
name = "sqlmodel-slim"

0 commit comments

Comments
 (0)