15
0
forked from pool/python-typer

Accepting request 984951 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/984951
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-typer?expand=0&rev=4
This commit is contained in:
2022-06-25 08:24:40 +00:00
committed by Git OBS Bridge
7 changed files with 2934 additions and 10 deletions

View File

@@ -1,2 +0,0 @@
# Marker file required for conformity with PEP-561
addFilter("zero-length /usr/lib/python3.6/site-packages/typer/py.typed")

View File

@@ -1,3 +1,20 @@
-------------------------------------------------------------------
Fri Jun 24 18:20:30 UTC 2022 - Matthias Bach <marix@marix.org> - 0.4.1
- Add run-subprocesses-with-correct-python.patch to ensure tests
aren't accidentally running subprocesses using the wrong Python
version.
- Add set-proper-pythonpath-for-tutorial-script-tests.patch to fix
issue with build failing due to import failures.
-------------------------------------------------------------------
Tue Jun 14 14:37:26 UTC 2022 - Matthias Bach <marix@marix.org> - 0.4.1
- Update to upstream version 0.4.1
* Fix import of get_terminal_size for Click 8.1.0 support.
- Switch from traditional setup.py installation to pyproject macros
as upstream no longer ships its setup.py compability wrapper.
-------------------------------------------------------------------
Mon Aug 30 19:31:17 UTC 2021 - Matthias Bach <marix@marix.org> - 0.4.0

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-typer
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2021 Matthias Bach <marix@marix.org>
#
# All modifications and additions to the file contributed by third parties
@@ -19,17 +19,19 @@
%define skip_python2 1
Name: python-typer
Version: 0.4.0
Version: 0.4.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
Source1: %{name}-rpmlintrc
Patch0: run-subprocesses-with-correct-python.patch
Patch1: set-proper-pythonpath-for-tutorial-script-tests.patch
BuildRequires: %{python_module click}
BuildRequires: %{python_module coverage}
BuildRequires: %{python_module flit-core}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module shellingham}
BuildRequires: fdupes
@@ -50,12 +52,13 @@ This package provides the Typer Python package required to build and run Typer-b
%prep
%setup -q -n typer-%{version}
%autopatch -p1
%build
%python_build
%pyproject_wheel
%install
%python_install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,120 @@
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 | 5 +++++
tests/test_tutorial/test_subcommands/test_tutorial003.py | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/tests/test_tutorial/test_subcommands/test_tutorial001.py b/tests/test_tutorial/test_subcommands/test_tutorial001.py
index 1b8b60e..392cf24 100644
--- a/tests/test_tutorial/test_subcommands/test_tutorial001.py
+++ b/tests/test_tutorial/test_subcommands/test_tutorial001.py
@@ -1,3 +1,4 @@
+import os
import subprocess
import sys
@@ -85,11 +86,15 @@ def test_users_delete(app):
def test_scripts(mod):
from docs_src.subcommands.tutorial001 import items, users
+ env = os.environ.copy()
+ env["PYTHONPATH"] = ":".join(list(tutorial001.__path__))
+
for module in [mod, items, users]:
result = subprocess.run(
[sys.executable, "-m", "coverage", "run", module.__file__, "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
+ env=env,
)
assert "Usage" in result.stdout
diff --git a/tests/test_tutorial/test_subcommands/test_tutorial003.py b/tests/test_tutorial/test_subcommands/test_tutorial003.py
index 57f1174..7de9107 100644
--- a/tests/test_tutorial/test_subcommands/test_tutorial003.py
+++ b/tests/test_tutorial/test_subcommands/test_tutorial003.py
@@ -1,3 +1,4 @@
+import os
import subprocess
import sys
@@ -137,11 +138,15 @@ def test_lands_towns_burn(app):
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__))
+
for module in [mod, items, lands, reigns, towns, users]:
result = subprocess.run(
[sys.executable, "-m", "coverage", "run", module.__file__, "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
+ env=env,
)
assert "Usage" in result.stdout
--
2.35.3

View File

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

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

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