From 26b39ec8cf058ad721b9d7956382cccb5a03796598ff15e97bee8b18e12faca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 18 May 2020 09:10:22 +0000 Subject: [PATCH] - Add patch no-builddir-freetype.patch to not require freetype in build/ subfolder which we use in python macros * This is SUSE specific patch - Make the package multibuild and execute the testsuite OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-matplotlib?expand=0&rev=28 --- _multibuild | 3 ++ freetype-2.6.1.tar.gz | 3 ++ no-builddir-freetype.patch | 30 ++++++++++++++++ python-matplotlib.changes | 8 +++++ python-matplotlib.spec | 72 ++++++++++++++++++++++---------------- 5 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 _multibuild create mode 100644 freetype-2.6.1.tar.gz create mode 100644 no-builddir-freetype.patch diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/freetype-2.6.1.tar.gz b/freetype-2.6.1.tar.gz new file mode 100644 index 0000000..756465e --- /dev/null +++ b/freetype-2.6.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a3c7dfbda6da1e8fce29232e8e96d987ababbbf71ebc8c75659e4132c367014 +size 2302080 diff --git a/no-builddir-freetype.patch b/no-builddir-freetype.patch new file mode 100644 index 0000000..5112038 --- /dev/null +++ b/no-builddir-freetype.patch @@ -0,0 +1,30 @@ +Index: matplotlib-3.2.1/setupext.py +=================================================================== +--- matplotlib-3.2.1.orig/setupext.py ++++ matplotlib-3.2.1/setupext.py +@@ -514,7 +514,7 @@ class FreeType(SetupPackage): + ext.sources.insert(0, 'src/checkdep_freetype2.c') + if options.get('local_freetype'): + src_path = pathlib.Path( +- 'build', f'freetype-{LOCAL_FREETYPE_VERSION}') ++ f'freetype-{LOCAL_FREETYPE_VERSION}') + # Statically link to the locally-built freetype. + # This is certainly broken on Windows. + ext.include_dirs.insert(0, str(src_path / 'include')) +@@ -541,7 +541,7 @@ class FreeType(SetupPackage): + if not options.get('local_freetype'): + return + +- src_path = pathlib.Path('build', f'freetype-{LOCAL_FREETYPE_VERSION}') ++ src_path = pathlib.Path(f'freetype-{LOCAL_FREETYPE_VERSION}') + + # We've already built freetype + if sys.platform == 'win32': +@@ -555,7 +555,6 @@ class FreeType(SetupPackage): + + # do we need to download / load the source from cache? + if not src_path.exists(): +- os.makedirs('build', exist_ok=True) + + url_fmts = [ + ('https://downloads.sourceforge.net/project/freetype' diff --git a/python-matplotlib.changes b/python-matplotlib.changes index 4ba0d96..aa52a9f 100644 --- a/python-matplotlib.changes +++ b/python-matplotlib.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon May 18 08:45:00 UTC 2020 - Tomáš Chvátal + +- Add patch no-builddir-freetype.patch to not require freetype + in build/ subfolder which we use in python macros + * This is SUSE specific patch +- Make the package multibuild and execute the testsuite + ------------------------------------------------------------------- Mon May 18 06:56:24 UTC 2020 - Tomáš Chvátal diff --git a/python-matplotlib.spec b/python-matplotlib.spec index e2dece6..1fd2626 100644 --- a/python-matplotlib.spec +++ b/python-matplotlib.spec @@ -17,12 +17,18 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} -%define oldpython python %define skip_python2 1 # Not doing tests because they take too long # The tests also pull in dependencies of all backends done in pure python -%bcond_with tests -Name: python-matplotlib +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif +Name: python-matplotlib%{psuffix} Version: 3.2.1 Release: 0 Summary: Plotting Library for Python @@ -30,6 +36,9 @@ License: SUSE-Matplotlib URL: https://matplotlib.org Source: https://files.pythonhosted.org/packages/source/m/matplotlib/matplotlib-%{version}.tar.gz Source1: matplotlib-setup.cfg +# Bundled version of freetype for testing purposes only +Source99: https://downloads.sourceforge.net/project/freetype/freetype2/2.6.1/freetype-2.6.1.tar.gz +Patch0: no-builddir-freetype.patch BuildRequires: %{python_module Cycler >= 0.10} BuildRequires: %{python_module devel} BuildRequires: %{python_module kiwisolver} @@ -66,12 +75,11 @@ BuildRequires: pkgconfig(freetype2) >= 2.3 BuildRequires: pkgconfig(libpng) >= 1.2 BuildRequires: pkgconfig(tcl) # /SECTION -%if %{with tests} -# SECTION testing dependencies +%if %{with test} BuildRequires: %{python_module mock} -BuildRequires: %{python_module nose} +BuildRequires: %{python_module pytest-xdist} +BuildRequires: %{python_module pytest} BuildRequires: %{python_module python-dateutil >= 2.1} -# /SECTION # SECTION cairo dependencies BuildRequires: %{python_module cairo} # SECTION GTK3 dependencies @@ -79,7 +87,7 @@ BuildRequires: %{python_module gobject} # /SECTION # SECTION Qt5 dependencies BuildRequires: %{python_module qt5} -BuildRequires: xorg-x11-Xvfb +BuildRequires: xvfb-run BuildRequires: pkgconfig(gtk+-3.0) # /SECTION # SECTION tk dependencies @@ -105,11 +113,7 @@ BuildRequires: tex(type1cm.sty) BuildRequires: tex(ucs.sty) # /SECTION %endif -%if 0%{?suse_version} >= 1500 Recommends: (python-matplotlib-tk if tk) -%else -Recommends: python-matplotlib-tk -%endif %python_subpackages %description @@ -197,28 +201,29 @@ This package includes the wxWidgets-based wxagg backend for %{name} plotting package %prep -%setup -q -n matplotlib-%{version} +%setup -q -n matplotlib-%{version} -a99 chmod -x lib/matplotlib/mpl-data/images/*.svg find examples lib/matplotlib lib/mpl_toolkits/mplot3d -type f -name "*.py" -exec sed -i "s|#!\/usr\/bin\/env python||" {} \; find examples lib/matplotlib lib/mpl_toolkits/mplot3d -type f -name "*.py" -exec sed -i "s|#!\/usr\/bin\/python||" {} \; -cp %{SOURCE1} ./setup.cfg +cp %{SOURCE1} setup.cfg -%if %{without tests} -sed -i -e 's/tests = .*/tests = False/' ./setup.cfg +%patch0 -p1 + +%if !%{with test} +sed -i -e 's/tests = .*/tests = False/' setup.cfg %else -# raise tolerance for changes due to freetype 2.6/2.7 rendering differences -sed -i -e 's/\(image_comparison.*\)tol=0/\1tol=0.310/' lib/matplotlib/testing/decorators.py # default -sed -i -e 's/tol=0.002/tol=0.009/' lib/matplotlib/tests/test_streamplot.py -sed -i -e 's/tol=0.*)/tol=0.012)/' lib/matplotlib/tests/test_png.py -# image rotation is broken, investigate -sed -i -e 's/\(image_comparison.*rotate_image.*\)/\1 tol=150,/' lib/matplotlib/tests/test_image.py +# As freetype changes the behaviour slightly for tests always use the bundled freetype +sed -i -e 's:#local_freetype = False:local_freetype = True:' setup.cfg %endif %build +%if !%{with test} export XDG_RUNTIME_DIR=/tmp %python_build +%endif %install +%if !%{with test} export XDG_RUNTIME_DIR=/tmp %python_install %{python_expand %fdupes %{buildroot}%{$python_sitearch} @@ -226,15 +231,21 @@ $python -m compileall -d %{$python_sitearch} %{buildroot}%{$python_sitearch}/mat $python -O -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitearch}/matplotlib/backends/qt_editor/ %fdupes %{buildroot}%{$python_sitearch}/matplotlib/backends/qt_editor/ } - -%if %{with tests} -%check -export DISPLAY=:42 -%{_bindir}/Xvfb :42 -screen 0 1024x768x24 >& /tmp/Xvfb.log & -trap "kill $! || true" EXIT -%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python ./tests.py --no-network --recursionlimit=5000 %endif +%if %{with test} +%check +# test_savefig_to_stringio - generated ps is differing a bit +# test_interactive_backend - needs full X session +# test_bbox_inches_tight_raster - resulting PNGs look differently +# test_backend_fallback_headful - fails to detect X session with xvfb +# test_usetex - png differs +export XDG_RUNTIME_DIR=/tmp +%python_exec setup.py build_ext --inplace +%python_expand PYTHONPATH=./lib xvfb-run $python -m pytest -v -n auto -k 'not (test_savefig_to_stringio or test_interactive_backend or test_bbox_inches_tight_raster or test_backend_fallback_headful or test_usetex)' +%endif + +%if !%{with test} %files %{python_files} %doc README.rst %doc examples/ @@ -264,7 +275,6 @@ trap "kill $! || true" EXIT %exclude %{python_sitearch}/matplotlib/backends/tkagg.* %exclude %{python_sitearch}/matplotlib/backends/web_backend/ %exclude %{python_sitearch}/matplotlib/backends/wx_compat.* -%ifpycache %exclude %{python_sitearch}/matplotlib/backends/__pycache__/backend_cairo.*.py* %exclude %{python_sitearch}/matplotlib/backends/__pycache__/backend_gtk3.*.py* %exclude %{python_sitearch}/matplotlib/backends/__pycache__/backend_gtk3agg.*.py* @@ -281,7 +291,6 @@ trap "kill $! || true" EXIT %exclude %{python_sitearch}/matplotlib/backends/__pycache__/qt_compat.*.py* %exclude %{python_sitearch}/matplotlib/backends/__pycache__/tkagg.*.py* %exclude %{python_sitearch}/matplotlib/backends/__pycache__/wx_compat.*.py* -%endif # Dummy package to pull in latex dependencies. %files %{python_files latex} @@ -337,5 +346,6 @@ trap "kill $! || true" EXIT %{python_sitearch}/matplotlib/backends/backend_wxagg.py* %pycache_only %{python_sitearch}/matplotlib/backends/__pycache__/backend_wx.*.py* %pycache_only %{python_sitearch}/matplotlib/backends/__pycache__/backend_wxagg.*.py* +%endif %changelog