[veusz] Update to Veusz 1.14. Also clean up spec file substantially, filter provides, move data files to /us

Jeremy Sanders jsanders at fedoraproject.org
Sun Nov 27 17:40:53 UTC 2011


commit e0f9c2c7941ab8208315243f318babb97d0c2026
Author: Jeremy Sanders <jeremy at jeremysanders.net>
Date:   Sun Nov 27 17:38:46 2011 +0000

    Update to Veusz 1.14. Also clean up spec file substantially, filter provides, move data files to /usr/share, install hicolor icons and use upstreamed-patch to fix location of installed files rather than our own patches.

 .gitignore              |    1 +
 sources                 |    2 +-
 veusz-fhs-support.patch |  131 ++++++++++++++++++++++++++++++++
 veusz.desktop           |    5 +-
 veusz.spec              |  192 +++++++++++++++++++++++++----------------------
 5 files changed, 236 insertions(+), 95 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 105c0c1..028d04d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ veusz-1.8.tar.gz
 /veusz-1.11.tar.gz
 /veusz-1.12.tar.gz
 /veusz-1.13.tar.gz
+/veusz-1.14.tar.gz
diff --git a/sources b/sources
index 9caa25b..71f85b1 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-081eab85b51fcc7e1ad1d27cd37d53ef  veusz-1.13.tar.gz
+13c5e5d9105384e6d0cfcb3163ede4b9  veusz-1.14.tar.gz
diff --git a/veusz-fhs-support.patch b/veusz-fhs-support.patch
new file mode 100644
index 0000000..0807126
--- /dev/null
+++ b/veusz-fhs-support.patch
@@ -0,0 +1,131 @@
+diff --git a/setup.py b/setup.py
+index 30488c8..c2869ea 100644
+--- a/setup.py
++++ b/setup.py
+@@ -28,6 +28,7 @@ import os.path
+ import sys
+ import numpy
+ from distutils.command.install_data import install_data
++from distutils.command.install import install as orig_install
+ import pyqtdistutils
+ 
+ # try to get py2app if it exists
+@@ -42,15 +43,41 @@ except ImportError:
+ # get version
+ version = open('VERSION').read().strip()
+ 
++class install(orig_install):
++    user_options = orig_install.user_options + [
++        # tell veusz where to install its data files
++        ('veusz-resource-dir=', None,
++         'override veusz resource directory location'),
++        ('disable-install-examples', None,
++         'do not install examples files'),
++        ]
++    boolean_options = orig_install.boolean_options + [
++        'disable-install-examples']
++
++    def initialize_options(self):
++        orig_install.initialize_options(self)
++        self.veusz_resource_dir = None
++        self.disable_install_examples = False
++
+ # Pete Shinner's distutils data file fix... from distutils-sig
+ #  data installer with improved intelligence over distutils
+ #  data files are copied into the project directory instead
+ #  of willy-nilly
+ class smart_install_data(install_data):   
+     def run(self):
+-        # need to change self.install_dir to the library dir
+         install_cmd = self.get_finalized_command('install')
+-        self.install_dir = getattr(install_cmd, 'install_lib')
++        if install_cmd.veusz_resource_dir:
++            # override location with veusz-resource-dir option
++            self.install_dir = install_cmd.veusz_resource_dir
++        else:
++            # change self.install_dir to the library dir + veusz by default
++            self.install_dir = os.path.join(install_cmd.install_lib, 'veusz')
++
++        # disable examples install if requested
++        if install_cmd.disable_install_examples:
++            self.data_files = [f for f in self.data_files
++                               if f[0][-8:] != 'examples']
++
+         return install_data.run(self)
+ 
+ descr = '''Veusz is a scientific plotting package, designed to create
+@@ -96,7 +123,7 @@ def findData(dirname, extns):
+     for extn in extns:
+         files += glob.glob(os.path.join(dirname, '*.'+extn))
+     files.sort()
+-    return ( os.path.join('veusz', dirname), files )
++    return (dirname, files)
+ 
+ setup(name = 'veusz',
+       version = version,
+@@ -125,7 +152,7 @@ setup(name = 'veusz',
+                       'veusz.widgets': 'widgets',
+                       'veusz.windows': 'windows',
+                       },
+-      data_files = [ ('veusz', ['VERSION']),
++      data_files = [ ('', ['VERSION']),
+                      findData('dialogs', ('ui',)),
+                      findData('windows/icons', ('png', 'svg')),
+                      findData('examples', ('vsz', 'py', 'csv', 'dat')),
+@@ -166,7 +193,8 @@ setup(name = 'veusz',
+         ],
+                                 
+       cmdclass = {'build_ext': pyqtdistutils.build_ext,
+-                  'install_data': smart_install_data },
++                  'install_data': smart_install_data,
++                  'install': install},
+ 
+       **extraoptions
+       )
+diff --git a/utils/utilfuncs.py b/utils/utilfuncs.py
+index b468213..792bf04 100644
+--- a/utils/utilfuncs.py
++++ b/utils/utilfuncs.py
+@@ -35,23 +35,32 @@ class IgnoreException(Exception):
+     """A special exception class to be ignored by the exception handler."""
+ 
+ def _getVeuszDirectory():
+-    """Get installed directory to find files relative to this one."""
++    """Get resource and examples directories for Veusz."""
+ 
+     if hasattr(sys, 'frozen'):
+         # for pyinstaller/py2app compatability
+-        dirname = os.path.dirname(os.path.abspath(sys.executable))
++        resdir = os.path.dirname(os.path.abspath(sys.executable))
+         if sys.platform == 'darwin':
+-            # py2app
+-            return os.path.join(dirname, '..', 'Resources', 'veusz')
+-        else:
+-            # pyinstaller
+-            return dirname
++            # special case for py2app
++            resdir = os.path.join(resdir, '..', 'Resources', 'veusz')
+     else:
+         # standard installation
+-        return os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
++        resdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
++
++    # override data directory with symlink
++    if os.path.exists( os.path.join(resdir, 'resources') ):
++        resdir = os.path.realpath( os.path.join(resdir, 'resources') )
++
++    # override with VEUSZ_RESOURCE_DIR environment variable if necessary
++    resdir = os.environ.get('VEUSZ_RESOURCE_DIR', resdir)
++
++    # now get example directory (which may be a symlink)
++    examplesdir = os.path.realpath( os.path.join(resdir, 'examples') )
++
++    return resdir, examplesdir
+ 
+-veuszDirectory = _getVeuszDirectory()
+-exampleDirectory = os.path.join(veuszDirectory, 'examples')
++# get resource and example directories
++veuszDirectory, exampleDirectory = _getVeuszDirectory()
+ 
+ id_re = re.compile('^[A-Za-z_][A-Za-z0-9_]*$')
+ def validPythonIdentifier(name):
diff --git a/veusz.desktop b/veusz.desktop
index c298b73..af13ac4 100644
--- a/veusz.desktop
+++ b/veusz.desktop
@@ -1,12 +1,11 @@
 [Desktop Entry]
 Encoding=UTF-8
 Name=Veusz
-GenericName=Veusz scientific plotting
-Comment=Open .vsz scientific plotting files
+GenericName=Scientific plotting
+Comment=Create and edit scientific plots and graphs
 MimeType=application/x-veusz
 Exec=veusz %F
 Icon=veusz
 Terminal=false
 Type=Application
 Categories=Graphics;
-
diff --git a/veusz.spec b/veusz.spec
index 608938c..c142cd3 100644
--- a/veusz.spec
+++ b/veusz.spec
@@ -1,9 +1,5 @@
-%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
-%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
-%{!?python_siteinc: %define python_siteinc %(%{__python} -c "from distutils.sysconfig import get_python_inc; print get_python_inc()")}
-
 Name:           veusz
-Version:        1.13
+Version:        1.14
 Release:        1%{?dist}
 Summary:        GUI scientific plotting package
 
@@ -14,100 +10,133 @@ URL:            http://home.gna.org/veusz/
 Source0:        http://download.gna.org/veusz/veusz-%{version}.tar.gz
 Source1:        %{name}.desktop
 Source2:        %{name}.xml
+# allow data directories to be put in _datadir
+# applied upstream: https://github.com/jeremysanders/veusz/issues/15
+Patch0:         veusz-fhs-support.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
-BuildRequires:  python-devel desktop-file-utils numpy
+BuildRequires:  python2-devel
+BuildRequires:  python-setuptools-devel
+BuildRequires:  numpy
 BuildRequires:  PyQt4-devel qt-devel sip-devel
-%{?_sip_api:Requires: sip-api(%{_sip_api_major}) >= %{_sip_api}}
 BuildRequires:  xorg-x11-server-Xvfb xorg-x11-xauth
+BuildRequires:  desktop-file-utils
 
+%{?_sip_api:Requires: sip-api(%{_sip_api_major}) >= %{_sip_api}}
 Requires:       numpy PyQt4 /usr/bin/env
 Provides:       python-veusz
 
-# for eggs
-%if 0%{?fedora} >= 8
-BuildRequires:  python-setuptools-devel
-%else
-BuildRequires:  python-setuptools
-%endif
+# we don't want to provide private python extension libs
+# https://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering
+%{?filter_setup:
+%filter_provides_in %{python_sitearch}/veusz/helpers/.*\.so$
+%filter_setup
+}
 
 %description
 Veusz is a scientific plotting package, designed to create
 publication-ready Postscript/PDF/SVG output. It features GUI,
 command-line, and scripting interfaces. Graphs are constructed from
 widgets, allowing complex layouts to be designed. Veusz supports
-plotting functions, data with errors, keys, labels, stacked plots,
-multiple plots, contours, shapes and fitting data.
+plotting functions, data with error bars, keys, labels, stacked plots,
+ternary plots, vector plots, contours, images, shapes and fitting
+data.
 
 %prep
 %setup -q -n veusz-%{version}
 find -name \*~ | xargs rm -f
 
-# change path of where to lookup bitmaps
-# this is so we can move the icons out of the python directory
-# and into /usr/share/pixmaps/veusz
-sed -i "/imagedir =/c\\imagedir = '%{_datadir}/pixmaps/veusz'" \
-        ${RPM_BUILD_DIR}/veusz-%{version}/utils/action.py
+%patch0 -p1 -b .fhs-support
 
 # change path of where to look for COPYING - should be docdir
-sed -i "/f =/s+utils.veuszDirectory+'%{_docdir}/veusz-%{version}'+" \
-	${RPM_BUILD_DIR}/veusz-%{version}/dialogs/aboutdialog.py
+sed -i "/COPYING/s@=.*@=open('%{vdoc}/COPYING', 'rU')@"  \
+    dialogs/aboutdialog.py
+
+# remove shebangs from scripts which aren't installed
+# (veusz allows these to be executed if app isn't installed properly)
+sed -i '/^#!/d' veusz_main.py
+sed -i '/^#!/d' veusz_listen.py
 
 %build
 CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
 
 %install
-rm -rf $RPM_BUILD_ROOT
-%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
-%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
+rm -rf %{buildroot}
+
+# veusz-resource-dir: put data files in location given
+%{__python} setup.py install --skip-build --root %{buildroot} \
+    --veusz-resource-dir=%{buildroot}/%{_datadir}/veusz \
+    --disable-install-examples
+
+# tell veusz where its resource directory is in _datadir
+ln -s %{_datadir}/veusz \
+    %{buildroot}%{python_sitearch}/veusz/resources
+
+# tell it where to look for examples
+ln -s %{_defaultdocdir}/%{name}-%{version}/examples \
+    %{buildroot}%{_datadir}/veusz
 
 # install desktop file
-desktop-file-install --vendor fedora                            \
-        --dir ${RPM_BUILD_ROOT}%{_datadir}/applications         \
-        --add-category X-Red-Hat-Extra                          \
-        %{SOURCE1}
+desktop-file-install  \
+    --dir %{buildroot}%{_datadir}/applications \
+    %{SOURCE1}
 
 # file to register .vsz mimetype
-mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/mime/packages/
-cp %{SOURCE2} ${RPM_BUILD_ROOT}%{_datadir}/mime/packages/
-
-# move icon files to /usr/share/pixmaps/veusz
-# symlink main veusz icon also into pixmaps (for desktop file)
-mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/pixmaps/veusz
-mv ${RPM_BUILD_ROOT}%{python_sitearch}/veusz/windows/icons/*.png \
-        ${RPM_BUILD_ROOT}%{_datadir}/pixmaps/veusz
-mv ${RPM_BUILD_ROOT}%{python_sitearch}/veusz/windows/icons/*.svg \
-        ${RPM_BUILD_ROOT}%{_datadir}/pixmaps/veusz
-ln -s veusz/veusz_48.png ${RPM_BUILD_ROOT}%{_datadir}/pixmaps/veusz.png
-
-# Mark some scripts as executable.
-# This isn't really needed, but Veusz includes shebangs in scripts
-# so that they can be run when not installed.
-# Do this so that the scripts don't need modification.
-chmod +x ${RPM_BUILD_ROOT}%{python_sitearch}/veusz/veusz_main.py
-chmod +x ${RPM_BUILD_ROOT}%{python_sitearch}/veusz/veusz_listen.py
+mkdir -p %{buildroot}%{_datadir}/mime/packages/
+cp %{SOURCE2} %{buildroot}%{_datadir}/mime/packages/
+
+# symlink main veusz icon into pixmaps (for desktop file)
+mkdir %{buildroot}%{_datadir}/pixmaps
+ln -s ../veusz/windows/icons/veusz_48.png \
+    %{buildroot}%{_datadir}/pixmaps/veusz.png
+
+# also link in hicolor icons
+for size in 16 32 48 64 128; do
+    odir=%{buildroot}%{_datadir}/icons/hicolor/${size}x${size}/apps
+    mkdir -p $odir
+    ln -s %{_datadir}/veusz/windows/icons/veusz_${size}.png ${odir}/veusz.png
+done
+odir=%{buildroot}%{_datadir}/icons/hicolor/scalable/apps
+mkdir -p $odir
+ln -s %{_datadir}/veusz/windows/icons/veusz.svg $odir
 
 # install man pages
-mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1
+mkdir -p %{buildroot}%{_mandir}/man1
 install -p Documents/veusz.1 Documents/veusz_listen.1 -m 0644 \
-        ${RPM_BUILD_ROOT}%{_mandir}/man1
+    %{buildroot}%{_mandir}/man1
 
 %check
 # self test has to run in X environment
-PYTHONPATH=${RPM_BUILD_ROOT}%{python_sitearch} xvfb-run \
-        --server-args "-screen 0 640x480x24" \
-        python tests/runselftest.py
+# as the data directory hasn't got the same absolute path we have
+# to define VEUSZ_RESOURCE_DIR
+PYTHONPATH=%{buildroot}%{python_sitearch} \
+    VEUSZ_RESOURCE_DIR=%{buildroot}%{_datadir}/veusz \
+    xvfb-run \
+    --auto-servernum \
+    --server-args "-screen 0 640x480x24" \
+    python tests/runselftest.py
 
 %post
-update-mime-database %{_datadir}/mime > /dev/null 2>&1 || :
-update-desktop-database &> /dev/null || :
+# see http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#mimeinfo
+/usr/bin/update-mime-database %{_datadir}/mime > /dev/null 2>&1 || :
+# http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#desktop-database
+/usr/bin/update-desktop-database &> /dev/null || :
+# http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Icon_Cache
+/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
 
 %postun
-update-mime-database %{_datadir}/mime > /dev/null 2>&1 || :
-update-desktop-database &> /dev/null || :
+/usr/bin/update-mime-database %{_datadir}/mime > /dev/null 2>&1 || :
+/usr/bin/update-desktop-database &> /dev/null || :
+if [ $1 -eq 0 ] ; then
+    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null
+    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+fi
+
+%posttrans
+/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 
 %clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
 %files
 %defattr(-,root,root,-)
@@ -115,43 +144,24 @@ rm -rf $RPM_BUILD_ROOT
 %doc examples
 %doc Documents/manual.html
 %doc Documents/manimages
-%{_bindir}/veusz
-%{_bindir}/veusz_listen
-%{_datadir}/applications/fedora-%{name}.desktop
-%{_datadir}/mime/packages/veusz.xml
-%dir %{python_sitearch}/veusz
-%{python_sitearch}/veusz-*egg-info
-%{python_sitearch}/veusz/VERSION
-%{python_sitearch}/veusz/*.py
-%{python_sitearch}/veusz/*.py[co]
-%{python_sitearch}/veusz/dialogs/*.py
-%{python_sitearch}/veusz/dialogs/*.py[co]
-%{python_sitearch}/veusz/dialogs/*.ui
-%{python_sitearch}/veusz/document/*.py
-%{python_sitearch}/veusz/document/*.py[co]
-%{python_sitearch}/veusz/helpers/*.py
-%{python_sitearch}/veusz/helpers/*.py[co]
-%{python_sitearch}/veusz/helpers/*.so
-%{python_sitearch}/veusz/plugins/*.py
-%{python_sitearch}/veusz/plugins/*.py[co]
-%{python_sitearch}/veusz/qtwidgets/*.py
-%{python_sitearch}/veusz/qtwidgets/*.py[co]
-%{python_sitearch}/veusz/setting/*.py
-%{python_sitearch}/veusz/setting/*.py[co]
-%{python_sitearch}/veusz/utils/*.py
-%{python_sitearch}/veusz/utils/*.py[co]
-%{python_sitearch}/veusz/widgets/*.py
-%{python_sitearch}/veusz/widgets/*.py[co]
-%{python_sitearch}/veusz/widgets/data/colormaps.dat
-%{python_sitearch}/veusz/windows/*.py
-%{python_sitearch}/veusz/windows/*.py[co]
-%dir %{_datadir}/pixmaps/veusz
-%{_datadir}/pixmaps/veusz/*.png
-%{_datadir}/pixmaps/veusz/*.svg
-%{_datadir}/pixmaps/veusz.png
+%{_bindir}/*
 %{_mandir}/man1/*
+%{_datadir}/applications/*
+%{_datadir}/mime/packages/*
+%{_datadir}/pixmaps/*
+%{_datadir}/icons/hicolor/*/apps/*
+%{_datadir}/veusz
+%{python_sitearch}/veusz-*.egg-info
+%{python_sitearch}/veusz
 
 %changelog
+* Sun Nov 27 2011 Jeremy Sanders <jeremy at jeremysanders.net> - 1.14-1
+- Update to Veusz 1.14
+- Significant simplifications of spec file
+- Install all data files in _datadir/veusz
+- Add icons to hicolor theme
+- Filter provides from private python modules
+
 * Mon Aug 22 2011 Jeremy Sanders <jeremy at jeremysanders.net> - 1.13-1
 - Update to Veusz 1.13
 


More information about the scm-commits mailing list