2c2c5b0
%global srcname pydocstyle
2c2c5b0
%global sum Python docstring style checker
2c2c5b0
2c2c5b0
Name: python-%{srcname}
47e8ed9
Version: 2.0.0
57f6af2
Release: 1%{?dist}
2c2c5b0
Summary: %{sum}
2c2c5b0
2c2c5b0
License: MIT
2c2c5b0
URL: https://github.com/PyCQA/pydocstyle/
cab34a6
# NOTE: Temporarily use GitHub archive download service until upstream includes
cab34a6
# tests in the release tarballs.
cab34a6
Source0: https://github.com/PyCQA/%{srcname}/archive/%{version}/%{srcname}-%{version}.tar.gz
2c2c5b0
2c2c5b0
BuildArch: noarch
2c2c5b0
2c2c5b0
2c2c5b0
%description
2c2c5b0
A static analysis tool for checking compliance with Python docstring
2c2c5b0
conventions.
2c2c5b0
2c2c5b0
It supports most of PEP 257 out of the box, but it should not be considered a
2c2c5b0
reference implementation.
2c2c5b0
2c2c5b0
2c2c5b0
%package -n python2-%{srcname}
2c2c5b0
Summary: %{sum}
2c2c5b0
%{?python_provide:%python_provide python2-%{srcname}}
2c2c5b0
cab34a6
BuildRequires: python2-devel
cab34a6
# Required for running tests
47e8ed9
BuildRequires: python2-six
47e8ed9
BuildRequires: python2-snowballstemmer
cab34a6
BuildRequires: python2-pytest
cab34a6
BuildRequires: python-pytest-pep8
cab34a6
BuildRequires: python2-mock
cab34a6
# NOTE: pathlib is not in BuildRequires since it is only needed by Integration
cab34a6
# tests which are ignored on Python 2 due to reasons described below.
cab34a6
47e8ed9
Requires: python2-six
47e8ed9
Requires: python2-snowballstemmer
47e8ed9
2c2c5b0
%description -n python2-%{srcname}
2c2c5b0
A static analysis tool for checking compliance with Python docstring
2c2c5b0
conventions.
2c2c5b0
2c2c5b0
It supports most of PEP 257 out of the box, but it should not be considered a
2c2c5b0
reference implementation.
2c2c5b0
2c2c5b0
NOTE: Only Python 3 version of 'pydocstyle' executable is packaged. See:
2c2c5b0
python3-%{srcname}.
2c2c5b0
2c2c5b0
2c2c5b0
%package -n python3-%{srcname}
2c2c5b0
Summary: %{sum}
2c2c5b0
%{?python_provide:%python_provide python3-%{srcname}}
2c2c5b0
cab34a6
BuildRequires: python3-devel
cab34a6
# Required for running tests
47e8ed9
BuildRequires: python3-six
47e8ed9
BuildRequires: python3-snowballstemmer
cab34a6
BuildRequires: python3-pytest
cab34a6
BuildRequires: python3-pytest-pep8
cab34a6
BuildRequires: python3-mock
cab34a6
# NOTE: pathlib is not in BuildRequires since it is part of the Python standard
cab34a6
# library in Python 3.4+.
cab34a6
47e8ed9
Requires: python3-six
47e8ed9
Requires: python3-snowballstemmer
47e8ed9
2c2c5b0
%description -n python3-%{srcname}
2c2c5b0
A static analysis tool for checking compliance with Python docstring
2c2c5b0
conventions.
2c2c5b0
2c2c5b0
It supports most of PEP 257 out of the box, but it should not be considered a
2c2c5b0
reference implementation.
2c2c5b0
2c2c5b0
2c2c5b0
%prep
2c2c5b0
%autosetup -n %{srcname}-%{version}
2c2c5b0
2c2c5b0
2c2c5b0
%build
2c2c5b0
%py2_build
2c2c5b0
%py3_build
2c2c5b0
2c2c5b0
# Remove (incorrect) Python shebang from package's __main__.py file
2c2c5b0
sed -i '\|/usr/bin/env|d' build/lib/pydocstyle/__main__.py
2c2c5b0
2c2c5b0
2c2c5b0
%install
2c2c5b0
# Must do the python2 install first because the scripts in /usr/bin are
2c2c5b0
# overwritten with every setup.py install, and in general we want the
2c2c5b0
# python3 version to be the default.
2c2c5b0
%py2_install
2c2c5b0
%py3_install
2c2c5b0
2c2c5b0
cab34a6
%check
cab34a6
# Run tests under Python 2
cab34a6
cab34a6
# NOTE: Integration tests are ignored on Python 2 since they require having the
47e8ed9
# 'pydocstyle' executable installed on the system. As described below, we only
47e8ed9
# package Python 3 version of this executable.
cab34a6
# NOTE: We need to specify the PYTHONPATH environment variable so that Python
cab34a6
# can find the system-installed pydocstyle package in %%{buildroot}.
cab34a6
PYTHONPATH="%{buildroot}%{python2_sitelib}" py.test \
cab34a6
    --pep8 \
