14
0
forked from pool/python-typer

Accepting request 1165971 from home:theMarix:branches:devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/1165971
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-typer?expand=0&rev=26
This commit is contained in:
Matthias Bach
2024-04-07 15:06:09 +00:00
committed by Git OBS Bridge
parent 413abde30d
commit f25673c78c
6 changed files with 53 additions and 117 deletions

5
python-typer-rpmlintrc Normal file
View File

@@ -0,0 +1,5 @@
# Upstream does not declare a dependency as it ships all files in both packages,
# which scarily works with pip unless you start uninstalling one of the two packages.
# We use files from python-typer-slim where they exist in both. Thus, we require
# the dependency although it is not there upstream.
addFilter("python\d+-typer.noarch: W: python-leftover-require python\d+-typer-slim")

View File

@@ -1,3 +1,17 @@
-------------------------------------------------------------------
Sat Apr 6 13:05:09 UTC 2024 - Matthias Bach <marix@marix.org> - 0.12.1
- Update to upstream version 0.12.1
* The core functionality has been extracted into
python-typer-slim.
* The typer command is now provided as part of the main typer
package.
* Formerly optional dependencies required for full
functionality are now automatically installed. If they are not
required, the slim package can be used.
- Drop set-proper-pythonpath-for-tutorial-script-tests.patch as it
is now applied in python-typer-slim.
-------------------------------------------------------------------
Fri Mar 29 09:29:31 UTC 2024 - Matthias Bach <marix@marix.org> - 0.11.1

View File

@@ -17,31 +17,31 @@
#
%define plainpython python
%{?sle15_python_module_pythons}
Name: python-typer
Version: 0.11.1
Version: 0.12.1
Release: 0
Summary: Typer, build great CLIs. Easy to code. Based on Python type hints
License: MIT
Group: Development/Languages/Python
URL: https://github.com/tiangolo/typer
Source: https://files.pythonhosted.org/packages/source/t/typer/typer-%{version}.tar.gz
Patch1: set-proper-pythonpath-for-tutorial-script-tests.patch
BuildRequires: %{python_module click}
BuildRequires: %{python_module coverage}
Source2: %{name}-rpmlintrc
BuildRequires: %{python_module pdm}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module rich}
BuildRequires: %{python_module shellingham}
BuildRequires: %{python_module typing_extensions}
BuildRequires: %{python_module typer-slim}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-click >= 8.0.0
Requires: python-typing_extensions >= 3.7.4.3
Recommends: python-colorama
Recommends: python-rich
Recommends: python-shellingham
# Work around Python dependency not being auto-added as there are no modules provided
Requires: %{plainpython}(abi) = %{python_version}
Requires: python-click
Requires: python-rich
Requires: python-shellingham
Requires: python-typer-slim >= %version
Requires: python-typing_extensions
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
%python_subpackages
@@ -51,7 +51,10 @@ Typer is a library for building CLI applications based on Python 3.6+ type hints
Based on type hints, Typer enables great editor support and completion for developers.
With automatic help and completion, Typer makes CLIs easy to use for users.
This package provides the Typer Python package required to build and run Typer-based CLI applications.
This package provides the Typer Python package and ensures all dependencies required
for full functionality are provided. In addition, it provides the command "typer"
which allows users to run scripts not using typer with the same command line comfort
as those that do.
%prep
%setup -q -n typer-%{version}
@@ -62,16 +65,27 @@ This package provides the Typer Python package required to build and run Typer-b
%install
%pyproject_install
# Remove files that were already installed by typer-slim
%python_expand rm -r %{buildroot}%{$python_sitelib}/typer
%python_clone -a %{buildroot}/%{_bindir}/typer
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# the completion tests fail as build runs in sh which is not supported
%pytest -k 'not test_show_completion and not test_install_completion'
# There are no tests in the python package as it only pulls dependencies
%post
%python_install_alternative typer
%postun
%python_uninstall_alternative typer
%files %{python_files}
%doc README.md
%license LICENSE
%{python_sitelib}/typer
%python_alternative %{_bindir}/typer
%{python_sitelib}/typer-%{version}*-info
%changelog

View File

