Opened 7 years ago

Closed 7 years ago

#9467 closed enhancement (fixed)

Requried patch for compiling libxml2-2.9.4 with Python 3.6

Reported by: Munir Contractor Owned by: Pierre Labastie
Priority: normal Milestone: 8.1
Component: BOOK Version: SVN
Severity: normal Keywords:
Cc:

Description

I have attached a patch here that I found from Fedora's build of libxml2. It fixes an issue when compiling libxml2-2.9.4 with Python 3.6 instead of Python 2.7.

Please add it to the book when you get a chance.

Thanks.

Change History (7)

comment:1 by bdubbs@…, 7 years ago

The patch came out as garbage. I deleted it. Please upload the patch again, but do not compress it.

comment:2 by Pierre Labastie, 7 years ago

For me, just adding the configure switch --with-python=/usr/bin/python3 allows to build bindings for Python3. I've not tested them though.

Side note: the dependencies have both Python2 and Python3 as recommended, but the instructions in the book build only bindings for Python2. So there is something slightly wrong here.

comment:3 by Pierre Labastie, 7 years ago

Looks like fedora and arch have this patch:

diff -Nur libxml2-2.9.4.orig/python/types.c libxml2-2.9.4/python/types.c
--- libxml2-2.9.4.orig/python/types.c	2016-02-09 03:17:33.000000000 -0700
+++ libxml2-2.9.4/python/types.c	2016-12-21 12:34:06.755650986 -0700
@@ -31,8 +31,6 @@
     const char *mode;
 
     fd = PyObject_AsFileDescriptor(f);
-    if (!_PyVerify_fd(fd))
-        return(NULL);
     /*
      * Get the flags on the fd to understand how it was opened
      */

Because the PyVerify_fd symbol does not exist anymore in python3.

Note also that archlinux builds both bindings with:

  cd build-py2
  ../$pkgname/configure --prefix=/usr --with-threads --with-history --with-python=/usr/bin/python2 --with-icu
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0 /g' libtool
  make

  cd ../build-py3
  ../$pkgname/configure --prefix=/usr --with-threads --with-history --with-python=/usr/bin/python --with-icu
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0 /g' libtool
  PYTHONHASHSEED=0 make

comment:4 by bdubbs@…, 7 years ago

For the patch, use:

sed -i '/_PyVerify_fd/{N;d}' /python/types.c


As for the arch procedures, the sed commands are optimization, We almost never change the default optimization, and then only when needed. For long experience, it is not needed.

--with-threads may be useful.

--with-ice may be useful for some users.

We do mention --with-python. If python2 is found, it is used and there is no reason to specify it. It seems a bit of overkill to create both the python2 and python3 modules on the same system. I do not know of anything we have that uses either of the xml python modules. The only reason for python3 being recommended instead of optional is to run the tests.

comment:5 by Pierre Labastie, 7 years ago

Owner: changed from blfs-book@… to Pierre Labastie
Status: newassigned

in reply to:  4 comment:6 by Pierre Labastie, 7 years ago

Replying to bdubbs@…:

For the patch, use:

sed -i '/_PyVerify_fd/{N;d}' /python/types.c

Or (I like it slightly better) sed -i '/_PyVerify_fd/,+1d' /python/types.c

[...] We do mention --with-python. If python2 is found, it is used and there is no reason to specify it. It seems a bit of overkill to create both the python2 and python3 modules on the same system. I do not know of anything we have that uses either of the xml python modules.

Have you read the "Note" on the libxml2 page?

The only reason for python3 being recommended instead of optional is to run the tests.

But python2 can be used for tests, can't it? In that case, the recommendation should be python2 or python3, not python2 and python3.

comment:7 by Pierre Labastie, 7 years ago

Resolution: fixed
Status: assignedclosed

Fixed at r18949

Note: See TracTickets for help on using tickets.