]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
👷 Update build setup for `sqlmodel-slim`, deprecate it, and make it only depend on...
authorSebastián Ramírez <tiangolo@gmail.com>
Wed, 11 Feb 2026 12:43:17 +0000 (04:43 -0800)
committerGitHub <noreply@github.com>
Wed, 11 Feb 2026 12:43:17 +0000 (12:43 +0000)
.github/workflows/test-redistribute.yml
pdm_build.py
pyproject.toml
sqlmodel-slim/README.md [new file with mode: 0644]

index a68344175a3626a303c69febe1f1c814e91f06a4..cf3ac46f9cd2d73c440b46fbff46631e6a192e9c 100644 (file)
@@ -12,11 +12,6 @@ on:
 jobs:
   test-redistribute:
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        package:
-          - sqlmodel
-          - sqlmodel-slim
     steps:
       - name: Dump GitHub context
         env:
@@ -30,8 +25,6 @@ jobs:
       - name: Install build dependencies
         run: pip install build
       - name: Build source distribution
-        env:
-          TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
         run: python -m build --sdist
       - name: Decompress source distribution
         run: |
@@ -41,8 +34,6 @@ jobs:
         run: |
           cd dist/sqlmodel*/
           pip install --group tests --editable .
-        env:
-          TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
       - name: Run source distribution tests
         run: |
           cd dist/sqlmodel*/
index 33a6b267e45977ae33f727205b34e281e1d7851a..67e71cbb05dcb05f84fc91d4238af26ae01f2511 100644 (file)
@@ -3,24 +3,23 @@ from typing import Any
 
 from pdm.backend.hooks import Context
 
-TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "sqlmodel")
+TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "typer")
 
 
 def pdm_build_initialize(context: Context) -> None:
     metadata = context.config.metadata
+    # Get main version
+    version = metadata["version"]
     # Get custom config for the current package, from the env var
-    config: dict[str, Any] = context.config.data["tool"]["tiangolo"][
+    all_configs_config: dict[str, Any] = context.config.data["tool"]["tiangolo"][
         "_internal-slim-build"
-    ]["packages"][TIANGOLO_BUILD_PACKAGE]
+    ]["packages"]
+
+    if TIANGOLO_BUILD_PACKAGE not in all_configs_config:
+        return
+
+    config = all_configs_config[TIANGOLO_BUILD_PACKAGE]
     project_config: dict[str, Any] = config["project"]
-    # Get main optional dependencies, extras
-    optional_dependencies: dict[str, list[str]] = metadata.get(
-        "optional-dependencies", {}
-    )
-    # Get custom optional dependencies name to always include in this (non-slim) package
-    include_optional_dependencies: list[str] = config.get(
-        "include-optional-dependencies", []
-    )
     # Override main [project] configs with custom configs for this package
     for key, value in project_config.items():
         metadata[key] = value
@@ -33,7 +32,9 @@ def pdm_build_initialize(context: Context) -> None:
         context.config.build_config[key] = value
     # Get main dependencies
     dependencies: list[str] = metadata.get("dependencies", [])
-    # Add optional dependencies to the default dependencies for this (non-slim) package
-    for include_optional in include_optional_dependencies:
-        optional_dependencies_group = optional_dependencies.get(include_optional, [])
-        dependencies.extend(optional_dependencies_group)
+    # Sync versions in dependencies
+    new_dependencies = []
+    for dep in dependencies:
+        new_dep = f"{dep}>={version}"
+        new_dependencies.append(new_dep)
+    metadata["dependencies"] = new_dependencies
index 69c9bd6a60736db7c30663056355b403e12ca70f..f3a516e47061a5b97a364463a6bebd19b7dc9391 100644 (file)
@@ -103,15 +103,29 @@ source-includes = [
 
 [tool.tiangolo._internal-slim-build.packages.sqlmodel-slim.project]
 name = "sqlmodel-slim"
-
-[tool.tiangolo._internal-slim-build.packages.sqlmodel]
-# include-optional-dependencies = ["standard"]
-
-[tool.tiangolo._internal-slim-build.packages.sqlmodel.project]
+readme = "sqlmodel-slim/README.md"
+dependencies = [
+    "sqlmodel",
+]
 optional-dependencies = {}
-
-# [tool.tiangolo._internal-slim-build.packages.sqlmodel.project.scripts]
-# sqlmodel = "sqlmodel.cli:main"
+scripts = {}
+
+[tool.tiangolo._internal-slim-build.packages.sqlmodel-slim.tool.pdm.build]
+# excludes needs to explicitly exclude the top level python packages,
+# otherwise PDM includes them by default
+# A "*" glob pattern can't be used here because in PDM internals, the patterns are put
+# in a set (unordered, order varies) and each excluded file is assigned one of the
+# glob patterns that matches, as the set is unordered, the matched pattern could be "*"
+# independent of the order here. And then the internal code would give it a lower score
+# than the one for a default included file.
+# By not using "*" and explicitly excluding the top level packages, they get a higher
+# score than the default inclusion
+excludes = ["sqlmodel", "tests", "pdm_build.py"]
+# source-includes needs to explicitly define some value because PDM will check the
+# truthy value of the list, and if empty, will include some defaults, including "tests",
+# an empty string doesn't match anything, but makes the list truthy, so that PDM
+# doesn't override it during the build.
+source-includes = [""]
 
 [tool.coverage.run]
 parallel = true
diff --git a/sqlmodel-slim/README.md b/sqlmodel-slim/README.md
new file mode 100644 (file)
index 0000000..bc4b07b
--- /dev/null
@@ -0,0 +1,52 @@
+<p align="center">
+  <a href="https://sqlmodel.tiangolo.com"><img src="https://sqlmodel.tiangolo.com/img/logo-margin/logo-margin-vector.svg#only-light" alt="SQLModel"></a>
+
+</p>
+<p align="center">
+    <em>SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.</em>
+</p>
+<p align="center">
+<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
+    <img src="https://github.com/fastapi/sqlmodel/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Test">
+</a>
+<a href="https://github.com/fastapi/sqlmodel/actions?query=workflow%3APublish" target="_blank">
+    <img src="https://github.com/fastapi/sqlmodel/actions/workflows/publish.yml/badge.svg" alt="Publish">
+</a>
+<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/sqlmodel" target="_blank">
+    <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/sqlmodel.svg" alt="Coverage">
+<a href="https://pypi.org/project/sqlmodel" target="_blank">
+    <img src="https://img.shields.io/pypi/v/sqlmodel?color=%2334D058&label=pypi%20package" alt="Package version">
+</a>
+</p>
+
+---
+
+**Documentation**: <a href="https://sqlmodel.tiangolo.com" target="_blank">https://sqlmodel.tiangolo.com</a>
+
+**Source Code**: <a href="https://github.com/fastapi/sqlmodel" target="_blank">https://github.com/fastapi/sqlmodel</a>
+
+---
+
+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.
+
+**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>.
+
+## `sqlmodel-slim`
+
+⚠️ Do not install this package. ⚠️
+
+This package, `sqlmodel-slim`, does nothing other than depend on `sqlmodel`.
+
+You **should not** install this package.
+
+Install instead:
+
+```bash
+pip install sqlmodel
+```
+
+This package is deprecated and will stop receiving any updates and published versions.
+
+## License
+
+This project is licensed under the terms of the MIT license.