File python3-rnginline.spec of Package python3-rnginline

#
# spec file for package python3-rnginline
#
# Copyright (c) 2016 SUSE LINUX 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 rng     rnginline

Name:           python3-rnginline
Version:        0.0.2
Release:        0
Summary:        Library/tool to flatten multi-file RELAX NG Schemas
License:        Apache-2.0
Group:          Development/Languages/Python
Url:            https://github.com/h4l/rnginline
Source:         https://pypi.python.org/packages/6d/41/6d8e6a1259ed386fb88f9961eff46c9c0edef614147b9b4c7ac057c375e2/rnginline-%{version}.tar.gz
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Requires:       python3-setuptools
Requires:       python3-docopt
Requires:       python3-lxml
Requires:       python3-six
BuildRequires:  fdupes
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch

%description
rnginline is a Python library and command-line tool for loading multi-file
RELAX NG schemas from arbitary URLs, and flattening them into a single
RELAX NG schema.

%prep
%setup -q -n rnginline-%{version}

%build
python3 setup.py build

%install
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
mv %{buildroot}%{_bindir}/%{rng} %{buildroot}%{_bindir}/%{rng}%{py3_ver}
ln -s %{_bindir}/%{rng}%{py3_ver} %{buildroot}%{_bindir}/%{rng}

%fdupes %{buildroot}

%pre
# Since /usr/bin/rnginline became ghosted to be used with update-alternatives,
# we have to get rid of the old binary resulting from the
# non-update-alternativies-ified package:
[ -h %{_bindir}/%{rng} ] || rm -f %{_bindir}/%{rng}

%post
update-alternatives --install %{_bindir}/%{rng} \
    %{rng} %{_bindir}/%{rng}%{py3_ver} 30

%preun
if [ $1 -eq 0 ] ; then
    update-alternatives --remove %{rng} %{_bindir}/%{rng}%{py3_ver}
fi


%files
%defattr(-,root,root,-)
%{_bindir}/%{rng}
%{_bindir}/%{rng}%{py3_ver}
%ghost %{_sysconfdir}/alternatives/%{rng}
%{python3_sitelib}/*
# %%{python3_sitelib}/rnginline-%%{version}-py%%{py3_ver}.egg-info

%changelog
openSUSE Build Service is sponsored by