xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] Xen Release 4.12.2 and Python 3: M4 python_devel module and mkheader.py issues
@ 2020-01-19  6:17 Kevin Buckley
  2020-01-22 12:36 ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buckley @ 2020-01-19  6:17 UTC (permalink / raw)
  To: xen-devel

Following on from some previous observations on building Xen from
source a Linux From Scratch system, I have some more feedback
when using a more up-to-date Xen and the most recent LFS.

On the back of trying to build Xen 4.12.2 on an LFS 9.0 system,
I've hit an issue in the way that the Xen M4 python_devel module
gets a version number, and then, I think, constructs the shared
library name that it tries to use in 'configure' incorrectly.

The first issue is that Xen's M4 python_devel module tries to
get a version number for "$PYTHON" by doing

> head ../m4/python_devel.m4
AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [
ac_previous_cppflags=$CPPFLAGS
ac_previous_ldflags=$LDFLAGS
ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \
    print distutils.sysconfig.get_config_var("VERSION")'`
AC_PATH_PROG([pyconfig], [$PYTHON-config], [no])
...


That fails as follows

...
checking for unistd.h... yes
  File "<string>", line 1
    import distutils.sysconfig;     print distutils.sysconfig.get_config_var("VE
RSION")

                                                  ^
SyntaxError: invalid syntax
checking for python3-config... /usr/bin/python3-config
..


If we check out the command in an interactive interpeter session,
we can identify the problen here, vis


> python3
Python 3.7.4 (default, Nov 17 2019, 18:19:17)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils.sysconfig
>>> distutils.sysconfig.get_config_var("VERSION")
'3.7'
>>>
>>> print distutils.sysconfig.get_config_var("VERSION")'
  File "<stdin>", line 1
    print distutils.sysconfig.get_config_var("VERSION")'
                  ^
SyntaxError: invalid syntax
>>> print(distutils.sysconfig.get_config_var("VERSION"))
3.7
>>> quit()

which suggests that the issue comes from the "print" statement,
not the distutils module.


It is fairly easy to fix the syntax there, by patching Xen's
M4 python_devel module to have parentheses around the argument
to the print command, vis:


ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \
    print(distutils.sysconfig.get_config_var("VERSION"))'`


however,  now that the Python interpreter is returning "3.7"
as the "version", Xen's configure script goes on to run some
tests as follows

...
checking for unistd.h... yes
checking for python3-config... /usr/bin/python3-config
checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython3.7... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

and here's the actual (from tools/config.log) command that's being
run as the test


configure:7456: checking for PyArg_ParseTuple in -lpython3.7
configure:7481: gcc -o conftest -g -O2 -g -O2 \
 -I/usr/include/python3.7m -I/usr/include/python3.7m  \
 -Wno-unused-result -Wsign-compare  -DNDEBUG -g -fwrapv \
 -O3 -Wall     -L/usr/lib -lpython3.7m -lcrypt -lpthread \
 -ldl  -lutil -lm  conftest.c -lpython3.7  -lpython3.7m \
 -lcrypt -lpthread -ldl  -lutil -lm   >&5
/usr/bin/ld: cannot find -lpython3.7



So here's the issue:

in LFS 9.0, Section 6.51, Python-3.7.4 we read

  6.51.2. Contents of Python 3

  Installed Programs: 2to3, idle3, pip3, pydoc3, python3, python3-config,
    and pyvenv

  Installed Library: libpython3.7m.so and libpython3.so

  Installed Directories: /usr/include/python3.7m, /usr/lib/python3
    and /usr/share/doc/python-3.7.4

and, on the LFS system, we indeed have

> ls -o /usr/lib/libpython3.*
lrwxrwxrwx 1 python3      20 Nov 17 18:20 /usr/lib/libpython3.7m.so -> libpython
3.7m.so.1.0
-rwxr-xr-x 1 python3 3265256 Nov 17 20:10 /usr/lib/libpython3.7m.so.1.0
-rwxr-xr-x 1 python3   13984 Nov 17 20:10 /usr/lib/libpython3.so


Note that the library names end in 3.7m, not 3.7.

Clearly then, with  the distutils module returning the version
as "3.7", the Xen configure script goes on to look to link against

  -lpython3.7

and not

  -lpython3.7m


It's fairly easy to add a link

   /usr/lib/libpython3.7.so -> libpython3.7m.so.1.0

that will see what Python's distutils module tells Xen it's version
is, match with the library that Xen then decides it should be looking
for but, given that using "python3-config" to get the LDFLAGS,

> /usr/bin/python3-config --ldflags
 -L/usr/lib -lpython3.7m -lcrypt -lpthread -ldl  -lutil -lm
>

would have suppiled the correct name, it might be worth taking
a look at the use of Python's distutils module in the M4 module.


But let's move on.

Having patched Xen's M4 python_devel module to have parentheses
around the argument to the print command, and having created a
link for the name that Xen's configure script will look for, I've
encountered another error within the "make", vis:

> PYTHON=/usr/bin/python3 \
  ./configure --prefix=/usr    \
  --disable-seabios          \
  --disable-qemu-traditional \
  --disable-rombios          \
  --disable-stubdom

> make \
    PYTHON=/usr/bin/python3 \
    EFI_DIR=/usr/lib/efi
...
 make[2]: Leaving directory
'/usr/src/xen/xen-RELEASE-4.12.2/tools/include/xen/lib/x86'
make -C xen-foreign
make[2]: Entering directory
'/usr/src/xen/xen-RELEASE-4.12.2/tools/include/xen-foreign'
/usr/bin/python3 mkheader.py arm32 arm32.h.tmp
/usr/src/xen/xen-RELEASE-4.12.2/tools/include/xen-foreign/../../../xen/include/public/arch-arm.h
/usr/src/xen/xen-RELEASE-4.12.2/tools/include/xen-foreign/../../../xen/include/public/xen.h
Traceback (most recent call last):
  File "mkheader.py", line 209, in <module>
    integers.sort(lambda a, b: cmp(len(b),len(a)));
AttributeError: 'dict_keys' object has no attribute 'sort'
make[2]: *** [Makefile:28: arm32.h] Error 1
make[2]: Leaving directory
'/usr/src/xen/xen-RELEASE-4.12.2/tools/include/xen-foreign'
make[1]: *** [Makefile:13: xen-foreign] Error 2
make[1]: Leaving directory '/usr/src/xen/xen-RELEASE-4.12.2/tools/include'
make: *** [Makefile:44: install-tools-public-headers] Error 2


This one, I'm less able to diagnose, although a "sort" does sound
like something that a 'dict_keys' object should have?


Any clues then, as to whether this is another Python3 hangover for Xen ?

Kevin

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] Xen Release 4.12.2 and Python 3: M4 python_devel module and mkheader.py issues
  2020-01-19  6:17 [Xen-devel] Xen Release 4.12.2 and Python 3: M4 python_devel module and mkheader.py issues Kevin Buckley
@ 2020-01-22 12:36 ` Andrew Cooper
  2020-01-28  8:45   ` Kevin Buckley
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2020-01-22 12:36 UTC (permalink / raw)
  To: Kevin Buckley, xen-devel

On 19/01/2020 06:17, Kevin Buckley wrote:
> Any clues then, as to whether this is another Python3 hangover for Xen ?

Xen 4.13 (now released) is the first version of Xen with any serious
form Python 3 compatibility (and even then, we missed a few corner cases).

Earlier versions of Xen are simply not going to work without Py 2.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] Xen Release 4.12.2 and Python 3: M4 python_devel module and mkheader.py issues
  2020-01-22 12:36 ` Andrew Cooper
@ 2020-01-28  8:45   ` Kevin Buckley
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Buckley @ 2020-01-28  8:45 UTC (permalink / raw)
  To: Andrew Cooper, Pry Mar; +Cc: xen-devel