cab34a6
    --cache-clear \
cab34a6
    --ignore=src/tests/test_integration.py \
cab34a6
    src/tests
cab34a6
cab34a6
# Run tests under Python 3
cab34a6
cab34a6
# Disable "install_package" fixure for integration tests since we want the
cab34a6
# tests to be run against the system-installed version of the package.
cab34a6
# NOTE: Two following blank lines need to be deleted to prevent the PEP8 E303
cab34a6
# error (too many blank lines).
cab34a6
sed -i '/pytestmark = pytest.mark.usefixtures("install_package")/ { N; N; d; }' \
cab34a6
    src/tests/test_integration.py
cab34a6
cab34a6
# Replace 'python(2|3)*' with '%%{__python3}' in tests that run pydocstyle as
cab34a6
# a named Python module.
cab34a6
sed -E -i 's|"python(2\|3)*( -m pydocstyle)|"%{__python3}\2|' \
cab34a6
    src/tests/test_integration.py
cab34a6
cab34a6
# NOTE: We need to specify the PYTHONPATH environment variable so that Python
cab34a6
# can find the system-installed pydocstyle package in %%{buildroot}.
cab34a6
# NOTE: We need to augment the PATH environment variable so that integration
cab34a6
# tests can find the system-installed pydocstyle executables in %%{buildroot}.
cab34a6
PYTHONPATH="%{buildroot}%{python3_sitelib}" PATH="$PATH:%{buildroot}%{_bindir}" py.test-3 \
cab34a6
    --pep8 \
cab34a6
    --cache-clear \
cab34a6
    src/tests
2c2c5b0
2c2c5b0
2c2c5b0
# NOTE: There is no %%files section for the unversioned python module if we are
2c2c5b0
# building for several python runtimes
2c2c5b0
%files -n python2-%{srcname}
2c2c5b0
%license LICENSE-MIT
2c2c5b0
%doc README.rst
2c2c5b0
%{python2_sitelib}/*
2c2c5b0
# NOTE: Only Python 3 versions of executables are packaged as recommended in:
2c2c5b0
# https://fedoraproject.org/wiki/Packaging:Python#Executables_in_.2Fusr.2Fbin
2c2c5b0
2c2c5b0
%files -n python3-%{srcname}
2c2c5b0
%license LICENSE-MIT
2c2c5b0
%doc README.rst
2c2c5b0
%{python3_sitelib}/*
2c2c5b0
%{_bindir}/pydocstyle
2c2c5b0
2c2c5b0
2c2c5b0
%changelog
57f6af2
* Fri Jun 30 2017 Tadej Janež <tadej.j@nez.si> 2.0.0-1
57f6af2
- Initial release in Fedora 25+.
57f6af2
47e8ed9
* Mon May 08 2017 Tadej Janež <tadej.j@nez.si> 2.0.0-0.1
47e8ed9
- Update to 2.0.0 release.
47e8ed9
- Update Requires and BuildRequires for the new version.
47e8ed9
- Drop pep257 compatibility console script.
47e8ed9
cab34a6
* Fri Apr 07 2017 Tadej Janež <tadej.j@nez.si> 1.1.1-0.2
cab34a6
- Temporarily use GitHub arhive download service until upstream includes tests
cab34a6
  in the release tarballs.
cab34a6
- Run tests in %%check.
cab34a6
- Add appropriate BuildRequires for running the tests.
cab34a6
- Remove end-of-line encoding fixes which are no longer necessary.
cab34a6
2c2c5b0
* Mon Jan 02 2017 Tadej Janež <tadej.j@nez.si> 1.1.1-0.1
2c2c5b0
- Initial package.