diff --git a/contrib/packaging/buildrpm b/contrib/packaging/buildrpm --- a/contrib/packaging/buildrpm +++ b/contrib/packaging/buildrpm @@ -11,6 +11,7 @@ BUILD=1 RPMBUILDDIR="$PWD/rpmbuild" +PYTHONEXE=python2 while [ "$1" ]; do case "$1" in @@ -18,6 +19,10 @@ while [ "$1" ]; do shift BUILD= ;; + --python3) + shift + PYTHONEXE=python3 + ;; --withpython | --with-python) shift PYTHONVER=2.7.16 @@ -96,6 +101,7 @@ rpmspec=$RPMBUILDDIR/SPECS/mercurial.spe sed -e "s,^Version:.*,Version: $version," \ -e "s,^Release:.*,Release: $release," \ + -e "s/^%global pythonexe .*/%global pythonexe $PYTHONEXE/" \ $specfile > $rpmspec echo >> $rpmspec diff --git a/contrib/packaging/mercurial.spec b/contrib/packaging/mercurial.spec --- a/contrib/packaging/mercurial.spec +++ b/contrib/packaging/mercurial.spec @@ -38,8 +38,8 @@ BuildRequires: make, gcc, gettext %if "%{?withpython}" BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel %else -BuildRequires: python >= 2.7, python-devel, python-docutils >= 0.5 -Requires: python >= 2.7 +BuildRequires: python >= %{pythonver}, python-devel, python-docutils >= 0.5 +Requires: python >= %{pythonver} %endif # The hgk extension uses the wish tcl interpreter, but we don't enforce it #Requires: tk @@ -60,6 +60,8 @@ sed -i '1c#! /usr/bin/env %{pythonexe}' %build +export HGPYTHON3=1 + %if "%{?withpython}" PYPATH=$PWD/%{pythonname} @@ -91,6 +93,8 @@ sed -i -e '1s|#!/usr/bin/env python$|#!/ %install rm -rf $RPM_BUILD_ROOT +export HGPYTHON3=1 + %if "%{?withpython}" PYPATH=$PWD/%{pythonname}