-
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix broken installation when upgrading from
typer <0.12.0
to `typ…
…er >=0.12.0`, make `typer` independent of `typer-slim`, include `typer` command in `typer` package (#791)
- Loading branch information
Showing
13 changed files
with
128 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,6 @@ jobs: | |
- typer-slim | ||
- typer | ||
- typer-cli | ||
env: | ||
dir: ${{ matrix.package == 'typer-slim' && './' || matrix.package == 'typer' && 'typer_package' || matrix.package == 'typer-cli' && 'typer_cli_package' }} | ||
permissions: | ||
id-token: write | ||
steps: | ||
|
@@ -34,9 +32,8 @@ jobs: | |
- name: Install build dependencies | ||
run: pip install build | ||
- name: Build distribution | ||
working-directory: ${{ env.dir }} | ||
env: | ||
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }} | ||
run: python -m build | ||
- name: Publish | ||
uses: pypa/[email protected] | ||
with: | ||
packages-dir: ${{ env.dir }}/dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import os | ||
from typing import Any, Dict, List | ||
|
||
from pdm.backend.hooks import Context | ||
|
||
TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "typer") | ||
|
||
|
||
def pdm_build_initialize(context: Context): | ||
metadata = context.config.metadata | ||
# Get main version | ||
version = metadata["version"] | ||
# Get package names to keep in sync with the same main version | ||
sync_dependencies: List[str] = context.config.data["tool"]["tiangolo"][ | ||
"_internal-slim-build" | ||
]["sync-dependencies"] | ||
# Get custom config for the current package, from the env var | ||
config: Dict[str, Any] = context.config.data["tool"]["tiangolo"][ | ||
"_internal-slim-build" | ||
]["packages"][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 | ||
# 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", []) | ||
# 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: | ||
if dep in sync_dependencies: | ||
new_dep = f"{dep}=={version}" | ||
new_dependencies.append(new_dep) | ||
else: | ||
new_dependencies.append(dep) | ||
if new_dependencies != dependencies: | ||
metadata["dependencies"] = new_dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,12 @@ requires = ["pdm-backend"] | |
build-backend = "pdm.backend" | ||
|
||
[project] | ||
# pip install typer-slim: is only the Typer library, without extras | ||
# pip install typer: is typer-slim[standard], with extras and typer-cli | ||
name = "typer-slim" | ||
name = "typer" | ||
dynamic = ["version"] | ||
description = "Typer, build great CLIs. Easy to code. Based on Python type hints." | ||
authors = [ | ||
{name = "Sebastián Ramírez", email = "[email protected]"}, | ||
] | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
classifiers = [ | ||
"Intended Audience :: Information Technology", | ||
|
@@ -38,16 +35,12 @@ dependencies = [ | |
"click >= 8.0.0", | ||
"typing-extensions >= 3.7.4.3", | ||
] | ||
|
||
readme = "README.md" | ||
[project.urls] | ||
Documentation = "https://typer.tiangolo.com/" | ||
homepage = "https://github.com/tiangolo/typer" | ||
|
||
[project.optional-dependencies] | ||
all = [ | ||
"shellingham >=1.3.0", | ||
"rich >=10.11.0", | ||
] | ||
standard = [ | ||
"shellingham >=1.3.0", | ||
"rich >=10.11.0", | ||
|
@@ -65,6 +58,50 @@ source-includes = [ | |
"scripts/", | ||
] | ||
|
||
[tool.tiangolo._internal-slim-build] | ||
sync-dependencies = [ | ||
"typer-slim[standard]", | ||
"typer-cli", | ||
"typer" | ||
] | ||
|
||
[tool.tiangolo._internal-slim-build.packages.typer-slim.project] | ||
name = "typer-slim" | ||
|
||
[tool.tiangolo._internal-slim-build.packages.typer] | ||
include-optional-dependencies = ["standard"] | ||
|
||
[tool.tiangolo._internal-slim-build.packages.typer.project] | ||
optional-dependencies = {} | ||
|
||
[tool.tiangolo._internal-slim-build.packages.typer.project.scripts] | ||
typer = "typer.cli:main" | ||
|
||
[tool.tiangolo._internal-slim-build.packages.typer-cli.project] | ||
name = "typer-cli" | ||
readme = "typer-cli/README.md" | ||
dependencies = [ | ||
"typer", | ||
] | ||
optional-dependencies = {} | ||
|
||
[tool.tiangolo._internal-slim-build.packages.typer-cli.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 = ["typer", "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.isort] | ||
profile = "black" | ||
known_third_party = ["typer", "click"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.