File python3-pycodestyle.spec of Package python3-pycodestyle

#
# spec file for package python3-pycodestyle
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           python3-pycodestyle
Version:        2.0.0
Release:        0
Url:            https://github.com/PyCQA/pycodestyle
Summary:        Python style guide checker - formery python3-pep8
License:        MIT
Group:          Development/Languages/Python
Source:         https://files.pythonhosted.org/packages/source/p/pycodestyle/pycodestyle-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  fdupes
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch

%description
The pycodestyle package is a tool to check your Python code against
some of the style conventions in PEP 8.

Note:
This package used to be called pep8 but was renamed to pycodestyle to
reduce confusion.

%prep
%setup -q -n pycodestyle-%{version}
sed -i "/\#\!\/usr\/bin\/env python/d" pycodestyle.py # Remove she-bang line

%build
python3 setup.py build

%install
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}

# Prepare for update-alternatives usage
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
mv %{buildroot}%{_bindir}/pycodestyle %{buildroot}%{_bindir}/pycodestyle-%{py3_ver}
ln -s -f %{_sysconfdir}/alternatives/pycodestyle %{buildroot}%{_bindir}/pycodestyle
# create a dummy target for /etc/alternatives/pycodestyle
touch %{buildroot}%{_sysconfdir}/alternatives/pycodestyle

%fdupes %{buildroot}%{python3_sitelib}

%post
"%_sbindir/update-alternatives" \
   --install %{_bindir}/pycodestyle pycodestyle %{_bindir}/pycodestyle-%{py3_ver} 30

%postun
if [ $1 -eq 0 ] ; then
    "%_sbindir/update-alternatives" --remove pycodestyle %{_bindir}/pycodestyle-%{py3_ver}
fi

%check
python3 setup.py test

%files
%defattr(-,root,root)
%doc CHANGES.txt README.rst
%{_bindir}/pycodestyle
%{_bindir}/pycodestyle-%{py3_ver}
%ghost %{_sysconfdir}/alternatives/pycodestyle
%{python3_sitelib}/pycodestyle.py*
%{python3_sitelib}/pycodestyle-%{version}-py%{py3_ver}.egg-info
%{python3_sitelib}/__pycache__/pycodestyle.*.pyc

%changelog
openSUSE Build Service is sponsored by