From 53899096c8d08af78dd2a5e69b4339b7725df7aa Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Mon, 5 Aug 2019 21:39:10 +0200 Subject: [PATCH] Prepare Mercurial for Py2 & Py3 - separate lang into the own subpackage as files are shared between mercurial for both pythons - extensions are now prepared and working only under Python2 - the core mercurial is prepared in mercurial-python3 subpackage providing the hg3 executable - Relates: #1737931 --- 0001-setup-hg3.patch | 37 ++++++++++++++++++++ contrib-hg-ssh.patch | 4 +-- hgk_python3.patch | 13 +++++++ mercurial.spec | 83 ++++++++++++++++++++++++++++++++++++++------ 4 files changed, 124 insertions(+), 13 deletions(-) create mode 100644 0001-setup-hg3.patch create mode 100644 hgk_python3.patch diff --git a/0001-setup-hg3.patch b/0001-setup-hg3.patch new file mode 100644 index 0000000..699dfb3 --- /dev/null +++ b/0001-setup-hg3.patch @@ -0,0 +1,37 @@ +From 313f85a013b487149bff441411d4b643d0cea6c2 Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Thu, 15 Aug 2019 01:20:11 +0200 +Subject: [PATCH] create hg3 bin/script to keep Py2 & Py3 mercurial + installable.. + +This can be removed completely once the mercurial for Python2 is +removed +--- + setup.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/setup.py b/setup.py +index 99556ce..5e30421 100644 +--- a/setup.py ++++ b/setup.py +@@ -207,6 +207,8 @@ def write_if_changed(path, content): + fh.write(content) + + scripts = ['hg'] ++if 'HGPYTHON3' in os.environ: ++ scripts = ['hg3'] + if os.name == 'nt': + # We remove hg.bat if we are able to build hg.exe. + scripts.append('contrib/win32/hg.bat') +@@ -311,6 +313,8 @@ def findhg(): + hgenv['HGPLAIN'] = '1' + hgenv['LANGUAGE'] = 'C' + hgcmd = ['hg'] ++ if 'HGPYTHON3' in os.environ: ++ hgcmd = ['hg3'] + # Run a simple "hg log" command just to see if using hg from the user's + # path works and can successfully interact with this repository. Windows + # gives precedence to hg.exe in the current directory, so fall back to the +-- +2.21.0 + diff --git a/contrib-hg-ssh.patch b/contrib-hg-ssh.patch index f03c835..aabca62 100644 --- a/contrib-hg-ssh.patch +++ b/contrib-hg-ssh.patch @@ -3,8 +3,8 @@ diff -r 9d3628141c21 contrib/hg-ssh +++ b/contrib/hg-ssh Tue Mar 05 07:26:54 2019 -0500 @@ -1,4 +1,4 @@ -#!/usr/bin/env python -+#!/usr/bin/env python2 ++#!/usr/bin/env python3 # # Copyright 2005-2007 by Intevation GmbH # - \ No newline at end of file + diff --git a/hgk_python3.patch b/hgk_python3.patch new file mode 100644 index 0000000..f82ab36 --- /dev/null +++ b/hgk_python3.patch @@ -0,0 +1,13 @@ +diff --git a/hgext/hgk.py b/hgext/hgk.py +index 3da626e..61239e8 100644 +--- a/hgext/hgk.py ++++ b/hgext/hgk.py +@@ -335,7 +335,7 @@ def revtree(ui, args, repo, full="tree", maxnr=0, parents=False): + ('[OPTION]... REV...')) + def revlist(ui, repo, *revs, **opts): + """print revisions""" +- if opts['header']: ++ if opts[u'header']: + full = "commit" + else: + full = None diff --git a/mercurial.spec b/mercurial.spec index 47f805a..deb88f0 100644 --- a/mercurial.spec +++ b/mercurial.spec @@ -1,4 +1,5 @@ %{!?python2_sitearch: %define python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python2_lib; print get_python2_lib(1)")} +%{!?python3_sitearch: %define python3_sitearch %(%{__python3} -c "from distutils.sysconfig import get_python3_lib; print(get_python3_lib(1))")} Summary: Mercurial -- a distributed SCM Name: mercurial @@ -16,10 +17,13 @@ URL: http://www.selenic.com/mercurial/ Source0: http://www.selenic.com/mercurial/release/%{name}-%{upstreamversion}.tar.gz Source1: mercurial-site-start.el Patch0: contrib-hg-ssh.patch +Patch1: hgk_python3.patch +Patch2: 0001-setup-hg3.patch BuildRequires: python2 python2-devel bash-completion BuildRequires: emacs-nox emacs-el pkgconfig gettext python2-docutils BuildRequires: gcc Requires: python2 emacs-filesystem +Requires: %{name}-lang = %{version}-%{release} Provides: hg = %{version}-%{release} Obsoletes: emacs-mercurial <= 3.4.1, emacs-mercurial-el <= 3.4.1 Provides: emacs-mercurial <= 3.4.1, emacs-mercurial-el <= 3.4.1 @@ -36,11 +40,22 @@ Extensions: http://www.selenic.com/mercurial/wiki/index.cgi/CategoryExtension # If the emacs-el package has installed a pkgconfig file, use that to determine +%package py3 +Summary: Mercurial -- a distributed SCM for Python3 +Provides: hg3 = %{version}-%{release} +Requires: python3 emacs-filesystem +BuildRequires: python3 python3-devel bash-completion +BuildRequires: emacs-nox emacs-el pkgconfig gettext python3-docutils +Requires: %{name}-lang = %{version}-%{release} + +%description py3 +Subpackage with mercurial for Python3. This is beta version with own problems. + + %package hgk Summary: Hgk interface for mercurial Requires: hg = %{version}-%{release}, tk - %description hgk A Mercurial extension for displaying the change history graphically using Tcl/Tk. Displays branches and merges in an easily @@ -51,6 +66,7 @@ Adds the "hg view" command. See http://www.selenic.com/mercurial/wiki/index.cgi/UsingHgk for more documentation. + %package chg Summary: A fast client for Mercurial command server running on Unix. It saves time of slow Python startup. Requires: hg = %{version}-%{release} @@ -65,25 +81,44 @@ Mercurial. When you type chg, a C program connects to that background process and executes Mercurial commands. +%package lang +Summary: Locales for mercurial + +%description lang +Locales for mercurial. + %prep %setup -q -n %{name}-%{upstreamversion} -# Patch files to use python2 instead of (since lately) non existent python binary. -sed -ri 's|python\b|python2|' %{_builddir}/%{name}-%{version}/Makefile %{_builddir}/%{name}-%{version}/doc/Makefile +# NOTE: Use PYTHON envar instead of pathing Makefiles +# sed -ri 's|python\b|python2|' %{_builddir}/%{name}-%{version}/Makefile %{_builddir}/%{name}-%{version}/doc/Makefile %patch0 -p1 -b .contrib-hg-ssh +# NOTE: The patch1 cannot be applied here as it has to be kept as it is for py2 version.. +# %%patch1 -p1 -b .hgk_python3 +%patch2 -p1 -b .create_hg3 %build -make all +# copy hg to hg3 to be able to create /usr/bin/hg3 script +cp -a hg hg3 +PYTHON=%{__python3} HGPYTHON3=1 make all +PYTHON=%{__python2} make all +#TODO: Now just for Py2, version for Py3 will need probably more fixes +# in installer - and possibly some renames.. pushd contrib/chg make popd %install +# NOTE: this is nasty, but if we want to have parallel Py2/Py3 mercurial.. +# ignoring now stuff related to *_completion, extensions rm -rf $RPM_BUILD_ROOT +HGPYTHON3=1 %{__python3} setup.py install -O1 --root $RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}3.files %{__python2} setup.py install -O1 --root $RPM_BUILD_ROOT --prefix %{_prefix} --record=%{name}.files make install-doc DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} +grep -v -e 'hgk.py*' -e %{python3_sitearch}/mercurial/ -e %{python3_sitearch}/hgext/ < %{name}3.files > %{name}3-base.files grep -v -e 'hgk.py*' -e %{python2_sitearch}/mercurial/ -e %{python2_sitearch}/hgext/ < %{name}.files > %{name}-base.files +grep 'hgk.py*' < %{name}3.files > %{name}3-hgk.files grep 'hgk.py*' < %{name}.files > %{name}-hgk.files install -D -m 755 contrib/hgk $RPM_BUILD_ROOT%{_libexecdir}/mercurial/hgk @@ -134,25 +169,31 @@ cacerts = /etc/pki/tls/certs/ca-bundle.crt EOF install -m 644 certs.rc $RPM_BUILD_ROOT/%{_sysconfdir}/mercurial/hgrc.d +# NOTE: It looks that locales will have to be moved into the separate subpackage, +# despite the original path, locales should not be dependend on the version of +# python, so we can use one or the other for both mercurials +#mv $RPM_BUILD_ROOT%{python3_sitearch}/mercurial/locale $RPM_BUILD_ROOT%{_datadir}/locale mv $RPM_BUILD_ROOT%{python2_sitearch}/mercurial/locale $RPM_BUILD_ROOT%{_datadir}/locale +rm -rf $RPM_BUILD_ROOT%{python3_sitearch}/mercurial/locale rm -rf $RPM_BUILD_ROOT%{python2_sitearch}/mercurial/locale %find_lang hg grep -v locale %{name}-base.files > %{name}-base-filtered.files +grep -v locale %{name}3-base.files > %{name}3-base-filtered.files -%files -f %{name}-base-filtered.files -f hg.lang +%files -f %{name}-base-filtered.files %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html *.cgi contrib/*.fcgi contrib/*.wsgi %doc %attr(644,root,root) %{_mandir}/man?/hg*.gz %doc %attr(644,root,root) contrib/*.svg -%{_datadir}/zsh/site-functions/_mercurial -%{_bindir}/hg-ssh -%{_datadir}/bash-completion/ %dir %{_datadir}/zsh/ -%{_datadir}/zsh/site-functions/ +%dir %{_datadir}/zsh/site-functions/ %dir %{_sysconfdir}/mercurial %dir %{_sysconfdir}/mercurial/hgrc.d +%{_bindir}/hg-ssh +%{_datadir}/bash-completion/ +%{_datadir}/zsh/site-functions/_mercurial %{python2_sitearch}/mercurial %{python2_sitearch}/hgext %{_emacs_sitelispdir}/mercurial @@ -160,6 +201,10 @@ grep -v locale %{name}-base.files > %{name}-base-filtered.files %config(noreplace) %{_sysconfdir}/mercurial/hgrc.d/certs.rc +%files py3 -f %{name}3-base-filtered.files +%{python3_sitearch}/mercurial +%{python3_sitearch}/hgext + %files hgk -f %{name}-hgk.files %{_libexecdir}/mercurial/ %{_sysconfdir}/mercurial/hgrc.d/hgk.rc @@ -168,11 +213,27 @@ grep -v locale %{name}-base.files > %{name}-base-filtered.files %{_bindir}/chg %doc %attr(644,root,root) %{_mandir}/man?/chg.*.gz +%files lang -f hg.lang + + +#%%check +#cd tests && %%{__python2} run-tests.py +# This will now fail everytime. Mercurial is not ported properly for Python3 +# and current split of mercurial for Py2 and Py3 brings additional problems +# for extensions then pure Python3 packaging. +#cd tests && HGPYTHON3=1 %%{__python3} run-tests.py -##%%check -##cd tests && %%{__python} run-tests.py %changelog +* Sat Oct 19 2019 Petr Stodulka - 5.1.2-2 +- first attempt to create builds for py2 & py3 version +- separate lang into the own subpackage as files are shared between + mercurial for both pythons +- extensions are now prepared and working only under Python2 +- the core mercurial is prepared in mercurial-python3 subpackage providing + the hg3 executable +- Relates: #1737931 + * Sat Oct 19 2019 Petr Stodulka - 5.1.2-1 - Update to 5.1.2 - fix patching of Makefiles