Skip to contentSkip to conversation

tools/xen-foreign: Update python scripts to be Py3 compatible

PATCH Superseded Andrew Cooper 5 participants 12 messages Mar 4, 2019 – Mar 5, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/xen-foreign: Update python scripts to be Py3 compatible

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

---
CC: George Dunlap <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Juergen Gross <[email protected]>

This is a nice-to-have for 4.12 because it makes our build system more compatible with bleeding edge distros.

I've not got the time to figure out why mkheader needs to process types in reverse order of their type names, but checker.c doesn't compile if the list is sorted differently.

---
 tools/include/xen-foreign/mkchecker.py | 2 +-
 tools/include/xen-foreign/mkheader.py  | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
tools/include/xen-foreign/mkchecker.py +1 -1
index fdad869..199b0ee 100644
@@ -37,7 +37,7 @@ for struct in structs:
     f.write('\tprintf("%%-25s |", "%s");\n' % struct);
     for a in archs:
         s = struct + "_" + a;
-        if compat_arches.has_key(a):
+        if a in compat_arches:
             compat = compat_arches[a]
             c = struct + "_" + compat;
         else:
tools/include/xen-foreign/mkheader.py +1 -3
index 97e0c7a..d876831 100644
@@ -205,9 +205,7 @@ for struct in structs:
     output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output);
 
 # replace: integer types
-integers = inttypes[arch].keys();
-integers.sort(lambda a, b: cmp(len(b),len(a)));
-for type in integers:
+for type in sorted(inttypes[arch].keys(), key = lambda x: -len(x)):
     output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output);
 
 # print results
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2 -I/persistent/local/home/dunlapg/anaconda3/include/python3.7m -I/persistent/local/home/dunlapg/anaconda3/include/python3.7m -Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall -L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu -L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread -ldl -lutil -lrt -lm -Xlinker -export-dynamic conftest.c -lpython -llzma -lpython3.7m -lpthread -ldl -lutil -lrt -lm -llzma >&5 /usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

-George

[1] https://www.python.org/dev/peps/pep-0394/

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 10 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

No.  Just the xen-foreign/ parts.

You seemed to be making progress on the other parts.  We should definitely see about making the Xen build system fully Py3-clean.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to George Dunlap
Quoted 7 lines · George Dunlap

checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

-lpython3.7 is also wrong. To make things more complicated, the lib is -lpython3.7m (notice the extra character after the version number).

The AC_CHECK_LIB() in m4/python_devel.m4:33 is attempting to guess what the python lib name would be, and guessed it wrong. Instead, configure should just use the already updated LDFLAGS (once the rune to find python's version is fixed).

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw
In reply to George Dunlap
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Thoughts?

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 98 lines · Juergen Gross
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Quoted 1 line

Thoughts?

I plan to have a closer look at python 3 compatibility issue today. But the outcome is unlikely to be simple -- most likely there will be a few patches. I don't think they will be suitable for 4.12.

We can document the python 2 requirement for 4.12.

Wei.

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 99 lines · Wei Liu
Quoted 98 lines · Juergen Gross
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Quoted 7 lines
Quoted 1 line

Thoughts?

I plan to have a closer look at python 3 compatibility issue today. But the outcome is unlikely to be simple -- most likely there will be a few patches. I don't think they will be suitable for 4.12.

We can document the python 2 requirement for 4.12.

Right, but there are two issues:
1. Build system requires python2
2. Build system assumes that 'python' == 'python2', and fails in strange ways when it's not

I agree #1 isn't something to rush before the release. Any opinions on #2?

Options are:

A. Simply document that if 'python' isn't 'python2' (such as on Arch Linux, or if you've got anaconda python installed), you need to explicitly set PYTHON=/path/to/python2

B. Hard-code configure to look for python2 if not specified rather than python.

C. Have configure detect when python is python3, and look for python2, failing if it's not available.

Evaluation:

Option A isn't a great UI, but the situation has been like this for a long time, so it's probably not the worst thing ever to wait for the next release to fix things. Also, serves you right for using such a broken distro. :-)

Option B is dead-simple; I just don't know how far back it will be compatible.

Option C is the most robust, but more work (though probably not a huge amount).

Thoughts?

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 134 lines · George Dunlap
Quoted 99 lines · Wei Liu
Quoted 98 lines · Juergen Gross
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Quoted 7 lines
Quoted 1 line

Thoughts?

I plan to have a closer look at python 3 compatibility issue today. But the outcome is unlikely to be simple -- most likely there will be a few patches. I don't think they will be suitable for 4.12.

We can document the python 2 requirement for 4.12.

Right, but there are two issues:
1. Build system requires python2
2. Build system assumes that 'python' == 'python2', and fails in strange ways when it's not

