From d77581b284559f94707022f96a079620d4e5cedbf531abe33dd2c01db79debcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Mon, 9 Jun 2025 15:08:15 +0000 Subject: [PATCH] - Convert to libalternatives OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pprintpp?expand=0&rev=14 --- .gitattributes | 23 +++ .gitignore | 1 + 3a35e815.patch | 33 ++++ pprintpp-0.4.0.tar.gz | 3 + python-311.patch | 13 ++ python-pprintpp-remove-nose.patch | 289 ++++++++++++++++++++++++++++++ python-pprintpp.changes | 44 +++++ python-pprintpp.spec | 76 ++++++++ 8 files changed, 482 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 3a35e815.patch create mode 100644 pprintpp-0.4.0.tar.gz create mode 100644 python-311.patch create mode 100644 python-pprintpp-remove-nose.patch create mode 100644 python-pprintpp.changes create mode 100644 python-pprintpp.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/3a35e815.patch b/3a35e815.patch new file mode 100644 index 0000000..060520f --- /dev/null +++ b/3a35e815.patch @@ -0,0 +1,33 @@ +From 873217674cc824b4c1cfdad4867c560c60e8d806 Mon Sep 17 00:00:00 2001 +From: Jake Waksbaum +Date: Fri, 18 Jan 2019 16:56:04 +0000 +Subject: [PATCH] Replace nose-parameterized with parameterized + +According to https://pypi.org/project/nose-parameterized +nose-parametrized is deprecated in favor of parameterized. +--- + test-requires.txt | 2 +- + test.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test-requires.txt b/test-requires.txt +index ed8195f..3621aa6 100644 +--- a/test-requires.txt ++++ b/test-requires.txt +@@ -1,2 +1,2 @@ + nose==1.3.0 +-nose_parameterized==0.3.3 ++parameterized==0.6.1 +diff --git a/test.py b/test.py +index 966c9de..45a0075 100644 +--- a/test.py ++++ b/test.py +@@ -5,7 +5,7 @@ + import textwrap + + from nose.tools import assert_equal +-from nose_parameterized import parameterized, param ++from parameterized import parameterized, param + + sys.path.append("pp/") + import pp diff --git a/pprintpp-0.4.0.tar.gz b/pprintpp-0.4.0.tar.gz new file mode 100644 index 0000000..97ff3ce --- /dev/null +++ b/pprintpp-0.4.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403 +size 17995 diff --git a/python-311.patch b/python-311.patch new file mode 100644 index 0000000..3fc40d3 --- /dev/null +++ b/python-311.patch @@ -0,0 +1,13 @@ +Index: pprintpp-0.4.0/setup.py +=================================================================== +--- pprintpp-0.4.0.orig/setup.py ++++ pprintpp-0.4.0/setup.py +@@ -8,7 +8,7 @@ from setuptools import setup + os.chdir(os.path.dirname(sys.argv[0]) or ".") + + try: +- long_description = open("README.rst", "U").read() ++ long_description = open("README.rst").read() + except IOError: + long_description = "See https://github.com/wolever/pprintpp" + diff --git a/python-pprintpp-remove-nose.patch b/python-pprintpp-remove-nose.patch new file mode 100644 index 0000000..cdcb5f3 --- /dev/null +++ b/python-pprintpp-remove-nose.patch @@ -0,0 +1,289 @@ +Index: pprintpp-0.4.0/test.py +=================================================================== +--- pprintpp-0.4.0.orig/test.py 2021-10-26 13:15:18.391876167 +0200 ++++ pprintpp-0.4.0/test.py 2021-10-26 13:15:23.059902356 +0200 +@@ -1,46 +1,100 @@ + from __future__ import print_function + + import sys +-import ctypes +-import textwrap +- +-from nose.tools import assert_equal +-from parameterized import parameterized, param ++from contextlib import redirect_stdout ++import io ++import pytest + + sys.path.append("pp/") + import pp + import pprintpp as p + from pprintpp import Counter, defaultdict, OrderedDict + +-class PPrintppTestBase(object): +- def assertStdout(self, expected, trim=True): +- if trim: +- expected = textwrap.dedent(expected.rstrip().lstrip("\n")) +- # Assumes that nose's capture plugin is active +- assert_equal(sys.stdout.getvalue().rstrip(), expected) +- +- +-class TestPP(PPrintppTestBase): +- def test_pp(self): ++def test_pp(): ++ expected = "['hello', 'world']" ++ f = io.StringIO() ++ with redirect_stdout(f): + pp(["hello", "world"]) +- self.assertStdout("['hello', 'world']") ++ actual = f.getvalue().rstrip("\n") ++ assert actual == expected + +- def test_pp_pprint(self): ++def test_pp_print(): ++ expected = "'stuff'" ++ f = io.StringIO() ++ with redirect_stdout(f): + pp.pprint("stuff") +- self.assertStdout("'stuff'") ++ actual = f.getvalue().rstrip("\n") ++ assert actual == expected + +- def test_fmt(self): ++def test_fmt(): ++ expected = "'asdf'\n'stuff'" ++ f = io.StringIO() ++ with redirect_stdout(f): + print(pp.pformat("asdf")) + print(pp.fmt("stuff")) +- self.assertStdout(""" +- 'asdf' +- 'stuff' +- """) +- +- def test_module_like(self): +- print(dir(pp)) +- print(repr(pp)) ++ actual = f.getvalue().rstrip("\n") ++ assert actual == expected + ++def test_module_like(): ++ print(dir(pp)) ++ print(repr(pp)) ++ ++uni_safe = "\xe9 \u6f02 \u0e4f \u2661" ++uni_unsafe = "\u200a \u0302 \n" ++slashed = lambda s: u"%s'%s'" %( ++ p.u_prefix, ++ s.encode("ascii", "backslashreplace").decode("ascii").replace("\n", "\\n") ++) ++ ++test_unicode_data = [ ++ (uni_safe, "%s'%s'" %(p.u_prefix, uni_safe), "utf-8"), ++ (uni_unsafe, slashed(uni_unsafe), "utf-8"), ++ (uni_unsafe, slashed(uni_unsafe), "ascii"), ++ ("\U0002F9B2", slashed("\U0002F9B2"), "ascii") ++] ++ ++@pytest.mark.parametrize("input,expected,encoding", test_unicode_data) ++def test_unicode(input, expected, encoding): ++ stream = p.TextIO(encoding=encoding) ++ p.pprint(input, stream=stream) ++ assert stream.getvalue().rstrip("\n") == expected ++ ++test_back_and_forth_data = [ ++ "'\\'\"'", ++ '"\'"', ++ "'\"'", ++ "frozenset(['a', 'b', 'c'])", ++ "set([None, 1, 'a'])", ++ "[]", ++ "[1]", ++ "{}", ++ "{1: 1}", ++ "set()", ++ "set([1])", ++ "frozenset()", ++ "frozenset([1])", ++ "()", ++ "(1, )", ++ "MyDict({})", ++ "MyDict({1: 1})", ++ "MyList([])", ++ "MyList([1])", ++ "MyTuple(())", ++ "MyTuple((1, ))", ++ "MySet()", ++ "MySet([1])", ++ "MyFrozenSet()", ++ "MyFrozenSet([1])", ++ "Counter()", ++ "Counter({1: 1})", ++ "OrderedDict()", ++ "OrderedDict([(1, 1), (5, 5), (2, 2)])", ++ "MyOrderedDict()", ++ "MyOrderedDict([(1, 1)])", ++ "MyCounter()", ++ "MyCounter({1: 1})", ++ "MyCounterWithRepr('dummy')", ++] + + class MyDict(dict): + pass +@@ -70,104 +124,46 @@ class MyCounterWithRepr(p.Counter): + def __repr__(self): + return "MyCounterWithRepr('dummy')" + +-class TestPPrint(PPrintppTestBase): +- uni_safe = u"\xe9 \u6f02 \u0e4f \u2661" +- uni_unsafe = u"\u200a \u0302 \n" +- slashed = lambda s: u"%s'%s'" %( +- p.u_prefix, +- s.encode("ascii", "backslashreplace").decode("ascii").replace("\n", "\\n") +- ) +- +- @parameterized([ +- param("safe", uni_safe, "%s'%s'" %(p.u_prefix, uni_safe)), +- param("unsafe", uni_unsafe, slashed(uni_unsafe)), +- param("encoding-aware", uni_safe, slashed(uni_safe), encoding="ascii"), +- param("high-end-chars", u"\U0002F9B2", slashed(u"\U0002F9B2"), encoding="ascii"), +- ]) +- def test_unicode(self, name, input, expected, encoding="utf-8"): +- stream = p.TextIO(encoding=encoding) +- p.pprint(input, stream=stream) +- assert_equal(stream.getvalue().rstrip("\n"), expected) +- +- @parameterized([ +- param(u"'\\'\"'"), +- param(u'"\'"'), +- param(u"'\"'"), +- param("frozenset(['a', 'b', 'c'])"), +- param("set([None, 1, 'a'])"), +- +- param("[]"), +- param("[1]"), +- param("{}"), +- param("{1: 1}"), +- param("set()"), +- param("set([1])"), +- param("frozenset()"), +- param("frozenset([1])"), +- param("()"), +- param("(1, )"), +- +- param("MyDict({})"), +- param("MyDict({1: 1})"), +- param("MyList([])"), +- param("MyList([1])"), +- param("MyTuple(())"), +- param("MyTuple((1, ))"), +- param("MySet()"), +- param("MySet([1])"), +- param("MyFrozenSet()"), +- param("MyFrozenSet([1])"), +- +- ] + ([] if not p._test_has_collections else [ +- param("Counter()"), +- param("Counter({1: 1})"), +- param("OrderedDict()"), +- param("OrderedDict([(1, 1), (5, 5), (2, 2)])"), +- param("MyOrderedDict()"), +- param("MyOrderedDict([(1, 1)])"), +- param("MyCounter()"), +- param("MyCounter({1: 1})"), +- param("MyCounterWithRepr('dummy')"), +- ])) +- def test_back_and_forth(self, expected): +- input = eval(expected) +- stream = p.TextIO() +- p.pprint(input, stream=stream) +- assert_equal(stream.getvalue().rstrip("\n"), expected) +- +- if p._test_has_collections: +- @parameterized([ +- param("defaultdict(%r, {})" %(int, ), defaultdict(int)), +- param("defaultdict(%r, {1: 1})" %(int, ), defaultdict(int, [(1, 1)])), +- param("MyDefaultDict(%r, {})" %(int, ), MyDefaultDict(int)), +- param("MyDefaultDict(%r, {1: 1})" %(int, ), MyDefaultDict(int, [(1, 1)])), +- ]) +- def test_expected_input(self, expected, input): +- stream = p.TextIO() +- p.pprint(input, stream=stream) +- assert_equal(stream.getvalue().rstrip("\n"), expected) +- +- def test_unhashable_repr(self): +- # In Python 3, C extensions can define a __repr__ method which is an +- # instance of `instancemethod`, which is unhashable. It turns out to be +- # spectacularly difficult to create an `instancemethod` and attach it to +- # a type without using C... so we'll simulate it using a more explicitly +- # unhashable type. +- # See also: http://stackoverflow.com/q/40876368/71522 +- +- class UnhashableCallable(object): +- __hash__ = None +- +- def __call__(self): +- return "some-repr" +- +- class MyCls(object): +- __repr__ = UnhashableCallable() +- +- obj = MyCls() +- assert_equal(p.pformat(obj), "some-repr") +- +- +-if __name__ == "__main__": +- import nose +- nose.main() ++@pytest.mark.parametrize("expected", test_back_and_forth_data) ++def test_back_and_forth(expected): ++ input = eval(expected) ++ stream = p.TextIO() ++ p.pprint(input, stream=stream) ++ assert stream.getvalue().rstrip("\n") == expected ++ ++test_expected_input_data = [ ++ ("defaultdict(%r, {})" %(int, ), defaultdict(int)), ++ ("defaultdict(%r, {1: 1})" %(int, ), defaultdict(int, [(1, 1)])), ++ ("MyDefaultDict(%r, {})" %(int, ), MyDefaultDict(int)), ++ ("MyDefaultDict(%r, {1: 1})" %(int, ), MyDefaultDict(int, [(1, 1)])), ++] ++ ++@pytest.mark.parametrize("expected,input", test_expected_input_data) ++def test_expected_input(expected, input): ++ stream = p.TextIO() ++ p.pprint(input, stream=stream) ++ assert stream.getvalue().rstrip("\n") == expected ++ ++ ++def test_unhashable_repr(): ++ # In Python 3, C extensions can define a __repr__ method which is an ++ # instance of `instancemethod`, which is unhashable. It turns out to be ++ # spectacularly difficult to create an `instancemethod` and attach it to ++ # a type without using C... so we'll simulate it using a more explicitly ++ # unhashable type. ++ # See also: http://stackoverflow.com/q/40876368/71522 ++ ++ class UnhashableCallable(object): ++ __hash__ = None ++ ++ def __call__(self): ++ return "some-repr" ++ ++ class MyCls(object): ++ __repr__ = UnhashableCallable() ++ ++ obj = MyCls() ++ assert p.pformat(obj) == "some-repr" ++ ++ ++ +Index: pprintpp-0.4.0/test-requires.txt +=================================================================== +--- pprintpp-0.4.0.orig/test-requires.txt 2021-10-26 13:15:18.391876167 +0200 ++++ pprintpp-0.4.0/test-requires.txt 2021-10-26 13:15:18.395876190 +0200 +@@ -1,2 +1,2 @@ +-nose==1.3.0 ++pytest + parameterized==0.6.1 + diff --git a/python-pprintpp.changes b/python-pprintpp.changes new file mode 100644 index 0000000..845bee0 --- /dev/null +++ b/python-pprintpp.changes @@ -0,0 +1,44 @@ +------------------------------------------------------------------- +Mon Jun 9 15:07:59 UTC 2025 - Markéta Machová + +- Convert to libalternatives + +------------------------------------------------------------------- +Tue Jun 3 12:01:25 UTC 2025 - Markéta Machová + +- Convert to pip-based build + +------------------------------------------------------------------- +Fri Feb 24 11:29:28 UTC 2023 - Daniel Garcia + +- Add python-311.patch to support python 3.11 + +------------------------------------------------------------------- +Wed Feb 9 18:02:05 UTC 2022 - Matej Cepl + +- Remove nose BR, we really needn't it. + +------------------------------------------------------------------- +Tue Oct 26 11:38:48 UTC 2021 - pgajdos@suse.com + +- %check: drop usage of nose, use %pytest macro for testing +- added patches + fix https://github.com/wolever/pprintpp/pull/28 + + python-pprintpp-remove-nose.patch + +------------------------------------------------------------------- +Wed May 20 07:26:15 UTC 2020 - Petr Gajdos + +- %python3_only -> %python_alternative + +------------------------------------------------------------------- +Sat Aug 24 06:34:13 UTC 2019 - Jan Engelhardt + +- Make description more neutral. + +------------------------------------------------------------------- +Thu Aug 1 03:14:08 AM UTC 2019 - John Vandenberg + +- Initial spec for v0.4.0 +- Add patch fixing tests from upstream git: + * 3a35e815.patch diff --git a/python-pprintpp.spec b/python-pprintpp.spec new file mode 100644 index 0000000..c54ae2a --- /dev/null +++ b/python-pprintpp.spec @@ -0,0 +1,76 @@ +# +# spec file for package python-pprintpp +# +# Copyright (c) 2025 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%bcond_without libalternatives +Name: python-pprintpp +Version: 0.4.0 +Release: 0 +Summary: A variant of pprint that is arguably "prettier" +License: BSD-2-Clause +Group: Development/Languages/Python +URL: https://github.com/wolever/pprintpp +Source: https://files.pythonhosted.org/packages/source/p/pprintpp/pprintpp-%{version}.tar.gz +# https://github.com/wolever/pprintpp/commit/3a35e815.patch +Patch0: 3a35e815.patch +# gh#wolever/pprintpp#28 +Patch1: python-pprintpp-remove-nose.patch +# PATCH-FIX-OPENSUSE python-311.patch small fix to support python 3.11 +Patch2: python-311.patch +BuildRequires: %{python_module parameterized} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: alts +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: alts +BuildArch: noarch +%python_subpackages + +%description +A drop-in replacement for pprint that is arguably prettier. + +%prep +%autosetup -p1 -n pprintpp-%{version} + +%build +export LANG=en_US.utf-8 +%pyproject_wheel + +%install +export LANG=en_US.utf-8 +%pyproject_install +%python_clone -a %{buildroot}%{_bindir}/pypprint +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +export LANG=en_US.utf-8 +%pytest -v test.py + +%pre +%python_libalternatives_reset_alternative pypprint + +%files %{python_files} +%doc CHANGELOG.txt README.rst +%license LICENSE.txt +%python_alternative %{_bindir}/pypprint +%{python_sitelib}/pprintpp +%{python_sitelib}/pprintpp-%{version}*-info + +%changelog