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