I agree #1 isn't something to rush before the release. Any opinions on #2?

Options are:

A. Simply document that if 'python' isn't 'python2' (such as on Arch Linux, or if you've got anaconda python installed), you need to explicitly set PYTHON=/path/to/python2

B. Hard-code configure to look for python2 if not specified rather than python.

C. Have configure detect when python is python3, and look for python2, failing if it's not available.

Evaluation:

Option A isn't a great UI, but the situation has been like this for a long time, so it's probably not the worst thing ever to wait for the next release to fix things. Also, serves you right for using such a broken distro. :-)

Quoted 7 lines

Option B is dead-simple; I just don't know how far back it will be compatible.

Option C is the most robust, but more work (though probably not a huge amount).

Thoughts?

I'm hoping to have 4.12 finished rather soon (maybe one further RC?).

For this reason I'd like to include fixes for regressions only from now on. This would imply option A.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
Quoted 141 lines · Juergen Gross
Quoted 140 lines · George Dunlap
Quoted 99 lines · Wei Liu
Quoted 98 lines · Juergen Gross
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Quoted 7 lines
Quoted 1 line

Thoughts?

I plan to have a closer look at python 3 compatibility issue today. But the outcome is unlikely to be simple -- most likely there will be a few patches. I don't think they will be suitable for 4.12.

We can document the python 2 requirement for 4.12.

Right, but there are two issues:
1. Build system requires python2
2. Build system assumes that 'python' == 'python2', and fails in strange ways when it's not

I agree #1 isn't something to rush before the release. Any opinions on #2?

Options are:

A. Simply document that if 'python' isn't 'python2' (such as on Arch Linux, or if you've got anaconda python installed), you need to explicitly set PYTHON=/path/to/python2

B. Hard-code configure to look for python2 if not specified rather than python.

C. Have configure detect when python is python3, and look for python2, failing if it's not available.

Evaluation:

Option A isn't a great UI, but the situation has been like this for a long time, so it's probably not the worst thing ever to wait for the next release to fix things. Also, serves you right for using such a broken distro. :-)

Option B is dead-simple; I just don't know how far back it will be compatible.

Option C is the most robust, but more work (though probably not a huge amount).

Quoted 6 lines
Quoted 1 line

Thoughts?

I'm hoping to have 4.12 finished rather soon (maybe one further RC?).

For this reason I'd like to include fixes for regressions only from now on. This would imply option A.

Works for me.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw
Quoted 142 lines · George Dunlap
Quoted 141 lines · Juergen Gross
Quoted 140 lines · George Dunlap
Quoted 99 lines · Wei Liu
Quoted 98 lines · Juergen Gross
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Quoted 7 lines
Quoted 1 line

Thoughts?

I plan to have a closer look at python 3 compatibility issue today. But the outcome is unlikely to be simple -- most likely there will be a few patches. I don't think they will be suitable for 4.12.

We can document the python 2 requirement for 4.12.

Right, but there are two issues:
1. Build system requires python2
2. Build system assumes that 'python' == 'python2', and fails in strange ways when it's not

I agree #1 isn't something to rush before the release. Any opinions on #2?

Options are:

A. Simply document that if 'python' isn't 'python2' (such as on Arch Linux, or if you've got anaconda python installed), you need to explicitly set PYTHON=/path/to/python2

B. Hard-code configure to look for python2 if not specified rather than python.

C. Have configure detect when python is python3, and look for python2, failing if it's not available.

Evaluation:

Option A isn't a great UI, but the situation has been like this for a long time, so it's probably not the worst thing ever to wait for the next release to fix things. Also, serves you right for using such a broken distro. :-)

Option B is dead-simple; I just don't know how far back it will be compatible.

Option C is the most robust, but more work (though probably not a huge amount).

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Thoughts?

I'm hoping to have 4.12 finished rather soon (maybe one further RC?).

For this reason I'd like to include fixes for regressions only from now on. This would imply option A.

Works for me.

I'll send a patch to README (which mentions python) saying that we require python2; and saying how to build correctly if python points to python3.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw
Quoted 147 lines · George Dunlap
Quoted 146 lines · George Dunlap
Quoted 145 lines · Juergen Gross
Quoted 134 lines · George Dunlap
Quoted 99 lines · Wei Liu
Quoted 98 lines · Juergen Gross
Quoted 84 lines · George Dunlap
Quoted 8 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

Did you test ./configure with python3?

Loads of the python-related runes in the configure are also python2-only, resulting in (at least for me) the wrong library paths being generated, so the following fails:

PYTHON=/usr/bin/python3 ./configure

With the following message:

