From a3edc68c72db3acd8b2d841751f96fffecfdb829ea70157eb9f4883a698b74e9 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 27 Aug 2025 02:56:11 +0000 Subject: [PATCH] - Replace python-blockdiag-nose-to-pytest.patch with a different upstream patch to also drop use of yield tests. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-blockdiag?expand=0&rev=30 --- .gitattributes | 23 ++++ .gitignore | 1 + blockdiag-3.0.0.tar.gz | 3 + pillow10.patch | 117 ++++++++++++++++ python-blockdiag-nose-to-pytest.patch | 183 ++++++++++++++++++++++++++ python-blockdiag.changes | 104 +++++++++++++++ python-blockdiag.spec | 97 ++++++++++++++ 7 files changed, 528 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 blockdiag-3.0.0.tar.gz create mode 100644 pillow10.patch create mode 100644 python-blockdiag-nose-to-pytest.patch create mode 100644 python-blockdiag.changes create mode 100644 python-blockdiag.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/blockdiag-3.0.0.tar.gz b/blockdiag-3.0.0.tar.gz new file mode 100644 index 0000000..7f681cb --- /dev/null +++ b/blockdiag-3.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dee4195bb87d23654546ba2bf5091480dbf253b409891fce2cd527c91d00a3e2 +size 2694464 diff --git a/pillow10.patch b/pillow10.patch new file mode 100644 index 0000000..879123e --- /dev/null +++ b/pillow10.patch @@ -0,0 +1,117 @@ +From 20d780cad84e7b010066cb55f848477957870165 Mon Sep 17 00:00:00 2001 +From: Theodore Ni <3806110+tjni@users.noreply.github.com> +Date: Sat, 5 Aug 2023 10:43:46 -0700 +Subject: [PATCH] Add support for Pillow 10 + +Fix a bunch of breaking changes in a backwards compatible way. +--- + src/blockdiag/imagedraw/png.py | 47 ++++++++++++++++++++++++++++------ + 1 file changed, 39 insertions(+), 8 deletions(-) + +diff --git a/src/blockdiag/imagedraw/png.py b/src/blockdiag/imagedraw/png.py +index 3cac05a..12f0514 100644 +--- a/src/blockdiag/imagedraw/png.py ++++ b/src/blockdiag/imagedraw/png.py +@@ -30,6 +30,21 @@ + from blockdiag.utils.myitertools import istep, stepslice + + ++# to support pillow < 9.1.0 ++if not hasattr(Image, 'Resampling'): ++ from enum import IntEnum ++ ++ class Resampling(IntEnum): ++ NEAREST = 0 ++ BOX = 4 ++ BILINEAR = 2 ++ HAMMING = 5 ++ BICUBIC = 3 ++ LANCZOS = 1 ++ ++ Image.Resampling = Resampling ++ ++ + def point_pairs(xylist): + iterable = iter(xylist) + for pt in iterable: +@@ -147,7 +162,7 @@ def set_canvas_size(self, size): + self.draw = ImageDraw.Draw(self._image) + + def resizeCanvas(self, size): +- self._image = self._image.resize(size, Image.ANTIALIAS) ++ self._image = self._image.resize(size, Image.Resampling.LANCZOS) + self.draw = ImageDraw.Draw(self._image) + + def arc(self, box, start, end, **kwargs): +@@ -273,13 +288,21 @@ def textfolder(self): + def textlinesize(self, string, font): + ttfont = ttfont_for(font) + if ttfont is None: +- size = self.draw.textsize(string, font=None) ++ if hasattr(self.draw, 'textbbox'): ++ left, top, right, bottom = self.draw.textbbox((0, 0), string) ++ size = (right - left, bottom - top) ++ else: ++ size = self.draw.textsize(string, font=None) + + font_ratio = font.size * 1.0 / FontMap.BASE_FONTSIZE + size = Size(int(size[0] * font_ratio), + int(size[1] * font_ratio)) + else: +- size = Size(*ttfont.getsize(string)) ++ if hasattr(ttfont, 'getbbox'): ++ left, top, right, bottom = ttfont.getbbox(string) ++ size = Size(right - left, bottom - top) ++ else: ++ size = Size(*ttfont.getsize(string)) + + return size + +@@ -291,7 +314,11 @@ def text(self, xy, string, font, **kwargs): + if self.scale_ratio == 1 and font.size == FontMap.BASE_FONTSIZE: + self.draw.text(xy, string, fill=fill) + else: +- size = self.draw.textsize(string) ++ if hasattr(self.draw, 'textbbox'): ++ left, top, right, bottom = self.draw.textbbox((0, 0), string) ++ size = (right - left, bottom - top) ++ else: ++ size = self.draw.textsize(string) + image = Image.new('RGBA', size) + draw = ImageDraw.Draw(image) + draw.text((0, 0), string, fill=fill) +@@ -299,10 +326,14 @@ def text(self, xy, string, font, **kwargs): + + basesize = (size[0] * self.scale_ratio, + size[1] * self.scale_ratio) +- text_image = image.resize(basesize, Image.ANTIALIAS) ++ text_image = image.resize(basesize, Image.Resampling.LANCZOS) + self.paste(text_image, xy, text_image) + else: +- size = ttfont.getsize(string) ++ if hasattr(ttfont, 'getbbox'): ++ left, top, right, bottom = ttfont.getbbox(string) ++ size = (right - left, bottom - top) ++ else: ++ size = ttfont.getsize(string) + + # Generate mask to support BDF(bitmap font) + mask = Image.new('1', size) +@@ -370,7 +401,7 @@ def image(self, box, url): + # resize image. + w = min([box.width, image.size[0] * self.scale_ratio]) + h = min([box.height, image.size[1] * self.scale_ratio]) +- image.thumbnail((w, h), Image.ANTIALIAS) ++ image.thumbnail((w, h), Image.Resampling.LANCZOS) + + # centering image. + w, h = image.size +@@ -404,7 +435,7 @@ def save(self, filename, size, _format): + y = int(self._image.size[1] / self.scale_ratio) + size = (x, y) + +- self._image.thumbnail(size, Image.ANTIALIAS) ++ self._image.thumbnail(size, Image.Resampling.LANCZOS) + + if self.filename: + self._image.save(self.filename, _format) diff --git a/python-blockdiag-nose-to-pytest.patch b/python-blockdiag-nose-to-pytest.patch new file mode 100644 index 0000000..df86339 --- /dev/null +++ b/python-blockdiag-nose-to-pytest.patch @@ -0,0 +1,183 @@ +From 4f4f726252084f17ecc6c524592222af09d37da4 Mon Sep 17 00:00:00 2001 +From: Guillaume Grossetie +Date: Mon, 10 Jul 2023 00:31:37 +0200 +Subject: [PATCH] Switch to pytest (nose is unmaintained and does not work on + Python3.10) + +--- + setup.py | 3 +- + src/blockdiag/tests/test_generate_diagram.py | 95 ++++++++++---------- + tox.ini | 2 +- + 3 files changed, 49 insertions(+), 51 deletions(-) + +Index: blockdiag-3.0.0/setup.py +=================================================================== +--- blockdiag-3.0.0.orig/setup.py ++++ blockdiag-3.0.0/setup.py +@@ -65,7 +65,7 @@ setup( + 'docutils' + ], + 'testing': [ +- 'nose', ++ 'pytest', + 'flake8', + 'flake8-coding', + 'flake8-copyright', +@@ -74,7 +74,6 @@ setup( + 'docutils', + ], + }, +- test_suite='nose.collector', + entry_points=""" + [console_scripts] + blockdiag = blockdiag.command:main +Index: blockdiag-3.0.0/src/blockdiag/tests/test_generate_diagram.py +=================================================================== +--- blockdiag-3.0.0.orig/src/blockdiag/tests/test_generate_diagram.py ++++ blockdiag-3.0.0/src/blockdiag/tests/test_generate_diagram.py +@@ -19,7 +19,7 @@ import sys + import unittest + from xml.etree import ElementTree + +-from nose.tools import nottest ++import pytest + + import blockdiag + import blockdiag.command +@@ -38,7 +38,7 @@ def get_diagram_files(testdir): + diagramsdir = os.path.join(testdir, 'diagrams') + + skipped = ['README', 'debian-logo-256color-palettealpha.png', +- 'errors', 'invalid.txt', 'white.gif'] ++ 'errors', 'invalid.txt', 'white.gif', 'node_icon.diag'] + for file in os.listdir(diagramsdir): + if file in skipped: + pass +@@ -46,66 +46,67 @@ def get_diagram_files(testdir): + yield os.path.join(diagramsdir, file) + + +-def test_generate(): +- mainfunc = blockdiag.command.main +- basepath = os.path.dirname(__file__) +- files = get_diagram_files(basepath) +- options = [] ++base_path = os.path.dirname(__file__) ++files = get_diagram_files(base_path) ++generate_testdata = [] ++generate_with_separate_testdata = [] ++for file_source in files: ++ generate_testdata.append((file_source, 'svg', [])) ++ generate_testdata.append((file_source, 'png', [])) ++ generate_testdata.append((file_source, 'png', ['--antialias'])) ++ generate_testdata.append((file_source, 'pdf', [])) ++ if re.search('separate', file_source): ++ generate_with_separate_testdata.append((file_source, 'svg', ['--separate'])) ++ generate_with_separate_testdata.append((file_source, 'png', ['--separate'])) ++ generate_with_separate_testdata.append((file_source, 'png', ['--separate', '--antialias'])) ++ generate_with_separate_testdata.append((file_source, 'pdf', ['--separate'])) ++ + +- for testcase in testcase_generator(basepath, mainfunc, files, options): +- yield testcase ++@pytest.mark.parametrize("source,file_type,options", generate_with_separate_testdata) ++def test_generate_with_separate_option(source, file_type, options): ++ mainfunc = blockdiag.command.main ++ generate(mainfunc, source, file_type, options) + + +-def test_generate_with_separate(): ++@pytest.mark.parametrize("source,file_type,options", generate_testdata) ++def test_generate_with_separate(source, file_type, options): + mainfunc = blockdiag.command.main +- basepath = os.path.dirname(__file__) +- files = get_diagram_files(basepath) +- filtered = (f for f in files if re.search('separate', f)) +- options = ['--separate'] +- +- for testcase in testcase_generator(basepath, mainfunc, filtered, options): +- yield testcase +- +- +-@nottest +-def testcase_generator(basepath, mainfunc, files, options): +- fontpath = get_fontpath(basepath) +- options = options + ['-f', fontpath] ++ generate(mainfunc, source, file_type, options) + +- for source in files: +- yield generate, mainfunc, 'svg', source, options + ++@capture_stderr ++def generate(mainfunc, source, file_type, options): ++ if file_type == 'png': + if not supported_pil(): +- yield unittest.skip("Pillow is not available")(generate) +- yield unittest.skip("Pillow is not available")(generate) +- elif os.environ.get('ALL_TESTS') is None: +- message = "Skipped by default. To enable it, specify $ALL_TESTS=1" +- yield unittest.skip(message)(generate) +- yield unittest.skip(message)(generate) +- else: +- yield generate, mainfunc, 'png', source, options +- yield generate, mainfunc, 'png', source, options + ['--antialias'] +- ++ unittest.skip('Pillow is not available') ++ return ++ if os.environ.get('ALL_TESTS') is None: ++ unittest.skip('Skipped by default. To enable it, specify $ALL_TESTS=1') ++ return ++ elif file_type == 'pdf': + if not supported_pdf(): +- yield unittest.skip("reportlab is not available")(generate) +- elif os.environ.get('ALL_TESTS') is None: +- message = "Skipped by default. To enable it, specify $ALL_TESTS=1" +- yield unittest.skip(message)(generate) +- else: +- yield generate, mainfunc, 'pdf', source, options +- ++ unittest.skip('reportlab is not available') ++ return ++ if os.environ.get('ALL_TESTS') is None: ++ unittest.skip('Skipped by default. To enable it, specify $ALL_TESTS=1') ++ return + +-@capture_stderr +-def generate(mainfunc, filetype, source, options): ++ tmpdir = None + try: + tmpdir = TemporaryDirectory() +- fd, tmpfile = tmpdir.mkstemp() ++ fd, tmp_file = tmpdir.mkstemp() + os.close(fd) +- +- mainfunc(['--debug', '-T', filetype, '-o', tmpfile, source] + +- list(options)) ++ mainfunc( ++ [ ++ '--debug', ++ '-T', ++ file_type, ++ '-o', tmp_file, source ++ ] + list(options) ++ ) + finally: +- tmpdir.clean() ++ if tmpdir is not None: ++ tmpdir.clean() + + + def not_exist_font_config_option_test(): +Index: blockdiag-3.0.0/tox.ini +=================================================================== +--- blockdiag-3.0.0.orig/tox.ini ++++ blockdiag-3.0.0/tox.ini +@@ -18,7 +18,7 @@ deps = + passenv = + ALL_TESTS + commands = +- nosetests ++ pytest + + [testenv:flake8] + description = diff --git a/python-blockdiag.changes b/python-blockdiag.changes new file mode 100644 index 0000000..15f48bc --- /dev/null +++ b/python-blockdiag.changes @@ -0,0 +1,104 @@ +------------------------------------------------------------------- +Wed Aug 27 02:55:25 UTC 2025 - Steve Kowalik + +- Replace python-blockdiag-nose-to-pytest.patch with a different + upstream patch to also drop use of yield tests. + +------------------------------------------------------------------- +Wed Jun 4 14:58:34 UTC 2025 - Nico Krapp + +- fix usage of libalternatives + +------------------------------------------------------------------- +Wed May 14 12:28:44 UTC 2025 - Markéta Machová + +- Convert to pip-based build + +------------------------------------------------------------------- +Tue Oct 3 12:06:41 UTC 2023 - Markéta Machová + +- Add upstream pillow10.patch to fix compatibility with Pillow 10.0.0 + +------------------------------------------------------------------- +Wed May 3 11:50:50 UTC 2023 - Dirk Müller + +- add sle15_python_module_pythons (jsc#PED-68) + +------------------------------------------------------------------- +Thu Aug 4 19:43:01 UTC 2022 - Ben Greiner + +- Update to 3.0.0 + * Drop python3.6 support + * Use funcparserlib-1.0.0a0 or newer to support new python + versions + * Allow to write multiline string via triple quotes (""" ... """) + * Fix #147: file existence disclosure using svg renderer +- Refresh python-blockdiag-nose-to-pytest.patch + +------------------------------------------------------------------- +Wed Sep 1 07:28:26 UTC 2021 - pgajdos@suse.com + +- added patches + https://github.com/blockdiag/blockdiag/pull/131 + + python-blockdiag-nose-to-pytest.patch + +------------------------------------------------------------------- +Mon Aug 30 13:34:57 UTC 2021 - pgajdos@suse.com + +- %check: test the package + +------------------------------------------------------------------- +Mon Feb 24 02:11:52 UTC 2020 - Steve Kowalik + +- Update to 2.0.1: + * Drop python2 and python3.4 support + * Fix #126: '_io.BufferedRandom' object has no attribute 'buffer' + * Fix #109 blockdiag does not work with recent pillow + +------------------------------------------------------------------- +Thu Feb 28 09:38:53 UTC 2019 - Tomáš Chvátal + +- Update to 1.5.4: + * better python 3.7 compatibility + +------------------------------------------------------------------- +Wed Dec 5 01:58:19 UTC 2018 - Jan Engelhardt + +- Use noun phrase in summary. + +------------------------------------------------------------------- +Tue Dec 4 12:46:14 UTC 2018 - Matej Cepl + +- Remove superfluous devel dependency for noarch package + +------------------------------------------------------------------- +Tue Mar 6 13:27:49 UTC 2018 - aplanas@suse.com + +- Allows Recommends and Suggest in Fedora + +------------------------------------------------------------------- +Tue Feb 27 17:07:05 UTC 2018 - aplanas@suse.com + +- Recommends only for SUSE + +------------------------------------------------------------------- +Thu Apr 20 15:16:20 UTC 2017 - toddrme2178@gmail.com + +- Implement single-spec version. + +------------------------------------------------------------------- +Thu Dec 1 20:18:05 UTC 2016 - termim@gmail.com + +- use update-alternatives + +------------------------------------------------------------------- +Thu May 12 07:12:05 UTC 2016 - tbechtold@suse.com + +- update to 1.5.3: + * Fix #67 Group overlaps with nodes having href + +------------------------------------------------------------------- +Fri Jul 10 10:55:55 UTC 2015 - tbechtold@suse.com + +- Initial packaging + diff --git a/python-blockdiag.spec b/python-blockdiag.spec new file mode 100644 index 0000000..faf3cdc --- /dev/null +++ b/python-blockdiag.spec @@ -0,0 +1,97 @@ +# +# spec file for package python-blockdiag +# +# Copyright (c) 2025 SUSE LLC and contributors +# +# 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 +%{?sle15_python_module_pythons} +Name: python-blockdiag +Version: 3.0.0 +Release: 0 +Summary: Program to generate block-diagram images from text +License: Apache-2.0 +URL: http://blockdiag.com/ +Source: https://files.pythonhosted.org/packages/source/b/blockdiag/blockdiag-%{version}.tar.gz +# PATCH-FIX-UPSTREAM Based on gh#blockdiag/blockdiag#175/commits/4f4f726252084f17ecc6c524592222af09d37da4 +Patch0: python-blockdiag-nose-to-pytest.patch +# PATCH-FIX-UPSTREAM https://github.com/blockdiag/blockdiag/pull/179 Add support for Pillow 10 +Patch1: pillow10.patch +BuildRequires: %{python_module Pillow >= 3} +BuildRequires: %{python_module base >= 3.7} +BuildRequires: %{python_module funcparserlib >= 1.0.0~a0} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module webcolors} +BuildRequires: %{python_module wheel} +BuildRequires: alts +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: alts +Requires: python-Pillow >= 3 +Requires: python-funcparserlib >= 1.0.0~a0 +Requires: python-setuptools +Requires: python-webcolors +BuildArch: noarch +# SECTION test requirements +BuildRequires: %{python_module docutils} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module reportlab} +# /SECTION +%if 0%{?suse_version} || 0%{?fedora_version} >= 24 +Recommends: ghostscript +Recommends: python-Wand +Recommends: python-reportlab +%endif +%python_subpackages + +%description +The blockdiag package generates block-diagram image files +from spec-text files. + +%prep +%autosetup -p1 -n blockdiag-%{version} + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} +%python_clone -a %{buildroot}%{_bindir}/blockdiag + +%pre +# If libalternatives is used: Removing old update-alternatives entries. +%python_libalternatives_reset_alternative blockdiag + +# post and postun macro call is not needed with only libalternatives + +%check +pushd src +# other disabled tests: +# [ 9s] WARNING: Could not retrieve: http://blockdiag.com/favicon.ico +# [ 9s] WARNING: Could not retrieve: http://upload.wikimedia.org/wikipedia/commons/9/9b/Scalable_Vector_Graphics_Circle2.svg +# [ 9s] WARNING: Could not retrieve: http://people.sc.fsu.edu/~jburkardt/data/eps/circle.eps +%pytest -k 'not (test_app_cleans_up_images or test_node_attribute or test_setup_inline_svg_is_true_with_multibytes)' +popd + +%files %{python_files} +%license LICENSE +%doc CHANGES.rst README.rst +%python_alternative %{_bindir}/blockdiag +%{python_sitelib}/blockdiag +%{python_sitelib}/blockdiag-%{version}.dist-info + +%changelog