Blob Blame History Raw
%if 0%{?fedora} > 12
%bcond_without python3
%else
%bcond_with python3
%endif

%global modname flake8

Name:             python-%{modname}
Version:          2.4.1
Release:          2%{?dist}
Summary:          Code checking using pep8 and pyflakes

Group:            Development/Languages
License:          MIT
URL:              http://pypi.python.org/pypi/%{modname}
Source0:          http://pypi.python.org/packages/source/f/%{modname}/%{modname}-%{version}.tar.gz

BuildArch:        noarch
BuildRequires:    python2-devel
BuildRequires:    python-nose
BuildRequires:    python-setuptools
BuildRequires:    python-mccabe >= 0.2
BuildRequires:    python-pep8 >= 1.5.7
BuildRequires:    pyflakes >= 0.8.1
BuildRequires:    python-mock
Requires:    python-mccabe >= 0.2
Requires:    python-pep8 >= 1.5.7
Requires:    pyflakes >= 0.8.1
Requires:    python-setuptools

%description
Flake8 is a wrapper around these tools:

- PyFlakes - pep8 - Ned's McCabe script

Flake8 runs all tools by launching the single 'flake8' script, but ignores
pep8 and PyFlakes extended options and just uses defaults. It displays the
warnings in a per-file, merged output.

It also adds a few features:

- files that contains with this header are skipped::

# flake8: noqa

- lines that contains a "# NOQA" comment at the end will not issue a
warning. - a Mercurial hook.

- a McCabe complexity checker.


%if %{with python3}
%package -n python3-%{modname}
Summary:        Code checking using pep8 and pyflakes
Group:          Development/Languages

Requires:    python3-setuptools
Requires:    python3-mccabe >= 0.2
Requires:    python3-pep8 >= 1.5.7
Requires:    python3-pyflakes >= 0.6.1

BuildRequires:    python3-devel
BuildRequires:    python3-setuptools
BuildRequires:    python3-nose
BuildRequires:    python3-mccabe >= 0.2
BuildRequires:    python3-pep8 >= 1.5.7
BuildRequires:    python3-pyflakes >= 0.8.1
BuildRequires:    python3-mock

%description -n python3-%{modname}
Flake8 is a wrapper around these tools:

- PyFlakes - pep8 - Ned's McCabe script

Flake8 runs all tools by launching the single 'flake8' script, but ignores
pep8 and PyFlakes extended options and just uses defaults. It displays the
warnings in a per-file, merged output.

It also adds a few features:

- files that contains with this header are skipped::

# flake8: noqa

- lines that contains a "# NOQA" comment at the end will not issue a
warning. - a Mercurial hook.

- a McCabe complexity checker.

This is version of the package running with Python 3.

%endif


%prep
%setup -qc
mv %{modname}-%{version} python2

# remove bundled egg-info
rm -rf flake8.egg-info
pushd python2

# copy README.1st CONTRIBUTORS.txt
cp -a README.rst ..
cp -a CONTRIBUTORS.txt ..

# remove requirements from setup.py, handled by rpm.
sed -i '/"pyflakes.*"/d' setup.py
sed -i '/"pep8.*"/d' setup.py
sed -i '/"mccabe .*"/d' setup.py
popd

%if %{with python3}
cp -a python2 python3
find python3 -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif


%build
pushd python2
%{__python2} setup.py build
popd

%if %{with python3}
pushd python3
%{__python3} setup.py build
popd
%endif

%install
# Must do the python3 install first because the scripts in /usr/bin are
# overwritten with every setup.py install (and we want the python2 version
# to be the default for now).
%if %{with python3}
pushd python3
    %{__python3} setup.py install -O1 --skip-build --root %{buildroot}
    mv %{buildroot}%{_bindir}/flake8 %{buildroot}%{_bindir}/python3-flake8
popd
%endif

pushd python2
%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
popd


%check
pushd python2
%{__python2} setup.py nosetests --verbosity=2
popd
%if %{with python3}
pushd python3
%{__python3} setup.py nosetests --verbosity=2
popd
%endif

%files
%doc README.rst CONTRIBUTORS.txt

%{_bindir}/%{modname}
%{python_sitelib}/%{modname}*

%if %{with python3}
%files -n python3-%{modname}
%doc README.rst CONTRIBUTORS.txt
%{_bindir}/python3-flake8
%{python3_sitelib}/%{modname}*
%endif


%changelog
* Mon Jul 06 2015 Matthias Runge <mrunge@redhat.com> - 2.4.1-2
- fix FTBFS (rhbz#1239837)

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Thu May 21 2015 Matej Cepl <mcepl@redhat.com> - 2.4.1-1
- update to 2.4.1 (rhbz#1178814)

* Mon Oct 20 2014 Matthias Runge <mrunge@redhat.com> - 2.2.5-1
- update to 2.2.5 (rhbz#1132878)

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed May 14 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 2.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4


* Wed Apr 09 2014 Matthias Runge <mrunge@redhat.com> - 2.1.0-1
- update to 2.1.0

* Thu Jan 02 2014 Matthias Runge <mrunge@redhat.com> - 2.0-5
- add missing requires to pep8, python-mccabe and pyflakes (rhbz#1046955)

* Mon Nov 18 2013 Matthias Runge <mrunge@redhat.com> - 2.0-4
- use __python2 instead of __python
- add CONTRIBUTORS.txt to py3 docs

* Tue Nov 05 2013 Matthias Runge <mrunge@redhat.com> - 2.0-3
- minimal spec cleanup, fix one rpmlint warning

* Sat Sep 08 2012 Matej Cepl <mcepl@redhat.com> - 1.4-2
- Update .spec file according to ongoing packaging review.

* Tue Jul 10 2012 Matej Cepl <mcepl@redhat.com> - 1.4-1
- initial package for Fedora