Skip to content

Commit 0b4989d

Browse files
authored
🔧 Migrate from Poetry to PDM for the internal build config (#912)
1 parent f67867f commit 0b4989d

File tree

10 files changed

+145
-88
lines changed

10 files changed

+145
-88
lines changed

.github/workflows/build-docs.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- README.md
2828
- docs/**
2929
- docs_src/**
30+
- requirements-docs.txt
3031
- pyproject.toml
3132
- mkdocs.yml
3233
- mkdocs.insiders.yml
@@ -52,21 +53,16 @@ jobs:
5253
id: cache
5354
with:
5455
path: ${{ env.pythonLocation }}
55-
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
56-
- name: Install Poetry
56+
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v01
57+
- name: Install docs extras
5758
if: steps.cache.outputs.cache-hit != 'true'
58-
run: |
59-
python -m pip install --upgrade pip
60-
python -m pip install "poetry"
61-
python -m poetry self add poetry-version-plugin
62-
- name: Configure poetry
63-
run: python -m poetry config virtualenvs.create false
64-
- name: Install Dependencies
65-
if: steps.cache.outputs.cache-hit != 'true'
66-
run: python -m poetry install
59+
run: pip install -r requirements-docs.txt
6760
- name: Install Material for MkDocs Insiders
6861
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
69-
run: python -m poetry run pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
62+
run: |
63+
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
64+
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
65+
pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
7066
- uses: actions/cache@v3
7167
with:
7268
key: mkdocs-cards-${{ github.ref }}

.github/workflows/publish.yml

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,23 @@ on:
1414
jobs:
1515
publish:
1616
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
package:
20+
- sqlmodel
21+
permissions:
22+
id-token: write
1723
steps:
1824
- uses: actions/checkout@v4
1925
- name: Set up Python
2026
uses: actions/setup-python@v4
2127
with:
22-
python-version: "3.7"
23-
# Allow debugging with tmate
24-
- name: Setup tmate session
25-
uses: mxschmitt/action-tmate@v3
26-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
27-
with:
28-
limit-access-to-actor: true
29-
- uses: actions/cache@v3
30-
id: cache
31-
with:
32-
path: ${{ env.pythonLocation }}
33-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
34-
- name: Install poetry
35-
if: steps.cache.outputs.cache-hit != 'true'
36-
run: |
37-
python -m pip install --upgrade pip
38-
python -m pip install "poetry"
39-
python -m poetry self add poetry-version-plugin
40-
- name: Configure poetry
41-
run: python -m poetry config virtualenvs.create false
42-
- name: Install Dependencies
43-
if: steps.cache.outputs.cache-hit != 'true'
44-
run: python -m poetry install
45-
- name: Publish
28+
python-version: "3.11"
29+
- name: Install build dependencies
30+
run: pip install build
31+
- name: Build distribution
4632
env:
47-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
48-
run: |
49-
python -m poetry config pypi-token.pypi $PYPI_TOKEN
50-
bash scripts/publish.sh
33+
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
34+
run: python -m build
35+
- name: Publish
36+
uses: pypa/gh-action-pypi-publish@v1.8.11
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test Redistribute
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
12+
jobs:
13+
test-redistribute:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
package:
18+
- sqlmodel
19+
steps:
20+
- name: Dump GitHub context
21+
env:
22+
GITHUB_CONTEXT: ${{ toJson(github) }}
23+
run: echo "$GITHUB_CONTEXT"
24+
- uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.10"
29+
- name: Install build dependencies
30+
run: pip install build
31+
- name: Build source distribution
32+
env:
33+
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
34+
run: python -m build --sdist
35+
- name: Decompress source distribution
36+
run: |
37+
cd dist
38+
tar xvf sqlmodel*.tar.gz
39+
- name: Install test dependencies
40+
run: |
41+
cd dist/sqlmodel*/
42+
pip install -r requirements-tests.txt
43+
- name: Run source distribution tests
44+
run: |
45+
cd dist/sqlmodel*/
46+
bash scripts/test.sh
47+
- name: Build wheel distribution
48+
run: |
49+
cd dist
50+
pip wheel --no-deps sqlmodel*.tar.gz

.github/workflows/test.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,10 @@ jobs:
5151
id: cache
5252
with:
5353
path: ${{ env.pythonLocation }}
54-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
55-
- name: Install poetry
56-
if: steps.cache.outputs.cache-hit != 'true'
57-
run: |
58-
python -m pip install --upgrade pip
59-
python -m pip install "poetry"
60-
python -m poetry self add poetry-version-plugin
61-
- name: Configure poetry
62-
run: python -m poetry config virtualenvs.create false
54+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}
6355
- name: Install Dependencies
6456
if: steps.cache.outputs.cache-hit != 'true'
65-
run: python -m poetry install
57+
run: pip install -r requirements-tests.txt
6658
- name: Install Pydantic v1
6759
if: matrix.pydantic-version == 'pydantic-v1'
6860
run: pip install --upgrade "pydantic>=1.10.0,<2.0.0"
@@ -72,10 +64,10 @@ jobs:
7264
- name: Lint
7365
# Do not run on Python 3.7 as mypy behaves differently
7466
if: matrix.python-version != '3.7' && matrix.pydantic-version == 'pydantic-v2'
75-
run: python -m poetry run bash scripts/lint.sh
67+
run: bash scripts/lint.sh
7668
- run: mkdir coverage
7769
- name: Test
78-
run: python -m poetry run bash scripts/test.sh
70+
run: bash scripts/test.sh
7971
env:
8072
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
8173
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}

