Switch macros to bcond's and make Python 2 optional

To facilitate building the Python 2 and Python 3 modules.
This commit is contained in:
Tomas Orsava 2017-08-07 16:12:23 +02:00
parent c15bf68d49
commit 5b97b5b966

View File

@ -1,36 +1,34 @@
# Dependencies for check and wheel introduce circular dependencies %global srcname setuptools
# Set this to 0 after we've bootstrapped.
%{!?_with_bootstrap: %global bootstrap 0}
%if ! 0%{?bootstrap} %bcond_with bootstrap
%global with_check 1 %bcond_without check
%global build_wheel 1
%else
%global with_check 0
%global build_wheel 0
%endif
%if 0%{?fedora} %bcond_without python2
%global with_python3 1 %bcond_without python3
%else
%if ! 0%{?fedora}
# disable Python 3 if not Fedora
%global _without_python3 1
# define some macros for RHEL 6 # define some macros for RHEL 6
%global __python2 %__python %global __python2 %__python
%global python2_sitelib %python_sitelib %global python2_sitelib %python_sitelib
%endif %endif
%global srcname setuptools %if %{without bootstrap}
%if 0%{?build_wheel} %global python_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
%global python2_wheelname %{srcname}-%{version}-py2.py3-none-any.whl %if %{with python2}
%global python2_wheelname %python_wheelname
%global python2_record %{python2_sitelib}/%{srcname}-%{version}.dist-info/RECORD %global python2_record %{python2_sitelib}/%{srcname}-%{version}.dist-info/RECORD
%if 0%{?with_python3} %endif
%global python3_wheelname %python2_wheelname %if %{with python3}
%global python3_wheelname %python_wheelname
%global python3_record %{python3_sitelib}/%{srcname}-%{version}.dist-info/RECORD %global python3_record %{python3_sitelib}/%{srcname}-%{version}.dist-info/RECORD
%endif %endif
%endif %endif
Name: python-setuptools Name: python-setuptools
Version: 36.2.0 Version: 36.2.0
Release: 3%{?dist} Release: 4%{?dist}
Summary: Easily build and distribute Python packages Summary: Easily build and distribute Python packages
Group: Applications/System Group: Applications/System
@ -39,28 +37,31 @@ URL: https://pypi.python.org/pypi/%{srcname}
Source0: https://files.pythonhosted.org/packages/source/s/%{srcname}/%{srcname}-%{version}.zip Source0: https://files.pythonhosted.org/packages/source/s/%{srcname}/%{srcname}-%{version}.zip
BuildArch: noarch BuildArch: noarch
%if %{with python2}
BuildRequires: python2-devel BuildRequires: python2-devel
%if 0%{?build_wheel} %if %{without bootstrap}
BuildRequires: python2-pip BuildRequires: python2-pip
BuildRequires: python2-wheel BuildRequires: python2-wheel
%endif %endif # without bootstrap
%if 0%{?with_check} %if %{with check}
BuildRequires: python2-pytest BuildRequires: python2-pytest
BuildRequires: python2-mock BuildRequires: python2-mock
BuildRequires: python2-backports-unittest_mock BuildRequires: python2-backports-unittest_mock
%endif # with_check %endif # with check
%endif # with python2
%if 0%{?with_python3} %if %{with python3}
BuildRequires: python3-devel BuildRequires: python3-devel
%if 0%{?with_check} %if %{with check}
BuildRequires: python3-pytest BuildRequires: python3-pytest
BuildRequires: python3-mock BuildRequires: python3-mock
%endif # with_check %endif # with check
%if 0%{?build_wheel} %if %{without bootstrap}
BuildRequires: python3-pip BuildRequires: python3-pip
BuildRequires: python3-wheel BuildRequires: python3-wheel
%endif # build_wheel %endif # without bootstrap
%endif # with_python3 %endif # with python3
# We're now back to setuptools as the package. # We're now back to setuptools as the package.
# Keep the python-distribute name active for a few releases. Eventually we'll # Keep the python-distribute name active for a few releases. Eventually we'll
@ -68,7 +69,6 @@ BuildRequires: python3-wheel
Provides: python-distribute = %{version}-%{release} Provides: python-distribute = %{version}-%{release}
Obsoletes: python-distribute < 0.6.36-2 Obsoletes: python-distribute < 0.6.36-2
%description %description
Setuptools is a collection of enhancements to the Python distutils that allow Setuptools is a collection of enhancements to the Python distutils that allow
you to more easily build and distribute Python packages, especially ones that you to more easily build and distribute Python packages, especially ones that
@ -77,9 +77,12 @@ have dependencies on other packages.
This package also contains the runtime components of setuptools, necessary to This package also contains the runtime components of setuptools, necessary to
execute the software that requires pkg_resources.py. execute the software that requires pkg_resources.py.
%if %{with python2}
%package -n python2-setuptools %package -n python2-setuptools
Summary: Easily build and distribute Python packages Summary: Easily build and distribute Python packages
%{?python_provide:%python_provide python2-setuptools} %{?python_provide:%python_provide python2-setuptools}
%description -n python2-setuptools %description -n python2-setuptools
Setuptools is a collection of enhancements to the Python distutils that allow Setuptools is a collection of enhancements to the Python distutils that allow
you to more easily build and distribute Python packages, especially ones that you to more easily build and distribute Python packages, especially ones that
@ -88,16 +91,15 @@ have dependencies on other packages.
This package also contains the runtime components of setuptools, necessary to This package also contains the runtime components of setuptools, necessary to
execute the software that requires pkg_resources.py. execute the software that requires pkg_resources.py.
%if 0%{?with_python3} %endif # with python2
%if %{with python3}
%package -n python3-setuptools %package -n python3-setuptools
Summary: Easily build and distribute Python 3 packages Summary: Easily build and distribute Python 3 packages
Group: Applications/System Group: Applications/System
%{?python_provide:%python_provide python3-setuptools} %{?python_provide:%python_provide python3-setuptools}
# Note: Do not need to Require python3-backports-ssl_match_hostname because it
# has been present since python3-3.2. We do not ship python3-3.0 or
# python3-3.1 anywhere
%description -n python3-setuptools %description -n python3-setuptools
Setuptools is a collection of enhancements to the Python 3 distutils that allow Setuptools is a collection of enhancements to the Python 3 distutils that allow
you to more easily build and distribute Python 3 packages, especially ones that you to more easily build and distribute Python 3 packages, especially ones that
@ -106,7 +108,8 @@ have dependencies on other packages.
This package also contains the runtime components of setuptools, necessary to This package also contains the runtime components of setuptools, necessary to
execute the software that requires pkg_resources.py. execute the software that requires pkg_resources.py.
%endif # with_python3 %endif # with python3
%prep %prep
%setup -q -n %{srcname}-%{version} %setup -q -n %{srcname}-%{version}
@ -130,27 +133,31 @@ rm -f setuptools/*.exe
# These tests require internet connection # These tests require internet connection
rm setuptools/tests/test_integration.py rm setuptools/tests/test_integration.py
%build %build
%if 0%{?build_wheel} %if %{with python2}
%if %{without bootstrap}
%py2_build_wheel %py2_build_wheel
%else %else
%py2_build %py2_build
%endif %endif
%endif # with python2
%if 0%{?with_python3} %if %{with python3}
%if 0%{?build_wheel} %if %{without bootstrap}
%py3_build_wheel %py3_build_wheel
%else %else
%py3_build %py3_build
%endif %endif
%endif # with_python3 %endif # with python3
%install %install
# Must do the python3 install first because the scripts in /usr/bin are # 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 # overwritten with every setup.py install (and we want the python2 version
# to be the default for now). # to be the default for now).
%if 0%{?with_python3} %if %{with python3}
%if 0%{?build_wheel} %if %{without bootstrap}
%py3_install_wheel %{python3_wheelname} %py3_install_wheel %{python3_wheelname}
# TODO: we have to remove this by hand now, but it'd be nice if we wouldn't have to # TODO: we have to remove this by hand now, but it'd be nice if we wouldn't have to
@ -163,46 +170,55 @@ sed -i '/\/usr\/bin\/easy_install,/d' %{buildroot}%{python3_record}
%endif %endif
rm -rf %{buildroot}%{python3_sitelib}/setuptools/tests rm -rf %{buildroot}%{python3_sitelib}/setuptools/tests
%if 0%{?build_wheel} %if %{without bootstrap}
sed -i '/^setuptools\/tests\//d' %{buildroot}%{python3_record} sed -i '/^setuptools\/tests\//d' %{buildroot}%{python3_record}
%endif %endif
find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -f find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -f
%endif # with_python3 %endif # with python3
%if 0%{?build_wheel}
%if %{with python2}
%if %{without bootstrap}
%py2_install_wheel %{python2_wheelname} %py2_install_wheel %{python2_wheelname}
%else %else
%py2_install %py2_install
%endif %endif
rm -rf %{buildroot}%{python2_sitelib}/setuptools/tests rm -rf %{buildroot}%{python2_sitelib}/setuptools/tests
%if 0%{?build_wheel} %if %{without bootstrap}
sed -i '/^setuptools\/tests\//d' %{buildroot}%{python2_record} sed -i '/^setuptools\/tests\//d' %{buildroot}%{python2_record}
%endif %endif
find %{buildroot}%{python2_sitelib} -name '*.exe' | xargs rm -f find %{buildroot}%{python2_sitelib} -name '*.exe' | xargs rm -f
%endif # with python2
# Don't ship these # Don't ship these
rm -r docs/{Makefile,conf.py,_*} rm -r docs/{Makefile,conf.py,_*}
%if 0%{?with_check}
%if %{with check}
%check %check
%if %{with python2}
#LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test #LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test
%endif # with python2
%if 0%{?with_python3} %if %{with python3}
LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test-%{python3_version} LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test-%{python3_version}
%endif # with_python3 %endif # with python3
%endif # with_check %endif # with check
%if %{with python2}
%files -n python2-setuptools %files -n python2-setuptools
%license LICENSE %license LICENSE
%doc docs/* CHANGES.rst README.rst %doc docs/* CHANGES.rst README.rst
%{python2_sitelib}/* %{python2_sitelib}/*
%{_bindir}/easy_install %{_bindir}/easy_install
%{_bindir}/easy_install-2.* %{_bindir}/easy_install-2.*
%endif # with python2
%if 0%{?with_python3} %if %{with python3}
%files -n python3-setuptools %files -n python3-setuptools
%license LICENSE CHANGES.rst README.rst %license LICENSE CHANGES.rst README.rst
%doc docs/* %doc docs/*
@ -211,9 +227,13 @@ LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test-%{python3_version}
%{python3_sitelib}/setuptools*/ %{python3_sitelib}/setuptools*/
%{python3_sitelib}/__pycache__/* %{python3_sitelib}/__pycache__/*
%{_bindir}/easy_install-3.* %{_bindir}/easy_install-3.*
%endif # with_python3 %endif # with python3
%changelog %changelog
* Wed Aug 09 2017 Tomas Orsava <torsava@redhat.com> - 36.2.0-4
- Switch macros to bcond's and make Python 2 optional to facilitate building
the Python 2 and Python 3 modules.
* Tue Aug 08 2017 Michal Cyprian <mcyprian@redhat.com> - 36.2.0-3 * Tue Aug 08 2017 Michal Cyprian <mcyprian@redhat.com> - 36.2.0-3
- Revert "Add --executable option to easy_install command" - Revert "Add --executable option to easy_install command"
This enhancement is currently not needed and it can possibly This enhancement is currently not needed and it can possibly