File python-debian.spec of Package python-debian

#
# spec file for package python-debian
#
# Copyright (c) 2017 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/
#


%bcond_with test

%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

%if 0%{?fedora} || 0%{?suse_version} > 1320
%global with_python3 1
%global py3dir %{_builddir}/py3/
%else
%global with_python3 0
%endif

Name:           python-debian
Version:        0.1.31
Release:        2%{?dist}
Summary:        Modules for Debian-related data formats
# debfile.py, arfile.py, debtags.py are release under GPL v3 or above
# everything else is GPLv2+
License:        GPL-2.0+ and GPL-3.0+
Source0:        http://ftp.debian.org/debian/pool/main/p/python-debian/python-debian_%{version}.tar.xz
Url:            http://git.debian.org/?p=pkg-python-debian/python-debian.git
BuildArch:      noarch
BuildRequires:  python-chardet
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  python-six

%global _description\
This package provides Python modules that abstract many formats of Debian\
related files. Currently handled are:\
* Debtags information (debian.debtags module)\
* debian/changelog (debian.changelog module)\
* Packages files, pdiffs (debian.debian_support module)\
* Control files of single or multiple RFC822-style paragraphs, e.g.\
  debian/control, .changes, .dsc, Packages, Sources, Release, etc.\
  (debian.deb822 module)\
* Raw .deb and .ar files, with (read-only) access to contained\
  files and meta-information

%description %_description

%package -n python2-debian
Summary:        %summary
Requires:       python >= 2.4
Requires:       python-chardet
Requires:       python-six
Requires:       xz
Suggests:       gnupg
#not available now
#Recommends:    python2-apt
Provides:       python-debian = %{version}-%{release}
Obsoletes:      python-debian < %{version}-%{release}

%description -n python2-debian %_description

%if 0%{?with_python3}
%package -n python3-debian
Summary:        Modules for Debian-related data formats
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Requires:       python3-chardet
Requires:       python3-six
Requires:       xz
Suggests:       gnupg
#not available now
#Recommends:    python3-apt

%description -n python3-debian
This package provides Python modules that abstract many formats of Debian
related files. Currently handled are:
* Debtags information (debian.debtags module)
* debian/changelog (debian.changelog module)
* Packages files, pdiffs (debian.debian_support module)
* Control files of single or multiple RFC822-style paragraphs, e.g.
  debian/control, .changes, .dsc, Packages, Sources, Release, etc.
  (debian.deb822 module)
* Raw .deb and .ar files, with (read-only) access to contained
  files and meta-information
%endif

%prep
%setup -q

%if 0%{with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif

%build
sed -e 's/__CHANGELOG_VERSION__/$(VERSION)/' < setup.py.in > setup.py
%{__python} setup.py build

%if 0%{with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif

%install
%{__python} setup.py install --prefix=%{_prefix} --root=$RPM_BUILD_ROOT

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --root=$RPM_BUILD_ROOT
popd
%endif

%clean
%{__python} setup.py clean

%check
%if %{with tests}
cd tests;
#./test_deb822.py
#TODO - fix this test
#./test_debfile.py
./test_debtags.py
./test_changelog.py
#./test_debian_support.py

%if 0%{with_python3}
pushd %{py3dir}
cd tests;
#./test_deb822.py
#TODO - fix this test
#./test_debfile.py
./test_debtags.py
./test_changelog.py
#./test_debian_support.py
popd
%endif
%endif

%files -n python2-debian
%dir %{python_sitelib}/debian
%dir %{python_sitelib}/debian_bundle
%{python_sitelib}/*.py*
%{python_sitelib}/debian/*.py*
%{python_sitelib}/debian_bundle/__init__.py*
%{python_sitelib}/python_debian*
%doc README README.changelog README.deb822 HISTORY.deb822 ACKNOWLEDGEMENTS

%if 0%{?with_python3}
%files -n python3-debian
%dir %{python3_sitelib}/debian
%dir %{python3_sitelib}/debian_bundle
%{python3_sitelib}/*.py*
%{python3_sitelib}/__pycache__
%{python3_sitelib}/debian/*.py*
%{python3_sitelib}/debian/__pycache__
%{python3_sitelib}/debian_bundle/__init__.py*
%{python3_sitelib}/debian_bundle/__pycache__
%{python3_sitelib}/python_debian*
%doc README README.changelog README.deb822 HISTORY.deb822 ACKNOWLEDGEMENTS
%endif

%changelog
openSUSE Build Service is sponsored by