# Created by pyp2rpm-0.5.1
%global pypi_name pyp2rpm

%if 0%{?rhel} && 0%{?rhel} >= 8
%bcond_with pytest
%else
%bcond_without pytest
%endif

Name:           %{pypi_name}
Version:        3.3.8
Release:        2.2%{?dist}
Summary:        Convert Python packages to RPM SPECFILES

License:        MIT
URL:            https://pypi.python.org/pypi/pyp2rpm
Source0:        %{pypi_source}
#Source0:        https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz

# Remove pytest-runner and flexmock dependencies (not packaged for Epel)
Patch0: remove-test-deps.patch
# Fixes encoding in koji builds
Patch1: archive_encoding-3.3.8.patch

BuildArch:      noarch
 
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-setuptools
%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires:  python36-jinja2
BuildRequires:  python36-click
%else
BuildRequires:  python%{python3_pkgversion}-jinja2
BuildRequires:  python%{python3_pkgversion}-click
%endif
BuildRequires:  python%{python3_pkgversion}-virtualenv
%if %{with pytest}
%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires:  python36-pytest
BuildRequires:  python36-pytest-runner
BuildRequires:  python36-flexmock >= 0.9.3
BuildRequires:  python36-scripttest
%else
BuildRequires:  python%{python3_pkgversion}-pytest
BuildRequires:  python%{python3_pkgversion}-pytest-runner
BuildRequires:  python%{python3_pkgversion}-flexmock >= 0.9.3
BuildRequires:  python%{python3_pkgversion}-scripttest
%endif
%if 0%{?fedora}
BuildRequires:  vex
%endif
%endif
Requires:       python%{python3_pkgversion}-setuptools
%if 0%{?rhel} && 0%{?rhel} <= 7
Requires:       python36-jinja2
Requires:       python36-click
%else
Requires:       python%{python3_pkgversion}-jinja2
Requires:       python%{python3_pkgversion}-click
%endif
Requires:       python%{python3_pkgversion}-virtualenv
Requires:       python3-rpm
Requires:       rpmdevtools

%if 0%{?rhel} && 0%{?rhel} <= 7
Requires:       python
%else
Requires:       python2
%endif
Requires:       python3
Requires:       git

# For Python 2 metadata extractor
%if 0%{?rhel} && 0%{?rhel} <= 7
Requires:       python-setuptools
%else
Suggests:       python2dist(setuptools)
%endif


%description
Convert Python packages to RPM SPECFILES. The packages can be downloaded from
PyPI and the produced SPEC is in line with Fedora 201x-era Python Packaging
Guidelines or Mageia Python Policy.

Unfortunately, pyp2rpm does not generate spec files according to to the current
Fedora Python Packaging Guidelines.


%prep
#%%autosetup -p1 -n %{pypi_name}-%{version}
%setup -q -n %{pypi_name}-%{version}
%if ! %{with pytest}
%patch0 -p1 -b .pytest
%endif
%if 0%{?rhel} && 0%{?rhel} <= 7
%patch1 -p1 -b .encoding
%endif

# Remove bundled egg-info
%{__rm} -rf %{pypi_name}.egg-info


%build
%py3_build


%install
%py3_install


%if %{with pytest}
%check
# TestMetadataExtractor requires Python 2 setuptools
PYTHONPATH="." py.test-3 -vv -m "not webtest" -k "not TestMetadataExtractor"
%endif


%files
%license LICENSE
%doc README.md
%{_bindir}/pyp2rpm
%{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info/


%changelog
* Wed May 04 2022 Tomasz Tomasik <scx.mail@gmail.com> - 3.2.2-2.2
- Fixes for EL >= 8

* Wed May 04 2022 Tomasz Tomasik <scx.mail@gmail.com> - 3.2.2-2.1
- Rebuilt for EL7

* Tue Oct 22 2019 Miro Hrončok <mhroncok@redhat.com> - 3.2.2-2
- Switch to Python 3

* Wed Feb 22 2017 Michal Cyprian <mcyprian@redhat.com> - 3.2.2-1
- Update to 3.2.2

* Mon Apr 04 2016 Kevin Fenzi <kevin@scrye.com> - 2.0.0-4
- Fix Requires.

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5

* Tue Aug 18 2015 Michal Cyprian <mcyprian@redhat.com> - 2.0.0-1
- Update to 2.0.0

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

* Thu Nov 27 2014 Robert Kuska <rkuska@redhat.com> - 1.1.2-1
- Update to 1.1.2

* Fri Sep 12 2014 Robert Kuska <rkuska@redhat.com> - 1.1.1-1
- Update to 1.1.1

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

* Tue May 13 2014 Bohuslav Kabrda <bkabrda@redhat.com> - 1.1.0b-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Tue Apr 29 2014 Robert Kuska <rkuska@redhat.com> - 1.1.0b-1
- Update to v1.1.0b

* Wed Jan 29 2014 Robert Kuska <rkuska@redhat.com> - 1.0.1-4
- Change requires from distribute to setuptools
- Add rpmdevtools to requires

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Wed Dec 19 2012 Bohuslav Kabrda <bkabrda@redhat.com> - 0.5.1-6
- Update to 1.0.1.

* Mon Dec 03 2012 Bohuslav Kabrda <bkabrda@redhat.com> - 0.5.1-5
- Properly require python3 deps only from the python3 subpackage.

* Mon Aug 06 2012 David Malcolm <dmalcolm@redhat.com> - 0.5.1-4
- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3

* Thu Aug  2 2012 David Malcolm <dmalcolm@redhat.com> - 0.5.1-3
- generalize py.test reference to work with Python 3.*

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Mon Jun 18 2012 Bohuslav Kabrda <bkabrda@redhat.com> - 0.5.1-1
- Initial package.