diff --git a/rpkg.spec b/rpkg.spec index d4cc6be..d00de04 100644 --- a/rpkg.spec +++ b/rpkg.spec @@ -1,8 +1,9 @@ # sitelib for noarch packages, sitearch for others (remove the unneeded one) +%{!?python2_sitelib: %global python2_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} Name: rpkg Version: 1.52 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Python library for interacting with rpm+git License: GPLv2+ and LGPLv2 @@ -11,28 +12,45 @@ Source0: https://pagure.io/releases/rpkg/%{name}-%{version}.tar.gz BuildArch: noarch +%if 0%{?fedora} || 0%{?rhel} > 7 +# Enable python3 build by default +%global with_python3 1 +%else +%global with_python3 0 +%endif + +%if 0%{?rhel} > 7 +# Disable python2 build by default +%global with_python2 0 +%else +%global with_python2 1 +%endif + %description Python library for interacting with rpm+git +%if 0%{?with_python2} %package -n python2-%{name} -Summary: Python library for interacting with rpm+git +Summary: %{summary} +%{?python_provide:%python_provide python2-%{name}} BuildRequires: python2-devel # We br these things for man page generation due to imports -BuildRequires: GitPython BuildRequires: python2-koji BuildRequires: python2-cccolutils BuildRequires: python2-openidc-client BuildRequires: python2-mock %if 0%{?rhel} +BuildRequires: GitPython BuildRequires: python-pycurl BuildRequires: python-rpmfluff BuildRequires: python-six >= 1.9.0 BuildRequires: python-requests %else +BuildRequires: python2-GitPython BuildRequires: python2-pycurl BuildRequires: python2-rpmfluff BuildRequires: python2-six >= 1.9.0 @@ -56,16 +74,17 @@ Requires: redhat-rpm-config Requires: rpm-build Requires: rpmlint -Requires: GitPython >= 0.2.0 Requires: python2-cccolutils Requires: python2-koji %if 0%{?rhel} +Requires: GitPython >= 0.2.0 Requires: rpm-python Requires: python-pycurl Requires: python-six >= 1.9.0 Requires: python-requests %else +Requires: python2-GitPython Requires: python2-rpm Requires: python2-pycurl Requires: python2-six >= 1.9.0 @@ -75,6 +94,7 @@ Requires: python2-six >= 1.9.0 Requires: python-argparse %endif +Requires: %{name}-common = %{version}-%{release} Conflicts: fedpkg < 1.26 @@ -86,6 +106,62 @@ Obsoletes: pyrpkg < 1.49-2 %description -n python2-%{name} A python library for managing RPM package sources in a git repository. +%endif # with python2 + + +%if 0%{?with_python3} +%package -n python3-%{name} +Summary: %{summary} +%{?python_provide:%python_provide python3-%{name}} + +BuildRequires: python3-devel +BuildRequires: python3-GitPython +BuildRequires: python3-koji +BuildRequires: python3-cccolutils +BuildRequires: python3-openidc-client +BuildRequires: python3-mock +BuildRequires: python3-pycurl +BuildRequires: python3-rpmfluff +BuildRequires: python3-six >= 1.9.0 +BuildRequires: python3-requests +BuildRequires: python3-setuptools +BuildRequires: python3-nose + +BuildRequires: rpmlint + +# see https://pagure.io/rpkg/pull-request/294 and remove this afterwards +BuildRequires: %{_bindir}/python + +Requires: mock +Requires: redhat-rpm-config +Requires: rpm-build +Requires: rpmlint + +Requires: python3-GitPython >= 0.2.0 +Requires: python3-cccolutils +Requires: python3-koji +Requires: python3-rpm +Requires: python3-pycurl +Requires: python3-six >= 1.9.0 + +Requires: %{name}-common = %{version}-%{release} + +Conflicts: fedpkg < 1.26 + +%description -n python3-%{name} +A python library for managing RPM package sources in a git repository. +%endif # with python3 + + +%package common +Summary: Common files for %{name} + +# Files were moved from python2-rpkg in that version +Conflicts: python2-rpkg < 1.52-2 +Conflicts: pyrpkg < 1.52-2 + +%description common +Common files for python2-%{name} and python3-%{name}. %prep @@ -93,12 +169,26 @@ A python library for managing RPM package sources in a git repository. %build +%if 0%{?with_python2} %{__python} setup.py build %{__python} doc/rpkg_man_page.py > rpkg.1 +%endif + +%if 0%{?with_python3} +%py3_build +%{__python3} doc/rpkg_man_page.py > rpkg.1 +%endif %install +%if 0%{?with_python2} %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT +%endif + +%if 0%{?with_python3} +%py3_install +%endif + # Create configuration directory to holding downstream clients config files # that are built on top of rpkg @@ -121,20 +211,42 @@ example_cli_dir=$RPM_BUILD_ROOT%{_datadir}/%{name}/examples/cli %check +# cannot use python2 -m nose on EPEL 6 (Python 2.6) +%if 0%{?with_python2} nosetests tests +%endif + +%if 0%{?with_python3} +%{__python3} -m nose tests +%endif +%if 0%{?with_python2} %files -n python2-%{name} %doc README.rst CHANGELOG.rst %license COPYING COPYING-koji LGPL # For noarch packages: sitelib %{python2_sitelib}/pyrpkg %{python2_sitelib}/%{name}-%{version}-py*.egg-info +%endif # with python2 + +%if 0%{?with_python3} +%files -n python3-%{name} +%doc README.rst CHANGELOG.rst +%license COPYING COPYING-koji LGPL +%{python3_sitelib}/pyrpkg +%{python3_sitelib}/%{name}-%{version}-py*.egg-info +%endif # with python3 + +%files common %{_datadir}/%{name} %{_sysconfdir}/rpkg %changelog +* Mon Mar 05 2018 Miro HronĨok - 1.52-2 +- Introduce python3 subpackage + * Thu Feb 22 2018 Chenxiong Qi - 1.52-1 - Mock ThreadPool in test_module_overview (cqi) - Drop rpmfluff in test (cqi)