@@ -1,97 +0,0 @@
From: Matthias Bach <marix@marix.org>
Date: Fri, 24 Jun 2022 19:54:06 +0200
Subject: [PATCH] Ensure the PYTHONPATH is set properly when testing the tutorial scripts
References: https://github.com/tiangolo/typer/pull/407
Upstream: sent
When packaging Typer for openSUSE I ran into errors because the tutorial
scripts were unable to import their colocated modules. Curiously this
only seems to be occurring when these scripts are run via coverage, as
they are in the tests. Them being run via coverage however also prevents
just changing the working directory for the script runs, as then the
coverage file would end up in the wrong directory.
Curiously, I have not been able to reproduce this issue on openSUSE Leap
but only seen it on openSUSE Tumbleweed. Thus, there might be something
weird with the Python stack or the coverage version on Tumbleweed.
However, as the same PYTHONPATH-patching is also done for the tests of
the tutorial code that run it directly and not as a subprocess, I think
it is just consistent to also do this for the script test.
For reference, this is the error that I am observing in the packaging
environment and that gets resolved by this commit:
[ 123s] =================================== FAILURES ===================================
[ 123s] _________________________________ test_scripts _________________________________
[ 123s]
[ 123s] mod = <module 'docs_src.subcommands.tutorial001.main' from '/home/abuild/rpmbuild/BUILD/typer-0.4.1/docs_src/subcommands/tutorial001/main.py'>
[ 123s]
[ 123s] def test_scripts(mod):
[ 123s] from docs_src.subcommands.tutorial001 import items, users
[ 123s]
[ 123s] for module in [mod, items, users]:
[ 123s] result = subprocess.run(
[ 123s] ["coverage", "run", module.__file__, "--help"],
[ 123s] stdout=subprocess.PIPE,
[ 123s] stderr=subprocess.PIPE,
[ 123s] encoding="utf-8",
[ 123s] )
[ 123s] > assert "Usage" in result.stdout
[ 123s] E assert 'Usage' in ''
[ 123s] E + where '' = CompletedProcess(args=['coverage', 'run', '/home/abuild/rpmbuild/BUILD/typer-0.4.1/docs_src/subcommands/tutorial001/main.py', '--help'], returncode=1, stdout='', stderr='Traceback (most recent call last):\n File "/home/abuild/rpmbuild/BUILD/typer-0.4.1/docs_src/subcommands/tutorial001/main.py", line 3, in <module>\n import items\nModuleNotFoundError: No module named \'items\'\n').stdout
[ 123s]
[ 123s] tests/test_tutorial/test_subcommands/test_tutorial001.py:94: AssertionError
[ 123s] _________________________________ test_scripts _________________________________
[ 123s]
[ 123s] mod = <module 'docs_src.subcommands.tutorial003.main' from '/home/abuild/rpmbuild/BUILD/typer-0.4.1/docs_src/subcommands/tutorial003/main.py'>
[ 123s]
[ 123s] def test_scripts(mod):
[ 123s] from docs_src.subcommands.tutorial003 import items, lands, reigns, towns, users
[ 123s]
[ 123s] for module in [mod, items, lands, reigns, towns, users]:
[ 123s] result = subprocess.run(
[ 123s] ["coverage", "run", module.__file__, "--help"],
[ 123s] stdout=subprocess.PIPE,
[ 123s] stderr=subprocess.PIPE,
[ 123s] encoding="utf-8",
[ 123s] )
[ 123s] > assert "Usage" in result.stdout
[ 123s] E assert 'Usage' in ''
[ 123s] E + where '' = CompletedProcess(args=['coverage', 'run', '/home/abuild/rpmbuild/BUILD/typer-0.4.1/docs_src/subcommands/tutorial003/main.py', '--help'], returncode=1, stdout='', stderr='Traceback (most recent call last):\n File "/home/abuild/rpmbuild/BUILD/typer-0.4.1/docs_src/subcommands/tutorial003/main.py", line 3, in <module>\n import items\nModuleNotFoundError: No module named \'items\'\n').stdout
[ 123s]
[ 123s] tests/test_tutorial/test_subcommands/test_tutorial003.py:146: AssertionError
---
tests/test_tutorial/test_subcommands/test_tutorial001.py | 2 +-
tests/test_tutorial/test_subcommands/test_tutorial003.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_tutorial/test_subcommands/test_tutorial001.py b/tests/test_tutorial/test_subcommands/test_tutorial001.py
index 1280e22..6f86826 100644
--- a/tests/test_tutorial/test_subcommands/test_tutorial001.py
+++ b/tests/test_tutorial/test_subcommands/test_tutorial001.py
@@ -87,7 +87,7 @@ def test_scripts(mod):
from docs_src.subcommands.tutorial001 import items, users
env = os.environ.copy()
- env["PYTHONPATH"] = ":".join(list(tutorial001.__path__))
+ env["PYTHONPATH"] = ":".join(list(tutorial001.__path__) + [env["PYTHONPATH"]] if "PYTHONPATH" in env else [])
for module in [mod, items, users]:
result = subprocess.run(
diff --git a/tests/test_tutorial/test_subcommands/test_tutorial003.py b/tests/test_tutorial/test_subcommands/test_tutorial003.py
index 2d6149c..0a05ae0 100644
--- a/tests/test_tutorial/test_subcommands/test_tutorial003.py
+++ b/tests/test_tutorial/test_subcommands/test_tutorial003.py
@@ -160,7 +160,7 @@ def test_scripts(mod):
from docs_src.subcommands.tutorial003 import items, lands, reigns, towns, users
env = os.environ.copy()
- env["PYTHONPATH"] = ":".join(list(tutorial003.__path__))
+ env["PYTHONPATH"] = ":".join(list(tutorial003.__path__) + [env["PYTHONPATH"]] if "PYTHONPATH" in env else [])
for module in [mod, items, lands, reigns, towns, users]:
result = subprocess.run(
--
2.35.3

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f5ae987b97ebbbd59182f8e84407bbc925bc636867fa007bce87a7a71ac81d5c
size 87143

3
typer-0.12.1.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:72d218ef3c686aed9c6ff3ca25b238aee0474a1628b29c559b18b634cfdeca88
size 93791