[CentOS-devel] RHEL 8, and potentially CentOS 8, lack "/usr/bin/python"

Sun May 12 09:02:26 UTC 2019
Phil Perry <pperry at elrepo.org>

On 12/05/2019 04:45, Nico Kadel-Garcia wrote:
> Good evening:
> 
> Even though Fedora still has a default /usr/bin/python, which has
> admittedly changed to a link to /usr/bin/python3 for recent releases,
> I see that RHEL 8 has no /usr/bin/python. This is going to break a
> *lot* SRPM's and older python scripts. It's especially going to mess
> up old "__python" configuration macros for .spec files.
> 
> I'd not realized this when I started testing. Heads up, a *lot* of
> EPEL .spec files are going to need updates.
> 

Correct, there is no default 'python' in RHEL8 - you have python2 and 
python3, and you get to decide which you wish to use. This is well 
documented and there have been a lot of RH articles and blog postings 
about it. See for example:

https://developers.redhat.com/blog/2018/11/14/python-in-rhel-8/

If you are packaging software, you will need to decide if you wish to 
build against python2, python3 or both (that's going to be fun) and 
specify that explicitly. For example, we needed to patch the mock SPEC 
file when porting the latest version of mock from fedora to RHEL8 to 
explicitly specify python2 and/or python3.

The good news is the errors are pretty obvious:

*** ERROR: ambiguous python shebang in /usr/libexec/mock/mock: 
#!/usr/bin/python -tt. Change it to python3 (or python2) explicitly.
*** ERROR: ambiguous python shebang in /usr/bin/mockchain: 
#!/usr/bin/python -tt.

and was easily fixed by explicitly specifying python2 instead of python 
in the code segment below:

%setup -q
%if %{use_python2}
for file in py/mock.py py/mockchain.py; do
sed -i 1"s|#!/usr/bin/python3 |#!/usr/bin/python |" $file
done
%endif