#5 F28: Don't build and ship Python 2 bits on EL > 7 and Fedora > 33
Closed 6 years ago by kevin. Opened 6 years ago by churchyard.
rpms/ churchyard/ansible nopy2  into  f28

file modified
+83 -36
@@ -5,9 +5,6 @@ 

  %global __python2 /usr/bin/python2.6

  %endif

  

- %if 0%{?rhel} <= 5

- %endif

- 

  %if 0%{?fedora} || 0%{?rhel} >= 8

  %global with_docs 1

  %else
@@ -20,12 +17,19 @@ 

  %global with_python3 0

  %endif

  

+ %if 0%{?fedora} >= 29 || 0%{?rhel} >= 8

+ %global with_python2 0

+ %global with_docs 0

+ # note that the docs are legacy python only as of 2.4.3.0

+ %else

+ %global with_python2 1

  %{!?python_sitelib: %global python_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

+ %endif

  

  Name: ansible

  Summary: SSH-based configuration management, deployment, and task execution system

  Version: 2.4.3.0

- Release: 2%{?dist}

+ Release: 3%{?dist}

  

  Group: Development/Libraries

  License: GPLv3+
@@ -40,6 +44,15 @@ 

  Url: http://ansible.com

  BuildArch: noarch

  

+ # This is needed to update the old ansible-firewall package that is no 

+ # longer needed. Note that you should also remove ansible-node-firewall manually

+ # Where you still have it installed. 

+ #

+ Provides: ansible-fireball = %{version}-%{release}

+ Obsoletes: ansible-fireball < 1.2.4

+ 

+ 

+ %if 0%{?with_python2}

  %if 0%{?rhel} && 0%{?rhel} <= 5

  # On RHEL6 use the python26 stack

  BuildRequires: python26-devel
@@ -125,22 +138,16 @@ 

  BuildRequires: python-simplejson

  %endif

  

- # 

- # This is needed to update the old ansible-firewall package that is no 

- # longer needed. Note that you should also remove ansible-node-firewall manually

- # Where you still have it installed. 

- #

- Provides: ansible-fireball = %{version}-%{release}

- Obsoletes: ansible-fireball < 1.2.4

  

  %description

- 

  Ansible is a radically simple model-driven configuration management,

  multi-node deployment, and remote task execution system. Ansible works

  over SSH and does not require any software or daemons to be installed

  on remote nodes. Extension modules can be written in any language and

  are transferred to managed machines automatically.

  

+ %endif # python2

+ 

  

  %if 0%{?with_python3}

  # Note, ansible is not intended to be used as a library so avoiding the
@@ -150,8 +157,16 @@ 

  # versions of ansible should behave identically but python3-only bugs may be present.

  # So upstream would like us to ship both py2 and py3 ansible (at least in

  # rawhide) for people to beat on and find bugs.

+ 

+ # However, for future ELs and Fedoras, we want Python 3 only

+ %if 0%{?with_python2}

  %package -n ansible-python3

  Summary: SSH-based configuration management, deployment, and task execution system

+ %else

+ Provides:      ansible-python3 = %{version}-%{release}

+ Obsoletes:     ansible-python3 < %{version}-%{release}

+ %endif

+ 

  BuildRequires: python3-devel

  BuildRequires: python3-setuptools

  
@@ -167,6 +182,7 @@ 

  BuildRequires: python3-pytest

  BuildRequires: python3-pytest-xdist

  BuildRequires: python3-pytest-mock

+ BuildRequires: python3-requests

  BuildRequires: python3-coverage

  BuildRequires: python3-mock

  BuildRequires: python3-boto3
@@ -186,11 +202,13 @@ 

  Requires: sshpass

  # needed for json_query filter

  Requires: python3-jmespath

- %endif

  

  

- %if 0%{?with_python3}

+ %if 0%{?with_python2}

  %description -n ansible-python3

+ %else

+ %description

+ %endif

  

  Ansible is a radically simple model-driven configuration management,

  multi-node deployment, and remote task execution system. Ansible works
@@ -199,7 +217,7 @@ 

  are transferred to managed machines automatically.

  

  This package installs versions of ansible that execute on Python3.

- %endif  # with_python3

+ %endif # python3

  

  %package -n ansible-doc

  Summary: Documentation for Ansible
@@ -227,15 +245,25 @@ 

  %endif # with_python3

  

  %build

+ %if 0%{?with_python2}

  %{__python2} setup.py build

  # Build docs

  # EPEL6/7 don't have a recent enough sphinx to build the docs

  %if %with_docs

    make webdocs

  %endif

+ %endif

  

  %if 0%{?with_python3}

+ pushd %{py3dir}

  %py3_build

+ 

+ %if %with_docs && ! 0%{?with_python2}

+   pathfix.py -i %{__python3} -p docs/bin

+   make webdocs

+ %endif

+ 

+ popd

  %endif # with_python3

  

  
@@ -247,23 +275,32 @@ 

  

  for i in $RPM_BUILD_ROOT/%{_bindir}/ansible* ; do

      if [ $(basename $i) = "ansible-connection" -o $(basename $i) = "ansible" ] ; then

-         mv $i $i-%{python3_version}

+         %if 0%{?with_python2}

+             mv $i $i-%{python3_version}

+         %else

+             # for backwards compatibility

+             ln -s $(basename $i) $i-%{python3_version}

+         %endif

          ln -s %{_bindir}/$(basename $i)-%{python3_version} $i-3

+     %if 0%{?with_python2}

      else

          # The ansible commands are themselves symlinks to /usr/bin/ansible.

          # Need to change them to point to the python3 version

          ln -s %{_bindir}/ansible-3 $i-%{python3_version}

          ln -s %{_bindir}/$(basename $i)-%{python3_version} $i-3

+     %endif

      fi

  done

  %endif # with_python3

  

+ %if 0%{?with_python2}

  %{__python2} setup.py install --root=$RPM_BUILD_ROOT

  for i in $RPM_BUILD_ROOT/%{_bindir}/{ansible,ansible-console,ansible-doc,ansible-galaxy,ansible-playbook,ansible-pull,ansible-vault}  ; do

      mv $i $i-%{python2_version}

      ln -s %{_bindir}/$(basename $i)-%{python2_version} $i

      ln -s %{_bindir}/$(basename $i)-%{python2_version} $i-2

  done

+ %endif

  

  mkdir -p $RPM_BUILD_ROOT/etc/ansible/

  mkdir -p $RPM_BUILD_ROOT/etc/ansible/roles/
@@ -282,50 +319,57 @@ 

  # RHEL <= 6 doesn't have a new enough python-mock to run the tests

  # Currently RHEL <= 7 doesn't have pytest-xdist or a new enough pytest

  # Fedora 25 doesn't have a new enough pytest

- %if 0%{?fedora} >= 26 || 0%{?rhel} >= 8

- if test -z $(which pytest) ; then

-   mkdir tests_bin

-   pushd tests_bin

-   ln -s `which py.test` pytest

-   export PATH=$PATH:$(pwd)

-   popd

- fi

+ %if 0%{?with_python2} && 0%{?fedora} >= 26

+ mkdir tests_bin

+ pushd tests_bin

+ ln -s `which pytest-2` pytest

+ export PATH=$PATH:$(pwd)

+ popd

+ 

  make tests

+ %endif  # New enough Fedora with python2

  

  %if 0%{?with_python3}

  pushd %{py3dir}

- if test -z $(which pytest) ; then

-   mkdir tests_bin

-   pushd tests_bin

-   ln -s `which py.test` pytest

-   export PATH=$PATH:$(pwd)

-   popd

- fi

+ 

+ mkdir tests_bin

+ pushd tests_bin

+ # this is a hack and should be done differently!

+ ln -s `which pytest-3` pytest

+ ln -s %{__python3} python

+ ln -s %{__python3} python2

+ export PATH=$PATH:$(pwd)

+ popd

+ 

  make tests

+ popd

  %endif  # python3

  

- %endif  # New enough Fedora/RHEL

  

  

  %files

  %defattr(-,root,root)

+ %if 0%{?with_python2}

  %{python_sitelib}/ansible*

+ %endif

  %{_bindir}/ansible*

- %if 0%{?with_python3}

+ %if 0%{?with_python3} && 0%{?with_python2}

  %exclude %{_bindir}/ansible*-3*

- %endif  # python3

+ %endif  # python3 and 2

  %config(noreplace) %{_sysconfdir}/ansible/

  %doc README.md PKG-INFO COPYING CHANGELOG.md

  %doc %{_mandir}/man1/ansible*

  

  %if 0%{?with_python3}

+ %if 0%{?with_python2}

  %files -n ansible-python3

  %defattr(-,root,root,-)

- %{python3_sitelib}/ansible*

- %{_bindir}/ansible*-3*

  %config(noreplace) %{_sysconfdir}/ansible/

  %doc README.md PKG-INFO COPYING CHANGELOG.md

  %doc %{_mandir}/man1/ansible*

+ %{_bindir}/ansible*-3*

+ %endif # python2

+ %{python3_sitelib}/ansible*

  %endif  # python3

  

  %files -n ansible-doc
@@ -335,6 +379,9 @@ 

  %endif

  

  %changelog

+ * Fri Mar 16 2018 Miro Hrončok <mhroncok@redhat.com> - 2.4.3.0-3

+ - Don't build and ship Python 2 bits on EL > 7 and Fedora > 28

+ 

  * Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.3.0-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild