Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/workflows/test-redistribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ on:
jobs:
test-redistribute:
runs-on: ubuntu-latest
strategy:
matrix:
package:
- fastapi-cli-slim
- fastapi-cli
steps:
- name: Dump GitHub context
env:
Expand All @@ -33,8 +28,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: |
Expand All @@ -44,8 +37,6 @@ jobs:
run: |
cd dist/fastapi_cli*/
pip install --group tests --editable .[standard]
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
- name: Run source distribution tests
run: |
cd dist/fastapi_cli*/
Expand Down
47 changes: 47 additions & 0 deletions fastapi-cli-slim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# FastAPI CLI

<a href="https://github.com/fastapi/fastapi-cli/actions/workflows/test.yml" target="_blank">
<img src="https://github.com/fastapi/fastapi-cli/actions/workflows/test.yml/badge.svg" alt="Test">
</a>
<a href="https://github.com/fastapi/fastapi-cli/actions/workflows/publish.yml" target="_blank">
<img src="https://github.com/fastapi/fastapi-cli/actions/workflows/publish.yml/badge.svg" alt="Publish">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/fastapi-cli" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/fastapi-cli.svg" alt="Coverage">
<a href="https://pypi.org/project/fastapi-cli" target="_blank">
<img src="https://img.shields.io/pypi/v/fastapi-cli?color=%2334D058&label=pypi%20package" alt="Package version">
</a>

---

**Source Code**: <a href="https://github.com/fastapi/fastapi-cli" target="_blank">https://github.com/fastapi/fastapi-cli</a>

---

Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀

## `fastapi-cli-slim`

⚠️ Do not install this package. ⚠️

This package, `fastapi-cli-slim`, does nothing other than depend on `fastapi-cli`.

You **should not** install this package.

Install instead:

```bash
pip install "fastapi[standard]"
```

or:

```bash
pip install fastapi-cli
```

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.
30 changes: 25 additions & 5 deletions pdm_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,38 @@

from pdm.backend.hooks import Context

TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "fastapi-cli")
TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE")


def pdm_build_initialize(context: Context):
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"].get(TIANGOLO_BUILD_PACKAGE)
if not config:
]["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"]
# Override main [project] configs with custom configs for this package
for key, value in project_config.items():
metadata[key] = value
# Get custom build config for the current package
build_config: dict[str, Any] = (
config.get("tool", {}).get("pdm", {}).get("build", {})
)
# Override PDM build config with custom build config for this package
for key, value in build_config.items():
context.config.build_config[key] = value
# Get main dependencies
dependencies: list[str] = metadata.get("dependencies", [])
# Sync versions in dependencies
new_dependencies = []
for dep in dependencies:
new_dep = f"{dep}>={version}"
new_dependencies.append(new_dep)
metadata["dependencies"] = new_dependencies
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ source-includes = [

[tool.tiangolo._internal-slim-build.packages.fastapi-cli-slim.project]
name = "fastapi-cli-slim"
readme = "fastapi-cli-slim/README.md"
dependencies = [
"fastapi-cli",
]
optional-dependencies = {}
scripts = {}

[tool.tiangolo._internal-slim-build.packages.fastapi-cli-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 = ["src", "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.pytest.ini_options]
addopts = [
Expand Down