On Wed, 22 Jan 2020 at 20:36, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>
> On 19/01/2020 06:17, Kevin Buckley wrote:
> > Any clues then, as to whether this is another Python3 hangover for Xen ?
>
> Xen 4.13 (now released) is the first version of Xen with any serious
> form Python 3 compatibility (and even then, we missed a few corner cases).
>
> Earlier versions of Xen are simply not going to work without Py 2.
>
> ~Andrew

and

On Mon, 20 Jan 2020 at 03:27, Pry Mar <pryorm09@gmail.com> wrote:
>
> Only xen-4.13 has been patched for python3 support. To get xen-4.12 to
> work with python3 I use the 9 patches above. They are pasted from the
> Debian delta used to build in Buster.
>

Just to say thanks for the feedback, and to say that I have managed to
deploy a Xen 4.13.0 on an LFS 9.0 system that

a) only had Python3 installed
b) didn't even have a link from python3 -> python.

There's an updated version of my own "LFS book"

http://youvegotbuckleys.org.nz/LFS/LFS-BOOK.html

that details the changes I needed to apply but, basically,
(though I am sure these will have been caught and/or fixed
in the Xen code by now)

1) there were three

-Wno-some-warning-that-causes-treat-all-warnings-as-errors-to-be-in-error

additions to Xen's tools/Makefile, vis:

-Wno-nonnull
-Wno-stringop-truncation
-Wno-format-truncation

along with

2) the swap, in the same Makefile, from

  -I$(XEN_ROOT)/tools/xenstore/compat/include

to

 -I$(XEN_ROOT)/tools/xenstore/include/compat

and

3) simply applying a sed akin to this one

sed -i -e 's|/usr/bin/env python|/usr/bin/env python3|'
analyse-9p-simpletrace.py

to all of the python scripts  in the

qemu-xen-dir-remote/scripts

directory.

Quite surprised at how few changes I needed to make.


Am tempted to suggest that the qemu-xen scripts should
respect the argument to their /usr/bin/env from the bare name
of the

PYTHON=/path/to/some-python-interpreter

define that can be supplied to Xen's configure and make
invocations, but would accept that few systems will not have
at least a link to a bare "python"

Thanks again for the feedback and pointers,
Kevin

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xen-devel] Xen Release 4.12.2 and Python 3: M4 python_devel module and mkheader.py issues
@ 2020-01-19 19:25 Pry Mar
  0 siblings, 0 replies; 4+ messages in thread
From: Pry Mar @ 2020-01-19 19:25 UTC (permalink / raw)
  To: xen-devel

kevin,

http://prymar56.org/xen/debian/buster-nmu/4cx/source/xen_4.12.2-1+deb10u1.2.debian.tar.xz

debian/patches/misc-0111-tools-xenmon-make-xenmon.py-compatible-with-python-2-.diff
debian/patches/misc-0112-xenmon-fix-mixed-tabs-and-spaces.diff
debian/patches/misc-0113-tools-python-Python-3-compatibility.diff
debian/patches/xen-flask-Fix-Python3-problems-with-gen-policy-py.diff
debian/patches/xen.python3-pt0.patch
debian/patches/xen.python3-pt1a.patch
debian/patches/xen.python3-pt1b.patch
debian/patches/xen.python3-pt2.patch
debian/patches/xen.python3-pt3.patch

Only xen-4.13 has been patched for python3 support. To get xen-4.12 to
work with python3 I use the 9 patches above. They are pasted from the
Debian delta used to build in Buster.

Once these patches are applied the buildinfo has nothing for python2,
only python3.

cheers,
PryMar56
##xen-packaging on Freenode IRC

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-28  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-19  6:17 [Xen-devel] Xen Release 4.12.2 and Python 3: M4 python_devel module and mkheader.py issues Kevin Buckley
2020-01-22 12:36 ` Andrew Cooper
2020-01-28  8:45   ` Kevin Buckley
2020-01-19 19:25 Pry Mar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).