# HG changeset patch # User Mads Kiilerich # Date 2019-10-27 20:40:21 # Node ID 92a51a45d44cae7b63dfb06b5f73149433ce1edd # Parent e0812b032bcc4068ae67240daedf7d7f6dd91036 packaging: be explicit about Python version in rpm spec Fedora 31 has Python3 at /usr/bin/python ... but expect everybody to not just find python in $PATH but be explicit about whether they want python2 or python3. mercurial.spec just used 'python' and would fail when it unknowingly used Python 3 and ended up with Mercurial setup.py reporting "Python 3.7 detected." and talking about the HGPYTHON3 environment variable. For now, just be explicit about using system python2 as python executable when building rpms. diff --git a/contrib/packaging/mercurial.spec b/contrib/packaging/mercurial.spec --- a/contrib/packaging/mercurial.spec +++ b/contrib/packaging/mercurial.spec @@ -15,7 +15,8 @@ %else -%global pythonver %(python -c 'import sys;print(".".join(map(str, sys.version_info[:2])))') +%global pythonexe python2 +%global pythonver %(%{pythonexe} -c 'import sys;print(".".join(map(str, sys.version_info[:2])))') %endif @@ -52,7 +53,7 @@ for efficient handling of very large dis %if "%{?withpython}" %setup -q -n mercurial-%{version}-%{release} -a1 -a2 # despite the comments in cgi.py, we do this to prevent rpmdeps from picking /usr/local/bin/python up -sed -i '1c#! /usr/bin/env python' %{pythonname}/Lib/cgi.py +sed -i '1c#! /usr/bin/env %{pythonexe}' %{pythonname}/Lib/cgi.py %else %setup -q -n mercurial-%{version}-%{release} %endif @@ -82,9 +83,11 @@ export PYTHONPATH=$PWD/%{docutilsname} %endif -make all +make all PYTHON=%{pythonexe} make -C contrib/chg +sed -i -e '1s|#!/usr/bin/env python$|#!/usr/bin/env %{pythonexe}|' contrib/hg-ssh + %install rm -rf $RPM_BUILD_ROOT @@ -101,14 +104,14 @@ cd %{docutilsname} LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py install --root="$RPM_BUILD_ROOT" cd - -PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{hgpyprefix} MANDIR=%{_mandir} +PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install PYTHON=%{pythonexe} DESTDIR=$RPM_BUILD_ROOT PREFIX=%{hgpyprefix} MANDIR=%{_mandir} mkdir -p $RPM_BUILD_ROOT%{_bindir} ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/hg . ) ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/python2.? %{pythonhg} ) %else -make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir} +make install PYTHON=%{pythonexe} DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir} %endif