From 252b74865bd6a7230f964f16002bc4c99b583f2330155ebdcd794605e6103e1d Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 2 Feb 2022 20:06:04 +0000 Subject: [PATCH 1/4] - Fix failing tests: - typing_extensions.patch (post Python 3.8 we don't need typing_extensions package at all) - syntaxerror_failing_test.patch (This is actually fixed in the post-0.22.1 development, but waiting on it.) OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bpython?expand=0&rev=20 --- python-bpython.changes | 9 +++ python-bpython.spec | 24 ++++-- syntaxerror_failing_test.patch | 19 +++++ typing_extensions.patch | 131 +++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 8 deletions(-) create mode 100644 syntaxerror_failing_test.patch create mode 100644 typing_extensions.patch diff --git a/python-bpython.changes b/python-bpython.changes index ae1a929..4fd05d3 100644 --- a/python-bpython.changes +++ b/python-bpython.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Wed Feb 2 20:04:24 UTC 2022 - Matej Cepl + +- Fix failing tests: + - typing_extensions.patch (post Python 3.8 we don't need + typing_extensions package at all) + - syntaxerror_failing_test.patch (This is actually fixed in the + post-0.22.1 development, but waiting on it.) + ------------------------------------------------------------------- Sun Jan 23 17:31:17 UTC 2022 - Arun Persaud diff --git a/python-bpython.spec b/python-bpython.spec index d2c35c5..8bcb93c 100644 --- a/python-bpython.spec +++ b/python-bpython.spec @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 -%bcond_with test +%bcond_without test Name: python-bpython Version: 0.22.1 Release: 0 @@ -26,9 +26,17 @@ Summary: Fancy Interface to the Python Interpreter License: MIT URL: https://www.bpython-interpreter.org/ Source: https://files.pythonhosted.org/packages/source/b/bpython/bpython-%{version}.tar.gz +# PATCH-FIX-UPSTREAM typing_extensions.patch gh#bpython/bpython#940 mcepl@suse.com +# We actually don't need typing_extensions (all objects are in 3.8+) +Patch0: typing_extensions.patch +# PATCH-FIX-UPSTREAM syntaxerror_failing_test.patch gh#bpython/bpython#952 mcepl@suse.com +# This is actually fixed in the post-0.22.1 development, but waiting on it. +Patch1: syntaxerror_failing_test.patch BuildRequires: %{python_module Babel} BuildRequires: %{python_module Sphinx} +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: hicolor-icon-theme BuildRequires: python-rpm-macros @@ -54,10 +62,10 @@ BuildArch: noarch BuildRequires: %{python_module curtsies >= 0.3.5} BuildRequires: %{python_module greenlet} BuildRequires: %{python_module pygments} +BuildRequires: %{python_module pyxdg} BuildRequires: %{python_module requests} BuildRequires: %{python_module six >= 1.5} BuildRequires: %{python_module wcwidth} -BuildRequires: python-mock %endif %ifpython2 Provides: bpython = %{version} @@ -90,14 +98,14 @@ Provides: %{python_module bpython-doc = %{version}} Documentation and help files for %{name}. %prep -%setup -q -n bpython-%{version} +%autosetup -p1 -n bpython-%{version} %build -%python_build +%pyproject_wheel %python_exec setup.py build_sphinx && rm build/sphinx/html/.buildinfo # HTML documentation %install -%python_install +%pyproject_install install -m 644 build/man/bpython.1 %{buildroot}%{_mandir}/man1/bpython.1 install -m 644 build/man/bpython-config.5 %{buildroot}%{_mandir}/man5/bpython-config.5 @@ -134,7 +142,7 @@ rm %{buildroot}%{_datadir}/applications/org.bpython-interpreter.bpython.desktop %if %{with test} %check -%python_exec setup.py test +%pyunittest discover -v %endif %post @@ -150,8 +158,8 @@ rm %{buildroot}%{_datadir}/applications/org.bpython-interpreter.bpython.desktop %{python_sitelib}/bpython/* %dir %{python_sitelib}/bpdb %{python_sitelib}/bpdb/* -%dir %{python_sitelib}/bpython-%{version}-py*.egg-info -%{python_sitelib}/bpython-%{version}-py*.egg-info/* +%dir %{python_sitelib}/bpython-%{version}-*-info +%{python_sitelib}/bpython-%{version}-*-info/* %python_alternative %{_bindir}/bpython %python_alternative %{_bindir}/bpython-curses %python_alternative %{_bindir}/bpython-urwid diff --git a/syntaxerror_failing_test.patch b/syntaxerror_failing_test.patch new file mode 100644 index 0000000..5e96e08 --- /dev/null +++ b/syntaxerror_failing_test.patch @@ -0,0 +1,19 @@ +--- + bpython/test/test_interpreter.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/bpython/test/test_interpreter.py ++++ b/bpython/test/test_interpreter.py +@@ -41,10 +41,10 @@ class TestInterpreter(unittest.TestCase) + + green('""') + + ", line " + + bold(magenta("1")) +- + "\n 1.1.1.1\n ^^^^^\n" ++ + "\n 1.1.1.1\n ^^\n" + + bold(red("SyntaxError")) + + ": " +- + cyan("invalid syntax. Perhaps you forgot a comma?") ++ + cyan("invalid syntax") + + "\n" + ) + elif (3, 8) <= sys.version_info[:2] <= (3, 9): diff --git a/typing_extensions.patch b/typing_extensions.patch new file mode 100644 index 0000000..647aae3 --- /dev/null +++ b/typing_extensions.patch @@ -0,0 +1,131 @@ +From 51ebc86070c7a49abe78ba87a0e8268a09f141a6 Mon Sep 17 00:00:00 2001 +From: Sebastian Ramacher +Date: Wed, 8 Dec 2021 18:18:17 +0100 +Subject: [PATCH] Add a typing compat module to avoid a dependency on + typing-extensions for Py >= 3.8 + +--- + bpython/_typing_compat.py | 33 +++++++++++++++++++++++++++++++++ + bpython/curtsies.py | 2 +- + bpython/curtsiesfrontend/_internal.py | 2 +- + bpython/curtsiesfrontend/repl.py | 2 +- + bpython/filelock.py | 2 +- + bpython/inspection.py | 2 +- + bpython/repl.py | 2 +- + setup.cfg | 2 +- + 8 files changed, 40 insertions(+), 7 deletions(-) + create mode 100644 bpython/_typing_compat.py + +--- /dev/null ++++ b/bpython/_typing_compat.py +@@ -0,0 +1,33 @@ ++# The MIT License ++# ++# Copyright (c) 2021 Sebastian Ramacher ++# ++# Permission is hereby granted, free of charge, to any person obtaining a copy ++# of this software and associated documentation files (the "Software"), to deal ++# in the Software without restriction, including without limitation the rights ++# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++# copies of the Software, and to permit persons to whom the Software is ++# furnished to do so, subject to the following conditions: ++# ++# The above copyright notice and this permission notice shall be included in ++# all copies or substantial portions of the Software. ++# ++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ++# THE SOFTWARE. ++ ++try: ++ # introduced in Python 3.8 ++ from typing import Literal ++except ImportError: ++ from typing_extensions import Literal # type: ignore ++ ++try: ++ # introduced in Python 3.8 ++ from typing import Protocol ++except ImportError: ++ from typing_extensions import Protocol # type: ignore +--- a/bpython/curtsies.py ++++ b/bpython/curtsies.py +@@ -33,7 +33,7 @@ from typing import ( + Optional, + Generator, + ) +-from typing_extensions import Literal, Protocol ++from ._typing_compat import Protocol + + logger = logging.getLogger(__name__) + +--- a/bpython/curtsiesfrontend/_internal.py ++++ b/bpython/curtsiesfrontend/_internal.py +@@ -23,7 +23,7 @@ + import pydoc + from types import TracebackType + from typing import Optional, Type +-from typing_extensions import Literal ++from .._typing_compat import Literal + + from .. import _internal + +--- a/bpython/curtsiesfrontend/repl.py ++++ b/bpython/curtsiesfrontend/repl.py +@@ -14,7 +14,7 @@ import unicodedata + from enum import Enum + from types import TracebackType + from typing import Dict, Any, List, Optional, Tuple, Union, cast, Type +-from typing_extensions import Literal ++from .._typing_compat import Literal + + import blessings + import greenlet +--- a/bpython/filelock.py ++++ b/bpython/filelock.py +@@ -21,7 +21,7 @@ + # THE SOFTWARE. + + from typing import Optional, Type, IO +-from typing_extensions import Literal ++from ._typing_compat import Literal + from types import TracebackType + + has_fcntl = True +--- a/bpython/inspection.py ++++ b/bpython/inspection.py +@@ -28,7 +28,7 @@ import re + from collections import namedtuple + from typing import Any, Optional, Type + from types import MemberDescriptorType, TracebackType +-from typing_extensions import Literal ++from ._typing_compat import Literal + + from pygments.token import Token + from pygments.lexers import Python3Lexer +--- a/bpython/repl.py ++++ b/bpython/repl.py +@@ -38,7 +38,7 @@ from itertools import takewhile + from pathlib import Path + from types import ModuleType, TracebackType + from typing import cast, Tuple, Any, Optional, Type +-from typing_extensions import Literal ++from ._typing_compat import Literal + + from pygments.lexers import Python3Lexer + from pygments.token import Token +--- a/setup.cfg ++++ b/setup.cfg +@@ -28,7 +28,7 @@ install_requires = + pygments + pyxdg + requests +- typing-extensions ++ typing-extensions; python_version < "3.8" + + [options.extras_require] + clipboard = pyperclip From bee9ade68ef5952bac0cc91570a943fece6cc3156915ae8fb25f72590c6c33a1 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 2 Feb 2022 20:10:23 +0000 Subject: [PATCH 2/4] Fix dist-info file names in files. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bpython?expand=0&rev=21 --- python-bpython.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-bpython.spec b/python-bpython.spec index 8bcb93c..60fc1dd 100644 --- a/python-bpython.spec +++ b/python-bpython.spec @@ -158,8 +158,8 @@ rm %{buildroot}%{_datadir}/applications/org.bpython-interpreter.bpython.desktop %{python_sitelib}/bpython/* %dir %{python_sitelib}/bpdb %{python_sitelib}/bpdb/* -%dir %{python_sitelib}/bpython-%{version}-*-info -%{python_sitelib}/bpython-%{version}-*-info/* +%dir %{python_sitelib}/bpython-%{version}*-info +%{python_sitelib}/bpython-%{version}*-info/* %python_alternative %{_bindir}/bpython %python_alternative %{_bindir}/bpython-curses %python_alternative %{_bindir}/bpython-urwid From 5104e34cdfcfdbc6dff448f1df43d47261bded29893a5f86ac86e5ff017be926 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 2 Feb 2022 22:02:33 +0000 Subject: [PATCH 3/4] - syntaxerror_failing_test.patch (from https://github.com/bpython/bpython/compare/fdd4ad9..4d33cc6). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bpython?expand=0&rev=22 --- python-bpython.changes | 4 +- python-bpython.spec | 1 + syntaxerror_failing_test.patch | 74 +++++++++++++++++++++++++++------- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/python-bpython.changes b/python-bpython.changes index 4fd05d3..17bf6b8 100644 --- a/python-bpython.changes +++ b/python-bpython.changes @@ -4,8 +4,8 @@ Wed Feb 2 20:04:24 UTC 2022 - Matej Cepl - Fix failing tests: - typing_extensions.patch (post Python 3.8 we don't need typing_extensions package at all) - - syntaxerror_failing_test.patch (This is actually fixed in the - post-0.22.1 development, but waiting on it.) + - syntaxerror_failing_test.patch (from + https://github.com/bpython/bpython/compare/fdd4ad9..4d33cc6). ------------------------------------------------------------------- Sun Jan 23 17:31:17 UTC 2022 - Arun Persaud diff --git a/python-bpython.spec b/python-bpython.spec index 60fc1dd..856d1b9 100644 --- a/python-bpython.spec +++ b/python-bpython.spec @@ -31,6 +31,7 @@ Source: https://files.pythonhosted.org/packages/source/b/bpython/bpython Patch0: typing_extensions.patch # PATCH-FIX-UPSTREAM syntaxerror_failing_test.patch gh#bpython/bpython#952 mcepl@suse.com # This is actually fixed in the post-0.22.1 development, but waiting on it. +# https://github.com/bpython/bpython/compare/fdd4ad9..4d33cc6.patch Patch1: syntaxerror_failing_test.patch BuildRequires: %{python_module Babel} BuildRequires: %{python_module Sphinx} diff --git a/syntaxerror_failing_test.patch b/syntaxerror_failing_test.patch index 5e96e08..00585d6 100644 --- a/syntaxerror_failing_test.patch +++ b/syntaxerror_failing_test.patch @@ -1,19 +1,65 @@ ---- - bpython/test/test_interpreter.py | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) +From b46afa3bb1ab783c96dc80c5184090a171ab70d4 Mon Sep 17 00:00:00 2001 +From: Sebastian Ramacher +Date: Fri, 31 Dec 2021 14:00:46 +0100 +Subject: [PATCH 1/3] Apply black +--- + bpython/autocomplete.py | 1 - + bpython/curtsiesfrontend/filewatch.py | 1 - + bpython/test/test_interpreter.py | 14 +++++++++++++- + bpython/urwid.py | 1 - + 4 files changed, 13 insertions(+), 4 deletions(-) + +--- a/bpython/autocomplete.py ++++ b/bpython/autocomplete.py +@@ -626,7 +626,6 @@ except ImportError: + def locate(self, cursor_offset: int, line: str) -> Optional[LinePart]: + return None + +- + else: + + class JediCompletion(BaseCompletionType): +--- a/bpython/curtsiesfrontend/filewatch.py ++++ b/bpython/curtsiesfrontend/filewatch.py +@@ -11,7 +11,6 @@ except ImportError: + def ModuleChangedEventHandler(*args): + return None + +- + else: + + class ModuleChangedEventHandler(FileSystemEventHandler): # type: ignore [no-redef] --- a/bpython/test/test_interpreter.py +++ b/bpython/test/test_interpreter.py -@@ -41,10 +41,10 @@ class TestInterpreter(unittest.TestCase) - + green('""') - + ", line " - + bold(magenta("1")) -- + "\n 1.1.1.1\n ^^^^^\n" +@@ -35,7 +35,19 @@ class TestInterpreter(unittest.TestCase) + + i.runsource("1.1.1.1") + +- if sys.version_info[:2] >= (3, 10): ++ if (3, 10, 1) <= sys.version_info[:3]: ++ expected = ( ++ " File " ++ + green('""') ++ + ", line " ++ + bold(magenta("1")) + + "\n 1.1.1.1\n ^^\n" - + bold(red("SyntaxError")) - + ": " -- + cyan("invalid syntax. Perhaps you forgot a comma?") ++ + bold(red("SyntaxError")) ++ + ": " + + cyan("invalid syntax") - + "\n" - ) - elif (3, 8) <= sys.version_info[:2] <= (3, 9): ++ + "\n" ++ ) ++ elif (3, 10) <= sys.version_info[:2]: + expected = ( + " File " + + green('""') +--- a/bpython/urwid.py ++++ b/bpython/urwid.py +@@ -128,7 +128,6 @@ if urwid.VERSION < (1, 0, 0) and hasattr + + return wrapper + +- + else: + TwistedEventLoop = getattr(urwid, "TwistedEventLoop", None) + From 28de2a93fb14f2fc761c77894318dcff2fcd03b50c7a4840baaff66935d6ecd4 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sat, 5 Feb 2022 22:15:48 +0000 Subject: [PATCH 4/4] - This version actually installs manpages on its own. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bpython?expand=0&rev=23 --- python-bpython.changes | 5 +++++ python-bpython.spec | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python-bpython.changes b/python-bpython.changes index 17bf6b8..39a1007 100644 --- a/python-bpython.changes +++ b/python-bpython.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sat Feb 5 21:57:02 UTC 2022 - Matej Cepl + +- This version actually installs manpages on its own. + ------------------------------------------------------------------- Wed Feb 2 20:04:24 UTC 2022 - Matej Cepl diff --git a/python-bpython.spec b/python-bpython.spec index 856d1b9..375f3b9 100644 --- a/python-bpython.spec +++ b/python-bpython.spec @@ -108,9 +108,6 @@ Documentation and help files for %{name}. %install %pyproject_install -install -m 644 build/man/bpython.1 %{buildroot}%{_mandir}/man1/bpython.1 -install -m 644 build/man/bpython-config.5 %{buildroot}%{_mandir}/man5/bpython-config.5 - %python_clone -a %{buildroot}%{_bindir}/bpython %python_clone -a %{buildroot}%{_bindir}/bpython-curses %python_clone -a %{buildroot}%{_bindir}/bpython-urwid @@ -118,9 +115,6 @@ install -m 644 build/man/bpython-config.5 %{buildroot}%{_mandir}/man5/bpython-co %python_clone -a %{buildroot}%{_mandir}/man1/bpython.1 %python_clone -a %{buildroot}%{_mandir}/man5/bpython-config.5 -install -d %{buildroot}%{_mandir}/man1/ -install -d %{buildroot}%{_mandir}/man5/ - %{python_expand %fdupes %{buildroot}%{$python_sitelib} cp %{buildroot}%{_datadir}/metainfo/org.bpython-interpreter.bpython.metainfo.xml %{buildroot}%{_datadir}/metainfo/org.bpython-interpreter.bpython-%{$python_bin_suffix}.metainfo.xml