File "<string>", line 1
import distutils.sysconfig; print
distutils.sysconfig.get_config_var("VERSION")

                                                  ^

SyntaxError: invalid syntax
checking for python3-config... /home/gdunlap/anaconda3/bin/python3-config checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking for PyArg_ParseTuple in -lpython... no
configure: error: Unable to find a suitable python development library
configure: error: ./configure failed for tools

Note the error with the VERSION above; that results in looking for -lpython rather than -lpython3.7, which results in the following line being executed:

configure:7468: checking for PyArg_ParseTuple in -lpython configure:7493: gcc -o conftest -g -O2 -g -O2

(quoted diff) +0 -12
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-I/persistent/local/home/dunlapg/anaconda3/include/python3.7m
-Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell
-ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe
-fdebug-prefix-map==/usr/local/src/conda/-
-fdebug-prefix-map==/usr/local/src/conda-prefix -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -flto -flto -fuse-linker-plugin
-ffat-lto-objects -flto-partition=none -g -DNDEBUG -fwrapv -O3 -Wall
-L/persistent/local/home/dunlapg/anaconda3/lib/python3.7/config-3.7m-x86_64-linux-gnu
-L/persistent/local/home/dunlapg/anaconda3/lib -lpython3.7m -lpthread
-ldl  -lutil -lrt -lm  -Xlinker -export-dynamic conftest.c -lpython
-llzma  -lpython3.7m -lpthread -ldl  -lutil -lrt -lm  -llzma  >&5

/usr/bin/ld: cannot find -lpython
collect2: error: ld returned 1 exit status

The following fixes it for me:

tools/configure +1 -1
index acc857510e..d7e21db959 100755
@@ -6953,7 +6953,7 @@ if echo "$PYTHON" | grep -q "^/"; then :
     PYTHON=`basename $PYTHONPATH`
 
 elif test -z "$PYTHON"; then :
-  PYTHON="python"
+  PYTHON="python2"
 else
   as_fn_error $? "PYTHON specified, but is not an absolute path"

"$LINENO" 5
fi

tools/configure.ac +1 -1
index 1499344ce6..adf70aeb33 100644
@@ -355,7 +355,7 @@ esac
 AS_IF([echo "$PYTHON" | grep -q "^/"], [
     PYTHONPATH=$PYTHON
     PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
+],[test -z "$PYTHON"], [PYTHON="python2"],
 [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [3])
Quoted 8 lines

..but:
1) I'm not sure if we can guarantee that python2 will exist on all systems we support,
2) We probably want to support python3 at some point anyway.

On the other hand, Arch has python -> python3, but (apparently) has since 2011 [1]; so there's an argument to be made that this isn't something that needs to be solved for 4.12.

Which raises the question whether Andrew's patch should be included in 4.12. I'm tempted to refuse my Rab as I don't see why we need to be python3 compliant in the build system while configure isn't.

Quoted 7 lines
Quoted 1 line

Thoughts?

I plan to have a closer look at python 3 compatibility issue today. But the outcome is unlikely to be simple -- most likely there will be a few patches. I don't think they will be suitable for 4.12.

We can document the python 2 requirement for 4.12.

Right, but there are two issues:
1. Build system requires python2
2. Build system assumes that 'python' == 'python2', and fails in strange ways when it's not

I agree #1 isn't something to rush before the release. Any opinions on #2?

Options are:

A. Simply document that if 'python' isn't 'python2' (such as on Arch Linux, or if you've got anaconda python installed), you need to explicitly set PYTHON=/path/to/python2

B. Hard-code configure to look for python2 if not specified rather than python.

C. Have configure detect when python is python3, and look for python2, failing if it's not available.

Evaluation:

Option A isn't a great UI, but the situation has been like this for a long time, so it's probably not the worst thing ever to wait for the next release to fix things. Also, serves you right for using such a broken distro. :-)

Quoted 7 lines

Option B is dead-simple; I just don't know how far back it will be compatible.

Option C is the most robust, but more work (though probably not a huge amount).

Thoughts?

I'm hoping to have 4.12 finished rather soon (maybe one further RC?).

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

For this reason I'd like to include fixes for regressions only from now on. This would imply option A.

Works for me.

I'll send a patch to README (which mentions python) saying that we require python2; and saying how to build correctly if python points to python3.

Thanks.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v1 1/1
#11 lore raw
In reply to Andrew Cooper
Quoted 11 lines · Andrew Cooper

The issues are:
* dict.has_key() was completely removed in Py3
* dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
* list.sort(cmp=) was deprecated in Py2.4 and removed in Py3. Replace it with a key= sort instead.

This is all compatible with Py2.4 and later, which is when the sorted() builtin was introduced. Tested with Py2.7 and Py3.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel