[CRIU] [PATCH 2/2] crit: use whatever python version is default
Adrian Reber
areber at redhat.com
Sat May 4 13:10:18 MSK 2019
On Fri, May 03, 2019 at 04:22:03PM -0700, Kirill Kolyshkin wrote:
> On Fri, 3 May 2019 at 09:13, Adrian Reber <areber at redhat.com> wrote:
>
> > The reason for all this mess is, is that usually the unversioned python
> > binary is always python2. Almost never python3.
> >
> > Neither on Fedora nor on Ubuntu (18.04) python points to python3. I also
> > think upstream python says that the python3 binary should always be
> > versioned.
> >
> > So, for development I can create a link python -> python3, but this is
> > not really a solution for packaging crit. Although, for Fedora, I could
> > replace 'python' with python3 during packaging, but I already have
> > problems with zdtm all the time because it uses an unversioned binary.
> > Which we agreed to be acceptable as it is never shipped.
> >
> > It is still not clear to me how to correctly ship code for
> > python2/python3 at the same time without some hack to change the
> > shebang.
> >
> > So, I am against this change.
> >
>
> I don't understand the problem. Are you implying that crit is not working
> with python2?
No, not at all.
> After the first commit from this series it should work fine with either 2
> or 3.
Most of CRIU was already working with python3 (except coredump and few
test scripts).
> Or am I missing something obvious?
You changed crit to use '#!/usr/bin/env python'. This never (most of the
time) means python3. So even if the code works with python3, the binary
behind python will not be python3, but most of the time python2.
On a system with only python3 crit will no longer work after make
install.
Reading https://www.python.org/dev/peps/pep-0394/ it says that python
should point to python2.
It also says that on Arch Linux python might point to python3, but it
does not sound like upstream Python recommends that.
It seems every distribution does it differently, but it cannot be
expected that python will point to python3 if on a python3-only system.
So for a successful 'make install' we need some way to change the
shebang of crit to point to the right python version. The python version
CRIU was build with.
Hope it makes now more sense.
Adrian
> > On Fri, May 03, 2019 at 08:28:37AM -0700, Kir Kolyshkin wrote:
> > > Now crit should work equally well with either python 2 or 3,
> > > so the python2/3 hack for crit is no longer needed.
> > >
> > > This reverts commit 4feb07020dedbf845fc00268d8ca02f4645641cd
> > > ("crit: enable python2 or python3 based crit"), and changes
> > > `python2` to `python`.
> > >
> > > Cc: Adrian Reber <areber at redhat.com>
> > > Signed-off-by: Kir Kolyshkin <kolyshkin at gmail.com>
> > > ---
> > > .gitignore | 1 -
> > > Makefile | 17 ++++-------------
> > > crit/Makefile | 13 -------------
> > > lib/py/cli.py => crit/crit | 1 +
> > > crit/crit-python2 | 6 ------
> > > crit/crit-python3 | 6 ------
> > > 6 files changed, 5 insertions(+), 39 deletions(-)
> > > delete mode 100644 crit/Makefile
> > > rename lib/py/cli.py => crit/crit (99%)
> > > delete mode 100755 crit/crit-python2
> > > delete mode 100755 crit/crit-python3
> > >
> > > diff --git a/.gitignore b/.gitignore
> > > index c231104af..048668905 100644
> > > --- a/.gitignore
> > > +++ b/.gitignore
> > > @@ -24,7 +24,6 @@ images/google/protobuf/*.c
> > > images/google/protobuf/*.h
> > > .gitid
> > > criu/criu
> > > -crit/crit
> > > criu/arch/*/sys-exec-tbl*.c
> > > # x86 syscalls-table is not generated
> > > !criu/arch/x86/sys-exec-tbl.c
> > > diff --git a/Makefile b/Makefile
> > > index 38887da99..ce03fa4c0 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -127,7 +127,7 @@ HOSTCFLAGS += $(WARNINGS) $(DEFINES)
> > -iquote include/
> > > export CFLAGS USERCLFAGS HOSTCFLAGS
> > >
> > > # Default target
> > > -all: criu lib crit
> > > +all: criu lib
> > > .PHONY: all
> > >
> > > #
> > > @@ -228,22 +228,14 @@ criu: $(criu-deps)
> > > $(Q) $(MAKE) $(build)=criu all
> > > .PHONY: criu
> > >
> > > -crit/Makefile: ;
> > > -crit/%: criu .FORCE
> > > - $(Q) $(MAKE) $(build)=crit $@
> > > -crit: criu
> > > - $(Q) $(MAKE) $(build)=crit all
> > > -.PHONY: crit
> > > -
> > > -
> > > #
> > > -# Libraries next once crit it ready
> > > +# Libraries next once criu it ready
> > > # (we might generate headers and such
> > > # when building criu itself).
> > > lib/Makefile: ;
> > > -lib/%: crit .FORCE
> > > +lib/%: criu .FORCE
> > > $(Q) $(MAKE) $(build)=lib $@
> > > -lib: crit
> > > +lib: criu
> > > $(Q) $(MAKE) $(build)=lib all
> > > .PHONY: lib
> > >
> > > @@ -255,7 +247,6 @@ clean mrproper:
> > > $(Q) $(MAKE) $(build)=compel $@
> > > $(Q) $(MAKE) $(build)=compel/plugins $@
> > > $(Q) $(MAKE) $(build)=lib $@
> > > - $(Q) $(MAKE) $(build)=crit $@
> > > .PHONY: clean mrproper
> > >
> > > clean-top:
> > > diff --git a/crit/Makefile b/crit/Makefile
> > > deleted file mode 100644
> > > index 988b481b6..000000000
> > > --- a/crit/Makefile
> > > +++ /dev/null
> > > @@ -1,13 +0,0 @@
> > > -
> > > -all-y += crit
> > > -
> > > -crit/crit: crit/crit-$(PYTHON)
> > > - $(Q) cp $^ $@
> > > -crit: crit/crit
> > > -.PHONY: crit
> > > -
> > > -clean-crit:
> > > - $(Q) $(RM) crit/crit
> > > -.PHONY: clean-crit
> > > -clean: clean-crit
> > > -mrproper: clean
> > > diff --git a/lib/py/cli.py b/crit/crit
> > > similarity index 99%
> > > rename from lib/py/cli.py
> > > rename to crit/crit
> > > index 29b21ec8f..28007217a 100755
> > > --- a/lib/py/cli.py
> > > +++ b/crit/crit
> > > @@ -1,3 +1,4 @@
> > > +#!/usr/bin/env python
> > > from __future__ import print_function
> > > from builtins import object
> > > import argparse
> > > diff --git a/crit/crit-python2 b/crit/crit-python2
> > > deleted file mode 100755
> > > index b0b7d3c3a..000000000
> > > --- a/crit/crit-python2
> > > +++ /dev/null
> > > @@ -1,6 +0,0 @@
> > > -#!/usr/bin/env python2
> > > -
> > > -from pycriu import cli
> > > -
> > > -if __name__ == '__main__':
> > > - cli.main()
> > > diff --git a/crit/crit-python3 b/crit/crit-python3
> > > deleted file mode 100755
> > > index 80467cba7..000000000
> > > --- a/crit/crit-python3
> > > +++ /dev/null
> > > @@ -1,6 +0,0 @@
> > > -#!/usr/bin/env python3
> > > -
> > > -from pycriu import cli
> > > -
> > > -if __name__ == '__main__':
> > > - cli.main()
> > > --
> > > 2.17.1
> > >
> >
More information about the CRIU
mailing list