File python3-veusz.spec of Package python3-veusz

#
# spec file for package python3-veusz
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%define pyname veusz

Name:           python3-veusz
Version:        1.21.1
Release:        0
# The entire source code is GPL-2.0+ except helpers/src/_nc_cntr.c which is Python-2.0
Summary:        GUI scientific plotting package
License:        GPL-2.0+ and Python-2.0
Group:          Productivity/Scientific/Other
Url:            http://home.gna.org/veusz/
Source0:        http://download.gna.org/veusz/veusz-%{version}.tar.gz
Source3:        %{pyname}_256.png
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  libqt4-devel
BuildRequires:  python3-devel
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-qt4-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-sip
BuildRequires:  update-desktop-files
BuildRequires:  xorg-x11-server
%define         X_display         ":98"
%{?_sip_api:Requires: sip-api(%{_sip_api_major}) >= %{_sip_api}}
Requires:       python3-numpy
Requires:       python3-qt4
Provides:       %{pyname} = %{version}
Obsoletes:      python-veusz < %{version}
Provides:       python-veusz = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(post): shared-mime-info desktop-file-utils
Requires(postun): shared-mime-info desktop-file-utils

%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.

%prep
%setup -q -n %{pyname}-%{version}
find -name \*~ | xargs rm -f

%build
CFLAGS="%{optflags}"
python3 setup.py build

%install
python3 setup.py install -O1 --skip-build --prefix="%{_prefix}" \
                                   --root=%{buildroot}

# Install .desktop, mime and appdata files from upstream tarball
install -Dm0644 support/%{pyname}.appdata.xml %{buildroot}%{_datadir}/appdata/%{pyname}.appdata.xml
install -Dm0644 support/%{pyname}.xml %{buildroot}/%{_datadir}/mime/packages/%{pyname}.xml
desktop-file-install -m 0644 \
  --dir=%{buildroot}/%{_datadir}/applications/ \
  --add-category=2DGraphics \
  support/%{pyname}.desktop

# move icon files to /usr/share/pixmaps/veusz
mkdir -p %{buildroot}%{_datadir}/pixmaps/%{pyname}
mv %{buildroot}%{python3_sitearch}/%{pyname}/icons/*.png \
        %{buildroot}%{_datadir}/pixmaps/%{pyname}
mv %{buildroot}%{python3_sitearch}/%{pyname}/icons/*.svg \
        %{buildroot}%{_datadir}/pixmaps/%{pyname}
for i in `ls %{buildroot}%{_datadir}/pixmaps/%{pyname}/`; do
ln -s  %{_datadir}/pixmaps/%{pyname}/$i \
          %{buildroot}%{python3_sitearch}/%{pyname}/icons/$i ;
done
# symlink main veusz icon also into hicolor-icon-theme dir (for desktop file)
install -m 0644 %{S:3} %{buildroot}%{_datadir}/pixmaps/%{pyname}/veusz_256.png
for size in 16 32 48 64 128 256; do
    odir=%{buildroot}%{_datadir}/icons/hicolor/${size}x${size}/apps
    mkdir -p $odir
    ln -s %{_datadir}/pixmaps/%{pyname}/veusz_${size}.png ${odir}/veusz.png
done
odir=%{buildroot}%{_datadir}/icons/hicolor/scalable/apps
mkdir -p $odir
ln -s %{_datadir}/pixmaps/%{pyname}/veusz.svg $odir

# 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 %{buildroot}%{python3_sitearch}/veusz/veusz_main.py
chmod +x %{buildroot}%{python3_sitearch}/veusz/veusz_listen.py

# install man pages
mkdir -p %{buildroot}%{_mandir}/man1
install -p Documents/veusz.1 Documents/veusz_listen.1 -m 0644 \
        %{buildroot}%{_mandir}/man1

install -m0644 COPYING %{buildroot}%{python3_sitearch}/%{pyname}/

%check
# Problems connectiong to xserver for openSUSE 12.2 and below
%if 0%{?suse_version} > 1220
export DISPLAY=%{X_display}
Xvfb %{X_display} >& Xvfb.log &
sleep 5
PYTHONPATH=%{buildroot}%{python3_sitearch} \
           python3 tests/runselftest.py
%endif

%fdupes -s %{buildroot}%{python3_sitearch}
%fdupes %{buildroot}%{_datadir}/pixmaps/%{pyname}/

%post
update-mime-database %{_datadir}/mime > /dev/null 2>&1 || :
update-desktop-database %{_datadir}/applications
%icon_theme_cache_post

%postun
update-mime-database %{_datadir}/mime > /dev/null 2>&1 || :
update-desktop-database %{_datadir}/applications
%icon_theme_cache_postun

%files
%defattr(-,root,root)
%doc README AUTHORS COPYING ChangeLog
%doc Documents/manual.html
%doc Documents/manimages/
%{_bindir}/veusz
%{_bindir}/veusz_listen
%{_datadir}/applications/%{pyname}.desktop
%{_datadir}/mime/packages/%{pyname}.xml
%{_datadir}/pixmaps/veusz/
%dir %{_datadir}/appdata
%{_datadir}/appdata/%{pyname}.appdata.xml
%{python3_sitearch}/%{pyname}-%{version}-py%{py3_ver}.egg-info
%{python3_sitearch}/%{pyname}/
%{_datadir}/icons/hicolor/*/apps/%{pyname}.*
%{_mandir}/man1/*

%changelog
openSUSE Build Service is sponsored by