python3Packages.typer: use mkPythonMetaPackage (#466482)

This commit is contained in:
dotlambda
2025-11-30 23:23:16 +00:00
committed by GitHub
3 changed files with 104 additions and 91 deletions

View File

@@ -0,0 +1,90 @@
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
# build-system
pdm-backend,
# dependencies
click,
typing-extensions,
# optional-dependencies
rich,
shellingham,
# tests
pytest-xdist,
pytestCheckHook,
writableTmpDirAsHomeHook,
procps,
}:
buildPythonPackage rec {
pname = "typer-slim";
version = "0.19.2";
pyproject = true;
src = fetchFromGitHub {
owner = "fastapi";
repo = "typer";
tag = version;
hash = "sha256-mMsOEI4FpLkLkpjxjnUdmKdWD65Zx3Z1+L+XsS79k44=";
};
postPatch = ''
for f in $(find tests -type f -print); do
# replace `sys.executable -m coverage run` with `sys.executable`
sed -z -i 's/"-m",\n\?\s*"coverage",\n\?\s*"run",//g' "$f"
done
'';
env.TIANGOLO_BUILD_PACKAGE = "typer-slim";
build-system = [ pdm-backend ];
dependencies = [
click
typing-extensions
];
optional-dependencies = {
standard = [
rich
shellingham
];
};
nativeCheckInputs = [
pytest-xdist
pytestCheckHook
writableTmpDirAsHomeHook
]
++ lib.concatAttrValues optional-dependencies
++ lib.optionals stdenv.hostPlatform.isDarwin [
procps
];
disabledTests = [
"test_scripts"
# Likely related to https://github.com/sarugaku/shellingham/issues/35
# fails also on Linux
"test_show_completion"
"test_install_completion"
]
++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
"test_install_completion"
];
pythonImportsCheck = [ "typer" ];
meta = {
description = "Library for building CLI applications";
homepage = "https://typer.tiangolo.com/";
changelog = "https://github.com/tiangolo/typer/releases/tag/${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ winpat ];
};
}

View File

@@ -1,97 +1,20 @@
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
# build-system
pdm-backend,
# dependencies
click,
typing-extensions,
# optional-dependencies
rich,
shellingham,
# tests
pytest-xdist,
pytestCheckHook,
writableTmpDirAsHomeHook,
procps,
# typer or typer-slim
package ? "typer",
mkPythonMetaPackage,
typer-slim,
}:
buildPythonPackage rec {
pname = package;
version = "0.19.2";
pyproject = true;
src = fetchFromGitHub {
owner = "fastapi";
repo = "typer";
tag = version;
hash = "sha256-mMsOEI4FpLkLkpjxjnUdmKdWD65Zx3Z1+L+XsS79k44=";
};
postPatch = ''
for f in $(find tests -type f -print); do
# replace `sys.executable -m coverage run` with `sys.executable`
sed -z -i 's/"-m",\n\?\s*"coverage",\n\?\s*"run",//g' "$f"
done
'';
env.TIANGOLO_BUILD_PACKAGE = package;
build-system = [ pdm-backend ];
dependencies = [
click
typing-extensions
]
# typer includes the standard optional by default
# https://github.com/tiangolo/typer/blob/0.12.3/pyproject.toml#L71-L72
++ lib.optionals (package == "typer") optional-dependencies.standard;
optional-dependencies = {
standard = [
rich
shellingham
];
};
doCheck = package == "typer"; # tests expect standard dependencies
nativeCheckInputs = [
pytest-xdist
pytestCheckHook
writableTmpDirAsHomeHook
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
procps
];
disabledTests = [
"test_scripts"
# Likely related to https://github.com/sarugaku/shellingham/issues/35
# fails also on Linux
"test_show_completion"
"test_install_completion"
]
++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
"test_install_completion"
];
pythonImportsCheck = [ "typer" ];
mkPythonMetaPackage {
pname = "typer";
inherit (typer-slim) version optional-dependencies;
dependencies = [ typer-slim ] ++ typer-slim.optional-dependencies.standard;
meta = {
description = "Library for building CLI applications";
homepage = "https://typer.tiangolo.com/";
changelog = "https://github.com/tiangolo/typer/releases/tag/${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ winpat ];
inherit (typer-slim.meta)
changelog
description
homepage
license
maintainers
;
};
}

View File

@@ -19257,7 +19257,7 @@ self: super: with self; {
typer-shell = callPackage ../development/python-modules/typer-shell { };
typer-slim = self.typer.override { package = "typer-slim"; };
typer-slim = callPackage ../development/python-modules/typer-slim { };
types-aiobotocore = callPackage ../development/python-modules/types-aiobotocore { };