04dbcf
%global pkgname qrcode
04dbcf
04dbcf
%if 0%{?rhel} > 7
04dbcf
# Disable python2 build by default
04dbcf
%bcond_with python2
04dbcf
%else
04dbcf
%bcond_without python2
04dbcf
%endif
04dbcf
04dbcf
Name:           python-%{pkgname}
04dbcf
Version:        5.1
04dbcf
Release:        12%{?dist}
04dbcf
Summary:        Python QR Code image generator
04dbcf
04dbcf
License:        BSD
04dbcf
URL:            https://github.com/lincolnloop/python-qrcode
04dbcf
Source0:        http://pypi.python.org/packages/source/q/qrcode/qrcode-%{version}.tar.gz
04dbcf
04dbcf
BuildArch:      noarch
04dbcf
04dbcf
%if %{with python2}
04dbcf
BuildRequires:  python2-devel
04dbcf
BuildRequires:  python2-setuptools
04dbcf
BuildRequires:  python2-imaging
04dbcf
BuildRequires:  python2-six
04dbcf
%endif # with python2
04dbcf
04dbcf
BuildRequires:  python3-devel
04dbcf
BuildRequires:  python3-setuptools
04dbcf
BuildRequires:  python3-imaging
04dbcf
BuildRequires:  python3-six
04dbcf
04dbcf
%global _description\
04dbcf
This module uses the Python Imaging Library (PIL) to allow for the\
04dbcf
generation of QR Codes.\
04dbcf
04dbcf
04dbcf
%description %_description
04dbcf
04dbcf
%if %{with python2}
04dbcf
%package -n python2-%{pkgname}
04dbcf
Summary: %summary
04dbcf
Requires:       python2-imaging
04dbcf
Requires:       python2-%{pkgname}-core = %{version}-%{release}
04dbcf
%{?python_provide:%python_provide python2-%{pkgname}}
04dbcf
04dbcf
%description -n python2-%{pkgname} %_description
04dbcf
04dbcf
%package -n python2-%{pkgname}-core
04dbcf
Requires:       python-six
04dbcf
Conflicts:      python-qrcode < 5.0
04dbcf
Summary:        Python 2 QR Code image generator (core library)
04dbcf
%{?python_provide:%python_provide python2-%{pkgname}-core}
04dbcf
04dbcf
%description -n python2-%{pkgname}-core
04dbcf
Core Python 2 module for QR code generation. Does not contain image rendering.
04dbcf
%endif # with python2
04dbcf
04dbcf
04dbcf
%package -n python3-%{pkgname}
04dbcf
Summary:        Python QR Code image generator
04dbcf
Requires:       python3-imaging
04dbcf
# For entry point:
04dbcf
%if 0%{?rhel} && 0%{?rhel} >= 8
04dbcf
Requires:       platform-python-setuptools
04dbcf
%else
04dbcf
Requires:       python3-setuptools
04dbcf
%endif
04dbcf
Requires:       python3-%{pkgname}-core = %{version}-%{release}
04dbcf
04dbcf
%description -n python3-%{pkgname}
04dbcf
This module uses the Python Imaging Library (PIL) to allow for the
04dbcf
generation of QR Codes. Python 3 version.
04dbcf
04dbcf
04dbcf
%package -n python3-%{pkgname}-core
04dbcf
Requires:       python3-six
04dbcf
Summary:        Python 3 QR Code image generator (core library)
04dbcf
04dbcf
%description -n python3-%{pkgname}-core
04dbcf
Core Python 3 module for QR code generation. Does not contain image rendering.
04dbcf
04dbcf
04dbcf
%prep
04dbcf
%setup -qc
04dbcf
04dbcf
%if %{with python2}
04dbcf
cp -a %{pkgname}-%{version} python2
04dbcf
04dbcf
# The pure plugin requires pymaging which is not packaged in Fedora.
04dbcf
rm python2/qrcode/image/pure.py*
04dbcf
04dbcf
# Remove shebang
04dbcf
sed -i '1d' python2/qrcode/console_scripts.py
04dbcf
%endif # with python2
04dbcf
04dbcf
cp -a %{pkgname}-%{version} python3
04dbcf
04dbcf
# The pure plugin requires pymaging which is not packaged in Fedora.
04dbcf
rm python3/qrcode/image/pure.py*
04dbcf
04dbcf
# Remove shebang
04dbcf
sed -i '1d' python3/qrcode/console_scripts.py
04dbcf
04dbcf
04dbcf
%build
04dbcf
%if %{with python2}
04dbcf
pushd python2
04dbcf
%py2_build
04dbcf
popd
04dbcf
%endif # with python2
04dbcf
04dbcf
pushd python3
04dbcf
%py3_build
04dbcf
popd
04dbcf
04dbcf
%install
04dbcf
%if %{with python2}
04dbcf
pushd python2
04dbcf
%py2_install
04dbcf
04dbcf
# Be sure binscripts are Python 3
04dbcf
rm %{buildroot}%{_bindir}/*
04dbcf
04dbcf
# Do not install tests
04dbcf
rm -r %{buildroot}%{python2_sitelib}/%{pkgname}/tests
04dbcf
popd
04dbcf
%endif # with python2
04dbcf
04dbcf
pushd python3
04dbcf
%py3_install
04dbcf
04dbcf
# Do not install tests
04dbcf
rm -r %{buildroot}%{python3_sitelib}/%{pkgname}/tests
04dbcf
popd
04dbcf
04dbcf
#
04dbcf
# In previous iterations of the package, the qr script had been
04dbcf
# renamed to qrcode. This was an unnecessary change from upstream.
04dbcf
#
04dbcf
# We cary this symlink to maintain compat with old packages.
04dbcf
#
04dbcf
ln -s qr %{buildroot}%{_bindir}/qrcode
04dbcf
04dbcf
%check
04dbcf
# in lieue of a real test suite
04dbcf
modules=$(find qrcode -name '*.py' \
04dbcf
          | grep -v __init__ \
04dbcf
          | sort \
04dbcf
          | sed -e 's|/|.|g' \
04dbcf
          | sed -e 's|.py$||g');
04dbcf
04dbcf
04dbcf
%if %{with python2}
04dbcf
pushd python2
04dbcf
for m in $modules;
04dbcf
do
04dbcf
    %{__python2} -c "import $m"
04dbcf
done
04dbcf
popd
04dbcf
%endif # with python2
04dbcf
04dbcf
pushd python3
04dbcf
for m in $modules;
04dbcf
do
04dbcf
    %{__python3} -c "import $m"
04dbcf
done
04dbcf
popd
04dbcf
04dbcf
04dbcf
%if %{with python2}
04dbcf
%files -n python2-%{pkgname}
04dbcf
%{python2_sitelib}/%{pkgname}/image/svg.py*
04dbcf
%{python2_sitelib}/%{pkgname}/image/pil.py*
04dbcf
04dbcf
04dbcf
%files -n python2-%{pkgname}-core
04dbcf
%doc python2/README.rst python2/CHANGES.rst
04dbcf
%license python2/LICENSE
04dbcf
%dir %{python2_sitelib}/%{pkgname}/
04dbcf
%dir %{python2_sitelib}/%{pkgname}/image
04dbcf
%{python2_sitelib}/%{pkgname}*.egg-info
04dbcf
%{python2_sitelib}/%{pkgname}/*.py*
04dbcf
%{python2_sitelib}/%{pkgname}/image/__init__.py*
04dbcf
%{python2_sitelib}/%{pkgname}/image/base.py*
04dbcf
%endif # with python2
04dbcf
04dbcf
04dbcf
%files -n python3-%{pkgname}
04dbcf
%{_bindir}/qr
04dbcf
%{_bindir}/qrcode
04dbcf
%{_mandir}/man1/qr.1*
04dbcf
%{python3_sitelib}/%{pkgname}/image/svg.py*
04dbcf
%{python3_sitelib}/%{pkgname}/image/pil.py*
04dbcf
%{python3_sitelib}/%{pkgname}/image/__pycache__/svg.*
04dbcf
%{python3_sitelib}/%{pkgname}/image/__pycache__/pil.*
04dbcf
04dbcf
04dbcf
%files  -n python3-%{pkgname}-core
04dbcf
%doc python3/README.rst python3/CHANGES.rst
04dbcf
%license python3/LICENSE
04dbcf
%dir %{python3_sitelib}/%{pkgname}/
04dbcf
%dir %{python3_sitelib}/%{pkgname}/image
04dbcf
%dir %{python3_sitelib}/%{pkgname}/image/__pycache__
04dbcf
%{python3_sitelib}/%{pkgname}*.egg-info
04dbcf
%{python3_sitelib}/%{pkgname}/*.py*
04dbcf
%{python3_sitelib}/%{pkgname}/__pycache__
04dbcf
%{python3_sitelib}/%{pkgname}/image/__init__.py*
04dbcf
%{python3_sitelib}/%{pkgname}/image/base.py*
04dbcf
%{python3_sitelib}/%{pkgname}/image/__pycache__/__init__.*
04dbcf
%{python3_sitelib}/%{pkgname}/image/__pycache__/base.*
04dbcf
04dbcf
04dbcf
%changelog
04dbcf
* Wed Nov 28 2018 Tomas Orsava <torsava@redhat.com> - 5.1-12
04dbcf
- Require platform-python-setuptools instead of python3-setuptools
04dbcf
- Resolves: rhbz#1654457, rhbz#1654458
04dbcf
04dbcf
* Fri Jun 22 2018 Charalampos Stratakis <cstratak@redhat.com> - 5.1-11
04dbcf
- Conditionalize the python2 subpackage
04dbcf
04dbcf
* Tue Mar 20 2018 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.1-10
04dbcf
- Also rename python-qrcode-core to python2-qrcode-core
04dbcf
04dbcf
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 5.1-9
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
04dbcf
04dbcf
* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.1-8
04dbcf
- Python 2 binary package renamed to python2-qrcode
04dbcf
  See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
04dbcf
04dbcf
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 5.1-7
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
04dbcf
04dbcf
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 5.1-6
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
04dbcf
04dbcf
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 5.1-5
04dbcf
- Rebuild for Python 3.6
04dbcf
04dbcf
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1-4
04dbcf
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
04dbcf
04dbcf
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 5.1-3
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
04dbcf
04dbcf
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1-2
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
04dbcf
04dbcf
* Fri Jul 10 2015 Miro Hrončok <mhroncok@redhat.com> - 5.1-1
04dbcf
- Update to 5.1
04dbcf
- Introduce python3 subpackages (#1237118)
04dbcf
- Moved LICENSE from %%doc to %%license
04dbcf
04dbcf
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.0.1-3
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
04dbcf
04dbcf
* Tue Sep 16 2014 Nathaniel McCallum <npmccallum@redhat.com> - 5.0.1-2
04dbcf
- Make python-qrcode-core conflicts with python-qrcode < 5.0
04dbcf
04dbcf
* Wed Sep 10 2014 Nathaniel McCallum <npmccallum@redhat.com> - 5.0.1-1
04dbcf
- Update to 5.0.1
04dbcf
04dbcf
* Tue Sep 09 2014 Nathaniel McCallum <npmccallum@redhat.com> - 2.4.1-7
04dbcf
- Create -core subpackage for minimal dependencies
04dbcf
04dbcf
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.1-6
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
04dbcf
04dbcf
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.1-5
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
04dbcf
04dbcf
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.1-4
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
04dbcf
04dbcf
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.1-3
04dbcf
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
04dbcf
04dbcf
* Wed Jun  6 2012 Michel Salim <salimma@fedoraproject.org> - 2.4.1-2
04dbcf
- Clean up spec, removing unnecessary declarations
04dbcf
- Rename tool in %%{_bindir} to the less ambiguous qrcode
04dbcf
04dbcf
* Sat Jun  2 2012 Michel Salim <salimma@fedoraproject.org> - 2.4.1-1
04dbcf
- Initial package