pyproject.toml

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["pdm-backend"]
3+
build-backend = "pdm.backend"
4+
5+
[project]
26
name = "sqlmodel"
3-
version = "0"
7+
dynamic = ["version"]
48
description = "SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness."
5-
authors = ["Sebastián Ramírez <[email protected]>"]
69
readme = "README.md"
7-
homepage = "https://github.com/tiangolo/sqlmodel"
8-
documentation = "https://sqlmodel.tiangolo.com"
9-
repository = "https://github.com/tiangolo/sqlmodel"
10-
license = "MIT"
11-
exclude = ["sqlmodel/sql/expression.py.jinja2"]
10+
requires-python = ">=3.7"
11+
authors = [
12+
{ name = "Sebastián Ramírez", email = "tiangolo@gmail.com" },
13+
]
14+
1215
classifiers = [
1316
"Development Status :: 4 - Beta",
1417
"Framework :: AsyncIO",
@@ -31,36 +34,28 @@ classifiers = [
3134
"Typing :: Typed",
3235
]
3336

34-
[tool.poetry.dependencies]
35-
python = "^3.7"
36-
SQLAlchemy = ">=2.0.0,<2.1.0"
37-
pydantic = ">=1.10.13,<3.0.0"
37+
dependencies = [
38+
"SQLAlchemy >=2.0.0,<2.1.0",
39+
"pydantic >=1.10.13,<3.0.0",
40+
]
3841

39-
[tool.poetry.group.dev.dependencies]
40-
pytest = "^7.0.1"
41-
mypy = "1.4.1"
42-
# Needed by the code generator using templates
43-
black = ">=22.10,<24.0"
44-
mkdocs-material = "9.2.7"
45-
pillow = "^9.3.0"
46-
cairosvg = "^2.5.2"
47-
mdx-include = "^1.4.1"
48-
coverage = {extras = ["toml"], version = ">=6.2,<8.0"}
49-
fastapi = "^0.103.2"
50-
ruff = "0.2.0"
51-
# For FastAPI tests
52-
httpx = "0.24.1"
53-
# TODO: upgrade when deprecating Python 3.7
54-
dirty-equals = "^0.6.0"
55-
typer-cli = "^0.0.13"
56-
mkdocs-markdownextradata-plugin = ">=0.1.7,<0.3.0"
42+
[project.urls]
43+
Homepage = "https://github.com/tiangolo/sqlmodel"
44+
Documentation = "https://sqlmodel.tiangolo.com"
45+
Repository = "https://github.com/tiangolo/sqlmodel"
5746

58-
[build-system]
59-
requires = ["poetry-core"]
60-
build-backend = "poetry.core.masonry.api"
47+
[tool.pdm]
48+
version = { source = "file", path = "sqlmodel/__init__.py" }
49+
distribution = true
6150

62-
[tool.poetry-version-plugin]
63-
source = "init"
51+
[tool.pdm.build]
52+
source-includes = [
53+
"tests/",
54+
"docs_src/",
55+
"requirements*.txt",
56+
"scripts/",
57+
"sqlmodel/sql/expression.py.jinja2",
58+
]
6459

6560
[tool.coverage.run]
6661
parallel = true

requirements-docs-tests.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# For mkdocstrings and code generator using templates
2+
black >=22.10,<24.0

requirements-docs.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-e .
2+
-r requirements-docs-tests.txt
3+
mkdocs-material==9.4.7
4+
mdx-include >=1.4.1,<2.0.0
5+
mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
6+
mkdocs-redirects>=1.2.1,<1.3.0
7+
pyyaml >=5.3.1,<7.0.0
8+
# For Material for MkDocs, Chinese search
9+
jieba==0.42.1
10+
# For image processing by Material for MkDocs
11+
pillow==10.1.0
12+
# For image processing by Material for MkDocs
13+
cairosvg==2.7.0
14+
mkdocstrings[python]==0.23.0
15+
griffe-typingdoc==0.2.2
16+
# For griffe, it formats with black
17+
black==23.3.0
18+
typer == 0.12.3

requirements-tests.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-e .
2+
-r requirements-docs-tests.txt
3+
pytest >=7.0.1,<8.0.0
4+
coverage[toml] >=6.2,<8.0
5+
mypy ==1.4.1
6+
ruff ==0.2.0
7+
# For FastAPI tests
8+
fastapi >=0.103.2
9+
httpx ==0.24.1
10+
# TODO: upgrade when deprecating Python 3.7
11+
dirty-equals ==0.6.0
12+
jinja2 ==3.1.3

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-e .
2+
3+
-r requirements-tests.txt
4+
-r requirements-docs.txt
5+
6+
pre-commit >=2.17.0,<4.0.0

sqlmodel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.16"
1+
__version__ = "0.0.17.dev2"
22

33
# Re-export from SQLAlchemy
44
from sqlalchemy.engine import create_engine as create_engine

0 commit comments

Comments
 (0)