14
0

- Convert to pip-based build and libalternatives

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-restview?expand=0&rev=17
This commit is contained in:
2025-06-11 13:10:59 +00:00
committed by Git OBS Bridge
commit 0e1d8634c8
7 changed files with 364 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -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

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

90
fix-tests.patch Normal file
View File

@@ -0,0 +1,90 @@
diff --git a/src/restview/tests.py b/src/restview/tests.py
index 71aeb77..c840cb8 100644
--- a/src/restview/tests.py
+++ b/src/restview/tests.py
@@ -541,10 +541,9 @@ def doctest_RestViewer_rest_to_html():
... ''', settings={'cloak_email_addresses': True}).strip())
... # doctest: +ELLIPSIS,+REPORT_NDIFF
<?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <!DOCTYPE html...>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
...
<title>example</title>
<style type="text/css">
@@ -556,7 +555,7 @@ def doctest_RestViewer_rest_to_html():
</style>
</head>
<body>
- <div class="document" id="example">
+ <main id="example">
<h1 class="title">example</h1>
<BLANKLINE>
<p>This is a doctest:</p>
@@ -570,11 +569,9 @@ def doctest_RestViewer_rest_to_html():
<p>This is a reference: <a class="reference external" href="http://example.com/README.rst">README.rst</a></p>
<p>This is an email: <a class="reference external" href="mailto:marius&#37;&#52;&#48;gedmin&#46;as">marius<span>&#64;</span>gedmin<span>&#46;</span>as</a></p>
<p>This is a literal block:</p>
- <pre class="literal-block">
- See <a href="CHANGES.rst">CHANGES.rst</a>, mkay?
- </pre>
+ <pre class="literal-block">See <a href="CHANGES.rst">CHANGES.rst</a>, mkay?</pre>
<p>This is an inline literal: <tt class="docutils literal"><a href="README.txt">README.txt</a></tt>.</p>
- </div>
+ </main>
</body>
</html>
@@ -594,10 +591,7 @@ def doctest_RestViewer_rest_to_html_css_url():
... ''').strip())
... # doctest: +ELLIPSIS,+REPORT_NDIFF
<?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <!DOCTYPE html...>
...
<title>...</title>
<link rel="stylesheet" href="http://example.com/my.css" type="text/css" />
@@ -606,11 +600,11 @@ def doctest_RestViewer_rest_to_html_css_url():
</style>
</head>
<body>
- <div class="document">
+ <main>
<BLANKLINE>
<BLANKLINE>
<p>Some text</p>
- </div>
+ </main>
</body>
</html>
@@ -729,21 +723,18 @@ def doctest_RestViewer_rest_to_html_pypi_strict():
... ''').strip().replace("&quot;", '"'))
... # doctest: +ELLIPSIS,+REPORT_NDIFF
<?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <!DOCTYPE html...>
...
<title>Hello</title>
<style type="text/css">
...
</head>
<body>
- <div class="document" id="hello">
+ <main id="hello">
<h1 class="title">Hello</h1>
<BLANKLINE>
<p><a href="http://www.example.com" rel="nofollow">This is fine</a>.</p>
- </div>
+ </main>
</body>
</html>

108
fix_tests.patch Normal file
View File

@@ -0,0 +1,108 @@
From 6a1d6b44ee400431d75ed2326bd0b4f35d4727fa Mon Sep 17 00:00:00 2001
From: Marius Gedminas <marius@gedmin.as>
Date: Mon, 21 Aug 2023 13:11:43 +0300
Subject: [PATCH] Fix tests
Not sure why they broke (new docutils release on PyPI)? Doctests were a
bad idea.
---
src/restview/tests.py | 58 +++++++++----------------------------------
1 file changed, 12 insertions(+), 46 deletions(-)
Index: restview-3.0.1/src/restview/tests.py
===================================================================
--- restview-3.0.1.orig/src/restview/tests.py
+++ restview-3.0.1/src/restview/tests.py
@@ -540,7 +540,7 @@ def doctest_RestViewer_rest_to_html():
... This is an inline literal: ``README.txt``.
... ''', settings={'cloak_email_addresses': True}).strip())
... # doctest: +ELLIPSIS,+REPORT_NDIFF
- <?xml version="1.0" encoding="utf-8" ?>
+ <?xml version="1.0" encoding="utf-8"...?>
<!DOCTYPE html...>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -581,34 +581,12 @@ def doctest_RestViewer_rest_to_html():
def doctest_RestViewer_rest_to_html_css_url():
"""Test for RestViewer.rest_to_html
- XXX: this shows pygments styles inlined *after* the external css, which
- means it's hard to override them!
-
>>> viewer = RestViewer('.')
>>> viewer.stylesheets = 'http://example.com/my.css'
- >>> print(viewer.rest_to_html(b'''
- ... Some text
- ... ''').strip())
- ... # doctest: +ELLIPSIS,+REPORT_NDIFF
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html...>
- ...
- <title>...</title>
+ >>> html = viewer.rest_to_html(b'Some text')
+ >>> grep('stylesheet', html)
<link rel="stylesheet" href="http://example.com/my.css" type="text/css" />
- <style type="text/css">
- ...
- </style>
- </head>
- <body>
- <main>
- <BLANKLINE>
- <BLANKLINE>
- <p>Some text</p>
- </main>
- </body>
- </html>
-
- """
+ """
def doctest_RestViewer_rest_to_html_strict_and_error_handling():
@@ -714,29 +692,16 @@ def doctest_RestViewer_rest_to_html_pypi
>>> viewer = RestViewer('.')
>>> viewer.stylesheets = None
>>> viewer.pypi_strict = True
- >>> print(viewer.rest_to_html(b'''
+ >>> html = viewer.rest_to_html(b'''
... Hello
... -----
...
... `This is fine <http://www.example.com>`__.
...
- ... ''').strip().replace("&quot;", '"'))
- ... # doctest: +ELLIPSIS,+REPORT_NDIFF
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html...>
- ...
+ ... ''')
+ >>> grep('Hello', html)
<title>Hello</title>
- <style type="text/css">
- ...
- </head>
- <body>
- <main id="hello">
<h1 class="title">Hello</h1>
- <BLANKLINE>
- <p><a href="http://www.example.com" rel="nofollow">This is fine</a>.</p>
- </main>
- </body>
- </html>
"""
@@ -1022,6 +987,12 @@ class TestMain(unittest.TestCase):
serve_called=True, browser_launched=True)
+def grep(needle, haystack):
+ for line in haystack.splitlines():
+ if needle in line:
+ print(line)
+
+
def test_suite():
return unittest.TestSuite([
unittest.defaultTestLoader.loadTestsFromName(__name__),

61
python-restview.changes Normal file
View File

@@ -0,0 +1,61 @@
-------------------------------------------------------------------
Wed Jun 11 13:08:29 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Convert to pip-based build and libalternatives
-------------------------------------------------------------------
Thu Nov 23 13:41:52 UTC 2023 - Markéta Machová <mmachova@suse.com>
- Update to 3.0.1
* Add support for Python 3.11.
* Drop support for Python 3.6.
- Add fix_tests.patch to fix tests one more time
* from the commit message: "Doctests were a bad idea."
-------------------------------------------------------------------
Fri Dec 2 09:54:28 UTC 2022 - Daniel Garcia <daniel.garcia@suse.com>
- Add fix-tests.patch gh#mgedmin/restview@5033eacb1d55
- Remove python_module macro definition
- More specific python_sitelib in %files
- Use autosetup instead of setup + autopatch
-------------------------------------------------------------------
Thu Apr 14 07:20:58 UTC 2022 - pgajdos@suse.com
- version update to 3.0.0
3.0.0 (2022-01-12)
- Drop support for Python 2.7.
2.9.3 (2021-11-29)
- Fix incompatibility with docutils 0.18.1 that resulted in "Cannot embed
stylesheet" errors (`issue 61 <https://github.com/mgedmin/restview/pull/61>`_,
contributed by Sébastien Besson).
- Add support for Python 3.8, 3.9, and 3.10.
- Drop support for Python 3.5.
- deleted patches
- false.patch (upstreamed)
-------------------------------------------------------------------
Thu Apr 1 12:58:17 UTC 2021 - Markéta Machová <mmachova@suse.com>
- Add false.patch to fix recent build failure
-------------------------------------------------------------------
Wed Jan 13 11:07:59 UTC 2021 - pgajdos@suse.com
- use %pytest macro
-------------------------------------------------------------------
Tue May 19 09:27:44 UTC 2020 - Petr Gajdos <pgajdos@suse.com>
- %python3_only -> %python_alternative
-------------------------------------------------------------------
Tue Sep 10 07:12:21 UTC 2019 - Jan Engelhardt <jengelh@inai.de>
- Use somewhat longer description from upstream.
-------------------------------------------------------------------
Fri Sep 6 03:53:30 PM UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Initial spec for v2.9.2

78
python-restview.spec Normal file
View File

@@ -0,0 +1,78 @@
#
# spec file for package python-restview
#
# 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-restview
Version: 3.0.1
Release: 0
Summary: ReStructuredText viewer
License: GPL-3.0-only
Group: Development/Languages/Python
URL: https://mg.pov.lt/restview/
Source: https://files.pythonhosted.org/packages/source/r/restview/restview-%{version}.tar.gz
# PATCH-FIX-UPSTREAM fix-tests.patch gh#mgedmin/restview@5033eacb1d55
Patch0: fix-tests.patch
# PATCH-FIX-UPSTREAM fix_tests.patch gh#mgedmin/restview@6a1d6b44ee40
Patch1: fix_tests.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: alts
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: alts
Requires: python-docutils
Requires: python-pygments
Requires: python-readme_renderer
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module docutils}
BuildRequires: %{python_module pygments}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module readme_renderer}
# /SECTION
%python_subpackages
%description
A viewer for ReStructuredText documents that renders them on the fly.
%prep
%autosetup -p1 -n restview-%{version}
%build
%pyproject_wheel
%install
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/restview
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest
%pre
%python_libalternatives_reset_alternative restview
%files %{python_files}
%doc CHANGES.rst README.rst
%license LICENSE
%python_alternative %{_bindir}/restview
%{python_sitelib}/restview
%{python_sitelib}/restview-%{version}*-info
%changelog

3
restview-3.0.1.tar.gz Normal file
View File

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