%if 0%{?fedora}
%global with_python3 1
%endif
%global pypi_name autopep8
%global py3_name python3-%{pypi_name}
Name: python-autopep8
Version: 1.2
Release: 1%{?dist}
Summary: The package autopep8 formats Python code based on the output of the pep8 utility
License: MIT
URL: http://pypi.python.org/pypi/autopep8
Source0: https://pypi.python.org/packages/source/a/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-pep8
Requires: python-pep8
%description
autopep8 formats Python code based on the output of the pep8 utility.
%if 0%{?with_python3}
%package -n %{py3_name}
Summary: The package autopep8 formats Python code based on the output of the pep8 utility
BuildRequires: python3-devel
BuildRequires: python3-pep8
Requires: python3-pep8
%description -n %{py3_name}
autopep8 formats Python code based on the output of the pep8 utility.
%endif
%prep
%setup -q -n autopep8-%{version}
sed -i -e '1d' autopep8.py
touch test/__init__.py #test needs to be a python module otherwise test will fial
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif
%build
%{__python2} setup.py build
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif
%check
# rpmbuild forces the use of LANG=C which fails unit tests
%if 0%{?fedora} || 0%{?rhel} > 6
LANG=en_US.utf8 %{__python2} setup.py test
%endif
%if 0%{?with_python3}
pushd %{py3dir}
LANG=en_US.utf8 %{__python3} setup.py test
popd
%endif
%install
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
mv %{buildroot}%{_bindir}/%{pypi_name} %{buildroot}%{_bindir}/%{py3_name}
popd
%endif
%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
%files
%doc README.rst
%{python2_sitelib}/*
%{_bindir}/%{pypi_name}
%if 0%{?with_python3}
%files -n %{py3_name}
%doc README.rst
%{python3_sitelib}/*
%{_bindir}/%{py3_name}
%endif
%changelog
* Fri Aug 28 2015 Nikola Dipanov <ndipanov@redhat.com> - 1.2-1
- Update to upstream version 1.2
* Sat Jul 11 2015 Haïkel Guémar <hguemar@fedoraproject.org> - 1.1.1-1
- Upstream 1.1.1
- Use python versioned macros
- Add missing dist in release tag
- Add python3 subpackage
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Tue Aug 13 2013 Nikola Dipanov <ndipanov@redhat.com> - 0.9.2-1
- Update to upstream version 0.9.2
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Thu Sep 06 2012 Nikola Dipanov <ndipanov@redhat.com> - 0.8-1
- initial build