Skip to content

Commit 46c601a

Browse files
authored
👷 Update build setup for sqlmodel-slim, deprecate it, and make it only depend on sqlmodel (#1753)
1 parent a87ac73 commit 46c601a

File tree

4 files changed

+90
-32
lines changed

4 files changed

+90
-32
lines changed

.github/workflows/test-redistribute.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ on:
1212
jobs:
1313
test-redistribute:
1414
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
package:
18-
- sqlmodel
19-
- sqlmodel-slim
2015
steps:
2116
- name: Dump GitHub context
2217
env:
@@ -30,8 +25,6 @@ jobs:
3025
- name: Install build dependencies
3126
run: pip install build
3227
- name: Build source distribution
33-
env:
34-
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
3528
run: python -m build --sdist
3629
- name: Decompress source distribution
3730
run: |
@@ -41,8 +34,6 @@ jobs:
4134
run: |
4235
cd dist/sqlmodel*/
4336
pip install --group tests --editable .
44-
env:
45-
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
4637
- name: Run source distribution tests
4738
run: |
4839
cd dist/sqlmodel*/

pdm_build.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@
33

44
from pdm.backend.hooks import Context
55

6-
TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "sqlmodel")
6+
TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "typer")
77

88

99
def pdm_build_initialize(context: Context) -> None:
1010
metadata = context.config.metadata
11+
# Get main version
12+
version = metadata["version"]
1113
# Get custom config for the current package, from the env var
12-
config: dict[str, Any] = context.config.data["tool"]["tiangolo"][
14+
all_configs_config: dict[str, Any] = context.config.data["tool"]["tiangolo"][
1315
"_internal-slim-build"
14-
]["packages"][TIANGOLO_BUILD_PACKAGE]
16+
]["packages"]
17+
18+
if TIANGOLO_BUILD_PACKAGE not in all_configs_config:
19+
return
20+
21+
config = all_configs_config[TIANGOLO_BUILD_PACKAGE]
1522
project_config: dict[str, Any] = config["project"]
16-
# Get main optional dependencies, extras
17-
optional_dependencies: dict[str, list[str]] = metadata.get(
18-
"optional-dependencies", {}
19-
)
20-
# Get custom optional dependencies name to always include in this (non-slim) package
21-
include_optional_dependencies: list[str] = config.get(
22-
"include-optional-dependencies", []
23-
)
2423
# Override main [project] configs with custom configs for this package
2524
for key, value in project_config.items():
2625
metadata[key] = value
@@ -33,7 +32,9 @@ def pdm_build_initialize(context: Context) -> None:
3332
context.config.build_config[key] = value
3433
# Get main dependencies
3534
dependencies: list[str] = metadata.get("dependencies", [])
36-
# Add optional dependencies to the default dependencies for this (non-slim) package
37-
for include_optional in include_optional_dependencies:
38-
optional_dependencies_group = optional_dependencies.get(include_optional, [])
39-
dependencies.extend(optional_dependencies_group)
35+
# Sync versions in dependencies
36+
new_dependencies = []
37+
for dep in dependencies:
38+
new_dep = f"{dep}>={version}"
39+
new_dependencies.append(new_dep)
40+
metadata["dependencies"] = new_dependencies

pyproject.toml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,29 @@ source-includes = [
103103

104104
[tool.tiangolo._internal-slim-build.packages.sqlmodel-slim.project]
105105
name = "sqlmodel-slim"
106-
107-
[tool.tiangolo._internal-slim-build.packages.sqlmodel]
108-
# include-optional-dependencies = ["standard"]
109-
110-
[tool.tiangolo._internal-slim-build.packages.sqlmodel.project]
106+
readme = "sqlmodel-slim/README.md"
107+
dependencies = [
108+
"sqlmodel",
109+
]
111110
optional-dependencies = {}
112-
113-
# [tool.tiangolo._internal-slim-build.packages.sqlmodel.project.scripts]
114-
# sqlmodel = "sqlmodel.cli:main"
111+
scripts = {}
112+
113+
[tool.tiangolo._internal-slim-build.packages.sqlmodel-slim.tool.pdm.build]
114+
# excludes needs to explicitly exclude the top level python packages,
115+
# otherwise PDM includes them by default
116+
# A "*" glob pattern can't be used here because in PDM internals, the patterns are put
117+
# in a set (unordered, order varies) and each excluded file is assigned one of the
118+
# glob patterns that matches, as the set is unordered, the matched pattern could be "*"
119+
# independent of the order here. And then the internal code would give it a lower score
120+
# than the one for a default included file.
121+
# By not using "*" and explicitly excluding the top level packages, they get a higher
122+
# score than the default inclusion
123+
excludes = ["sqlmodel", "tests", "pdm_build.py"]
124+
# source-includes needs to explicitly define some value because PDM will check the
125+
# truthy value of the list, and if empty, will include some defaults, including "tests",
126+
# an empty string doesn't match anything, but makes the list truthy, so that PDM
127+
# doesn't override it during the build.
128+
source-includes = [""]
115129

116130
[tool.coverage.run]
117131
parallel = true

sqlmodel-slim/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<p align="center">
2+
<a href="https://sqlmodel.tiangolo.com"><img src="https://sqlmodel.tiangolo.com/img/logo-margin/logo-margin-vector.svg#only-light" alt="SQLModel"></a>
3+
4+
</p>
5+
<p align="center">
6+
<em>SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.</em>
7+
</p>
8+
<p align="center">
9+
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
10+
<img src="https://github.com/fastapi/sqlmodel/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Test">
11+
</a>
12+
<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3APublish" target="_blank">
13+
<img src="https://github.com/fastapi/sqlmodel/actions/workflows/publish.yml/badge.svg" alt="Publish">
14+
</a>
15+
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/sqlmodel" target="_blank">
16+
<img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/sqlmodel.svg" alt="Coverage">
17+
<a href="https://pypi.org/project/sqlmodel" target="_blank">
18+
<img src="https://img.shields.io/pypi/v/sqlmodel?color=%2334D058&label=pypi%20package" alt="Package version">
19+
</a>
20+
</p>
21+
22+
---
23+
24+
**Documentation**: <a href="https://sqlmodel.tiangolo.com" target="_blank">https://sqlmodel.tiangolo.com</a>
25+
26+
**Source Code**: <a href="https://github.com/fastapi/sqlmodel" target="_blank">https://github.com/fastapi/sqlmodel</a>
27+
28+
---
29+
30+
SQLModel is a library for interacting with <abbr title='Also called "Relational databases"'>SQL databases</abbr> from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.
31+
32+
**SQLModel** is based on Python type annotations, and powered by <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> and <a href="https://sqlalchemy.org/" class="external-link" target="_blank">SQLAlchemy</a>.
33+
34+
## `sqlmodel-slim`
35+
36+
⚠️ Do not install this package. ⚠️
37+
38+
This package, `sqlmodel-slim`, does nothing other than depend on `sqlmodel`.
39+
40+
You **should not** install this package.
41+
42+
Install instead:
43+
44+
```bash
45+
pip install sqlmodel
46+
```
47+
48+
This package is deprecated and will stop receiving any updates and published versions.
49+
50+
## License
51+
52+
This project is licensed under the terms of the MIT license.

0 commit comments

Comments
 (0)