From 135cedf18159a2fb4d4560b6faef513c6453ac9ba1f310497f35918b6617dc37 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 29 Aug 2024 04:06:32 +0000 Subject: [PATCH] Accepting request 1196432 from home:pgajdos - drop python 2 support, do not require six - added patches fix https://github.com/rubik/mando/pull/57 + python-mando-no-python2.patch OBS-URL: https://build.opensuse.org/request/show/1196432 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-mando?expand=0&rev=17 --- python-mando-no-python2.patch | 310 ++++++++++++++++++++++++++++++++++ python-mando.changes | 8 + python-mando.spec | 11 +- 3 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 python-mando-no-python2.patch diff --git a/python-mando-no-python2.patch b/python-mando-no-python2.patch new file mode 100644 index 0000000..67cc9e6 --- /dev/null +++ b/python-mando-no-python2.patch @@ -0,0 +1,310 @@ +Index: mando-0.7.1/docs/conf.py +=================================================================== +--- mando-0.7.1.orig/docs/conf.py ++++ mando-0.7.1/docs/conf.py +@@ -46,8 +46,8 @@ source_suffix = '.rst' + master_doc = 'index' + + # General information about the project. +-project = u'mando' +-copyright = u'2013, Michele Lacchia' ++project = 'mando' ++copyright = '2013, Michele Lacchia' + + # The version info for the project you're documenting, acts as replacement for + # |version| and |release|, also used in various other places throughout the +@@ -199,8 +199,8 @@ latex_elements = { + # (source start file, target name, title, + # author, documentclass [howto, manual, or own class]). + latex_documents = [ +- ('index', 'mando.tex', u'mando Documentation', +- u'Michele Lacchia', 'manual'), ++ ('index', 'mando.tex', 'mando Documentation', ++ 'Michele Lacchia', 'manual'), + ] + + # The name of an image file (relative to this directory) to place at the top of +@@ -229,8 +229,8 @@ latex_documents = [ + # One entry per manual page. List of tuples + # (source start file, name, description, authors, manual section). + man_pages = [ +- ('index', 'mando', u'mando Documentation', +- [u'Michele Lacchia'], 1) ++ ('index', 'mando', 'mando Documentation', ++ ['Michele Lacchia'], 1) + ] + + # If true, show URL addresses after external links. +@@ -243,8 +243,8 @@ man_pages = [ + # (source start file, target name, title, author, + # dir menu entry, description, category) + texinfo_documents = [ +- ('index', 'mando', u'mando Documentation', +- u'Michele Lacchia', 'mando', 'One line description of project.', ++ ('index', 'mando', 'mando Documentation', ++ 'Michele Lacchia', 'mando', 'One line description of project.', + 'Miscellaneous'), + ] + +Index: mando-0.7.1/mando/__init__.py +=================================================================== +--- mando-0.7.1.orig/mando/__init__.py ++++ mando-0.7.1/mando/__init__.py +@@ -1,11 +1,6 @@ + __version__ = '0.7.1' + +-try: +- from mando.core import Program +-except ImportError as e: # pragma: no cover +- # unfortunately the only workaround for Python2.6, argparse and setup.py +- e.version = __version__ +- raise e ++from mando.core import Program + + main = Program() + command = main.command +Index: mando-0.7.1/mando/core.py +=================================================================== +--- mando-0.7.1.orig/mando/core.py ++++ mando-0.7.1/mando/core.py +@@ -5,22 +5,19 @@ ordinary Python functions into commands + import argparse + import inspect + import sys ++from inspect import signature + + from mando.napoleon import Config, GoogleDocstring, NumpyDocstring + + from mando.utils import (purify_doc, action_by_type, find_param_docs, + split_doc, ensure_dashes, purify_kwargs) +-try: +- from inspect import signature +-except ImportError: +- from funcsigs import signature + + + _POSITIONAL = type('_positional', (object,), {}) + _DISPATCH_TO = '_dispatch_to' + + +-class SubProgram(object): ++class SubProgram: + def __init__(self, parser, signatures): + self.parser = parser + self._subparsers = self.parser.add_subparsers() +Index: mando-0.7.1/mando/napoleon/__init__.py +=================================================================== +--- mando-0.7.1.orig/mando/napoleon/__init__.py ++++ mando-0.7.1/mando/napoleon/__init__.py +@@ -9,12 +9,10 @@ + :license: BSD, see LICENSE for details. + """ + +-from six import iteritems +- + from mando.napoleon.docstring import GoogleDocstring, NumpyDocstring + + +-class Config(object): ++class Config: + """Sphinx napoleon extension settings in `conf.py`. + + Listed below are all the settings used by napoleon and their default +@@ -252,7 +250,7 @@ class Config(object): + + def __init__(self, **settings): + # type: (Any) -> None +- for name, (default, rebuild) in iteritems(self._config_values): ++ for name, (default, rebuild) in self._config_values.items(): + setattr(self, name, default) +- for name, value in iteritems(settings): ++ for name, value in settings.items(): + setattr(self, name, value) +Index: mando-0.7.1/mando/napoleon/docstring.py +=================================================================== +--- mando-0.7.1.orig/mando/napoleon/docstring.py ++++ mando-0.7.1/mando/napoleon/docstring.py +@@ -11,16 +11,10 @@ + :license: BSD, see LICENSE for details. + """ + +-try: +- from collections.abc import Callable +-except ImportError: +- from collections import Callable ++from collections.abc import Callable + import inspect + import re + +-from six import string_types, u +-from six.moves import range +- + from mando.napoleon.iterators import modify_iter + from mando.napoleon.pycompat import UnicodeMixin + +@@ -124,7 +118,7 @@ class GoogleDocstring(UnicodeMixin): + self._name = name + self._obj = obj + self._opt = options +- if isinstance(docstring, string_types): ++ if isinstance(docstring, str): + docstring = docstring.splitlines() + self._lines = docstring + self._line_iter = modify_iter(docstring, modifier=lambda s: s.rstrip()) +@@ -171,7 +165,7 @@ class GoogleDocstring(UnicodeMixin): + Unicode version of the docstring. + + """ +- return u('\n').join(self.lines()) ++ return (u'\n').join(self.lines()) + + def lines(self): + # type: () -> List[unicode] +@@ -323,13 +317,13 @@ class GoogleDocstring(UnicodeMixin): + def _fix_field_desc(self, desc): + # type: (List[unicode]) -> List[unicode] + if self._is_list(desc): +- desc = [u''] + desc ++ desc = [''] + desc + elif desc[0].endswith('::'): + desc_block = desc[1:] + indent = self._get_indent(desc[0]) + block_indent = self._get_initial_indent(desc_block) + if block_indent > indent: +- desc = [u''] + desc ++ desc = [''] + desc + else: + desc = ['', desc[0]] + self._indent(desc_block, 4) + return desc +@@ -341,9 +335,9 @@ class GoogleDocstring(UnicodeMixin): + return ['.. %s:: %s' % (admonition, lines[0].strip()), ''] + elif lines: + lines = self._indent(self._dedent(lines), 3) +- return [u'.. %s::' % admonition, u''] + lines + [u''] ++ return ['.. %s::' % admonition, ''] + lines + [''] + else: +- return [u'.. %s::' % admonition, u''] ++ return ['.. %s::' % admonition, ''] + + def _format_block(self, prefix, lines, padding=None): + # type: (unicode, List[unicode], unicode) -> List[unicode] +@@ -614,7 +608,7 @@ class GoogleDocstring(UnicodeMixin): + for _name, _, _desc in self._consume_fields(parse_type=False): + lines.append('.. method:: %s' % _name) + if _desc: +- lines.extend([u''] + self._indent(_desc, 3)) ++ lines.extend([''] + self._indent(_desc, 3)) + lines.append('') + return lines + +@@ -924,7 +918,7 @@ class NumpyDocstring(GoogleDocstring): + # type: () -> bool + section, underline = self._line_iter.peek(2) + section = section.lower() +- if section in self._sections and isinstance(underline, string_types): ++ if section in self._sections and isinstance(underline, str): + return bool(_numpy_section_regex.match(underline)) # type: ignore + elif self._directive_sections: + if _directive_regex.match(section): +Index: mando-0.7.1/mando/napoleon/iterators.py +=================================================================== +--- mando-0.7.1.orig/mando/napoleon/iterators.py ++++ mando-0.7.1/mando/napoleon/iterators.py +@@ -14,7 +14,7 @@ + import collections + + +-class peek_iter(object): ++class peek_iter: + """An iterator object that supports peeking ahead. + + Parameters +Index: mando-0.7.1/mando/napoleon/pycompat.py +=================================================================== +--- mando-0.7.1.orig/mando/napoleon/pycompat.py ++++ mando-0.7.1/mando/napoleon/pycompat.py +@@ -1,18 +1,6 @@ +-from six import PY3 ++class UnicodeMixin: ++ """Mixin class to handle defining the proper __str__/__unicode__ ++ methods in Python 2 or 3.""" + +- +-# UnicodeMixin +-if PY3: +- class UnicodeMixin(object): +- """Mixin class to handle defining the proper __str__/__unicode__ +- methods in Python 2 or 3.""" +- +- def __str__(self): +- return self.__unicode__() +-else: +- class UnicodeMixin(object): +- """Mixin class to handle defining the proper __str__/__unicode__ +- methods in Python 2 or 3.""" +- +- def __str__(self): +- return self.__unicode__().encode('utf8') ++ def __str__(self): ++ return self.__unicode__() +Index: mando-0.7.1/mando/tests/capture.py +=================================================================== +--- mando-0.7.1.orig/mando/tests/capture.py ++++ mando-0.7.1/mando/tests/capture.py +@@ -7,12 +7,7 @@ Capture function + + import sys + from contextlib import contextmanager +- +-try: +- from cStringIO import StringIO +-except ImportError: +- from io import StringIO +- ++from io import StringIO + + @contextmanager + def capture_sys_output(): +Index: mando-0.7.1/mando/tests/test_unicode_docstring_on_py2.py +=================================================================== +--- mando-0.7.1.orig/mando/tests/test_unicode_docstring_on_py2.py ++++ mando-0.7.1/mando/tests/test_unicode_docstring_on_py2.py +@@ -1,6 +1,3 @@ +-# This is important: it will make all literals unicode under 2.x +-from __future__ import unicode_literals +- + import unittest + + from mando import Program +Index: mando-0.7.1/setup.py +=================================================================== +--- mando-0.7.1.orig/setup.py ++++ mando-0.7.1/setup.py +@@ -9,16 +9,15 @@ except ImportError as e: + else: + version = mando.__version__ + +-deps = ["six"] ++deps = [] + extras = {"restructuredText": ["rst2ansi"]} + + + sversion = tuple(setuptools.__version__.split(".")) + + if sversion > ("36", "2"): +- deps += ['argparse ; python_version<="2.6"', 'funcsigs ; python_version<="3.2"'] ++ deps += ['funcsigs ; python_version<="3.2"'] + elif sversion > ("18", "0"): +- extras[':python_version<="2.6"'] = ["argparse"] + extras[':python_version<="3.2"'] = ["funcsigs"] + + +@@ -51,8 +50,6 @@ setuptools.setup( + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", +- "Programming Language :: Python :: 2", +- "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.1", + "Programming Language :: Python :: 3.2", diff --git a/python-mando.changes b/python-mando.changes index f52b508..5a94661 100644 --- a/python-mando.changes +++ b/python-mando.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Aug 28 09:19:47 UTC 2024 - pgajdos@suse.com + +- drop python 2 support, do not require six +- added patches + fix https://github.com/rubik/mando/pull/57 + + python-mando-no-python2.patch + ------------------------------------------------------------------- Tue Jun 13 09:10:40 UTC 2023 - ecsos diff --git a/python-mando.spec b/python-mando.spec index 1e0ab15..0563731 100644 --- a/python-mando.spec +++ b/python-mando.spec @@ -1,7 +1,7 @@ # # spec file for package python-mando # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,15 +24,15 @@ Summary: Python wrapper around argparse, a tool to create CLI apps License: MIT URL: https://mando.readthedocs.org/ Source: https://files.pythonhosted.org/packages/source/m/mando/mando-%{version}.tar.gz +# https://github.com/rubik/mando/pull/57 +Patch0: python-mando-no-python2.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-six Suggests: python-rst2ansi BuildArch: noarch # SECTION teset requirements BuildRequires: %{python_module pytest} -BuildRequires: %{python_module six} # /SECTION %python_subpackages @@ -41,7 +41,7 @@ Mando is a wrapper around argparse, and allows writing CLI applications. %prep -%setup -q -n mando-%{version} +%autosetup -p1 -n mando-%{version} sed -i -e '/^#!\//, 1d' mando/tests/*.py %build @@ -57,6 +57,7 @@ sed -i -e '/^#!\//, 1d' mando/tests/*.py %files %{python_files} %license LICENSE %doc README.rst -%{python_sitelib}/* +%{python_sitelib}/mando +%{python_sitelib}/mando-*-info %changelog