Blob Blame History Raw
%global sum Image Viewer and Toolkit
%global common_desc                                                           \
Ginga is a toolkit designed for building viewers for scientific image data in \
Python, visualizing 2D pixel data in numpy arrays. It can view astronomical   \
data such as contained in files based on the FITS (Flexible Image Transport   \
System) file format. It is written and is maintained by software engineers at \
the Subaru Telescope, National Astronomical Observatory of Japan.             \
                                                                              \
The Ginga toolkit centers around an image display class which supports zooming\
and panning, color and intensity mapping, a choice of several automatic cut   \
levels algorithms and canvases for plotting scalable geometric forms. In      \
addition to this widget, a general purpose “reference” FITS viewer is         \
provided, based on a plugin framework. A fairly complete set of standard      \
plugins are provided for features that we expect from a modern FITS viewer:   \
panning and zooming windows, star catalog access, cuts, star pick/fwhm,       \
thumbnails, etc.

Name:           ginga
Version:        2.6.1
Release:        1%{?dist}
Summary:        %{sum}
# License breakdown
#
# In general (if not listed below): BSD
#
# Apache 2.0
#   astropy_helpers/astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.css
#   ginga/util/heaptimer.py
# 
# MIT/X11
#   ginga/util/six.py
#
License:        BSD and ASL 2.0 and MIT
URL:            https://ejeschke.github.io/ginga/
Source0:        https://files.pythonhosted.org/packages/source/g/%{name}/%{name}-%{version}.tar.gz

# General build reqs
BuildRequires:  desktop-file-utils
BuildRequires:  fontpackages-devel
BuildRequires:  google-roboto-fonts
# Python 2 build reqs
BuildRequires:  python2-astropy
BuildRequires:  python2-astropy-helpers
BuildRequires:  python2-devel
BuildRequires:  python2-matplotlib-qt5
BuildRequires:  python2-qt5
BuildRequires:  python2-scipy
# Python 3 build reqs
BuildRequires:  python3-astropy
BuildRequires:  python3-astropy-helpers
BuildRequires:  python3-devel
BuildRequires:  python3-matplotlib-qt5
BuildRequires:  python3-qt5
BuildRequires:  python3-scipy

Requires:       python3-%{name} = %{version}-%{release}

BuildArch:      noarch

%description
%{common_desc}

%package -n python2-%{name}
Summary:        %{sum}
%{?python_provide:%python_provide python2-%{name}}
Requires:       google-roboto-fonts
Requires:       python2-astropy
Requires:       python2-matplotlib-qt5
Requires:       python2-qt5
Requires:       python2-scipy

%description -n python2-%{name}
%{common_desc}

%package -n python2-%{name}-examples
Summary:        Examples for %{name}
%{?python_provide:%python_provide python2-%{name}-examples}
Requires:       python2-%{name} = %{version}-%{release}

%description -n python2-%{name}-examples
Examples for %{name}

%package -n python3-%{name}
Summary:        %{sum}
%{?python_provide:%python_provide python3-%{name}}
Requires:       google-roboto-fonts
Requires:       python3-astropy
Requires:       python3-matplotlib-qt5
Requires:       python3-qt5
Requires:       python3-scipy

%description -n python3-%{name}
%{common_desc}

%package -n python3-%{name}-examples
Summary:        Examples for %{name}
%{?python_provide:%python_provide python3-%{name}-examples}
Requires:       python3-%{name} = %{version}-%{release}

%description -n python3-%{name}-examples
Examples for %{name}


%prep
%autosetup
cp -r ginga/examples examples-py2
cp -r ginga/examples examples-py3
# Fix wrong Python interpreters (upstream uses env)
find examples-py2 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python2}|'
find examples-py3 -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python3}|'

%build
%py2_build
%py3_build

%install
# Must do the python2 install first because the scripts in /usr/bin are
# overwritten with every setup.py install, and in general we want the
# python3 version to be the default.
%py2_install
%py3_install
desktop-file-install                                    \
     --dir=%{buildroot}%{_datadir}/applications         \
     %{name}.desktop

# Replace bundled fonts with symlinks to system fonts
# python2-ginga
rm -f %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/*
ln -sf %{_fontbasedir}/google-roboto/Roboto-Black.ttf %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/Roboto-Black.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Bold.ttf %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/Roboto-Bold.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Light.ttf %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/Roboto-Light.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Medium.ttf %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/Roboto-Medium.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Regular.ttf %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/Roboto-Regular.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Thin.ttf %{buildroot}/%{python2_sitelib}/%{name}/fonts/Roboto/Roboto-Thin.ttf
# python3-ginga
rm -f %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/*
ln -sf %{_fontbasedir}/google-roboto/Roboto-Black.ttf %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/Roboto-Black.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Bold.ttf %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/Roboto-Bold.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Light.ttf %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/Roboto-Light.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Medium.ttf %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/Roboto-Medium.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Regular.ttf %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/Roboto-Regular.ttf
ln -sf %{_fontbasedir}/google-roboto/Roboto-Thin.ttf %{buildroot}/%{python3_sitelib}/%{name}/fonts/Roboto/Roboto-Thin.ttf

# ginga/web/pgw/ipg.py has wrong permissions
chmod 755 %{buildroot}/%{python2_sitelib}/%{name}/web/pgw/ipg.py
chmod 755 %{buildroot}/%{python2_sitelib}/%{name}/util/mosaic.py
chmod 755 %{buildroot}/%{python3_sitelib}/%{name}/web/pgw/ipg.py
chmod 755 %{buildroot}/%{python3_sitelib}/%{name}/util/mosaic.py

# Fix wrong interpreters in some scripts...
find %{buildroot}/%{python2_sitelib}/%{name} -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python2}|'
find %{buildroot}/%{python3_sitelib}/%{name} -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python3}|'

%post
/usr/bin/update-desktop-database &> /dev/null || :
/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :

%postun
/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 || :


%files
%license licenses/LICENSE.txt
%doc README.txt
%{_bindir}/*
%{_datadir}/applications/%{name}.desktop

%files -n python2-%{name}
%license licenses/LICENSE.txt
%doc README.txt
%{python2_sitelib}/*
# Examples are shipped as documentation in examples subpackage
%exclude %{python2_sitelib}/%{name}/examples

%files -n python2-%{name}-examples
%license licenses/LICENSE.txt
%doc examples-py2/*

%files -n python3-%{name}
%license licenses/LICENSE.txt
%doc README.txt
%{python3_sitelib}/*
# Examples are shipped as documentation in examples subpackage
%exclude %{python3_sitelib}/%{name}/examples

%files -n python3-%{name}-examples
%license licenses/LICENSE.txt
%doc examples-py3/*

%changelog
* Sun Jan 01 2017 Christian Dersch <lupinix@mailbox.org> - 2.6.1-1
- new version

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 2.6.0-2
- Rebuild for Python 3.6

* Wed Nov 30 2016 Christian Dersch <lupinix@mailbox.org> - 2.6.0-1
- new version

* Sat Oct 22 2016 Christian Dersch <lupinix@mailbox.org> - 2.5.20161005204600-1
- new version
- unbundled fonts
- fixed interpreters for scripts to use correct Python version

* Sun Oct  2 2016 Christian Dersch <lupinix@mailbox.org> - 2.5.20160926130800-1
- initial package