hercules-team / python-augeas

Python bindings for Augeas
GNU Lesser General Public License v2.1
44 stars 31 forks source link

Attempt to remove libxml2 as a dependency #25

Closed thedrow closed 7 years ago

thedrow commented 7 years ago

Fixes #20 #21

thedrow commented 7 years ago

@gregswift @lutter @rackergs @ohemorange can you please try to install this branch? I think I got rid of the direct dependency on libxml2.

lutter commented 7 years ago

@thedrow I just tried this on a Fedora 25 machine where I had removed /usr/include/libxml2, and the following worked successfully for me:

make build
PYTHONPATH=$PWD/build/lib.linux-x86_64-2.7/ make check

The change also makes sense to me as ffi.py already contains the headers for all the Augeas functions the Python bindings are interested in, and teh include of augeas.h was therefore superfluous.

So, +1 from me.

gregswift commented 7 years ago

On Fedora 24, with libxml2-devel both installed and uninstalled I get the following

libxml2-devel installed

[ xaeth@localhost python-augeas ] (remove-libxml2-dependency *%)$ make build
PREFIX=/usr python setup.py build
running build
running build_py
running build_ext
generating cffi module 'build/temp.linux-x86_64-2.7/augeas.c'
already up-to-date
building 'augeas' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/augeas.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/augeas.o
In file included from build/temp.linux-x86_64-2.7/augeas.c:423:0:
/usr/include/augeas.h:24:25: fatal error: libxml/tree.h: No such file or directory
 #include <libxml/tree.h>
                         ^
compilation terminated.
error: command 'gcc' failed with exit status 1
Makefile:15: recipe for target 'build' failed
make: *** [build] Error 1

libxml2-devel uninstalled (which means no augeas-devel)

[ xaeth@localhost python-augeas ] (remove-libxml2-dependency *%)$ make build
PREFIX=/usr python setup.py build
running build
running build_py
running build_ext
generating cffi module 'build/temp.linux-x86_64-2.7/augeas.c'
already up-to-date
building 'augeas' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/augeas.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/augeas.o
build/temp.linux-x86_64-2.7/augeas.c:423:35: fatal error: augeas.h: No such file or directory
                #include <augeas.h>
                                   ^
compilation terminated.
error: command 'gcc' failed with exit status 1
Makefile:15: recipe for target 'build' failed
make: *** [build] Error 1

edit: to show the difference between the 2 runs

gregswift commented 7 years ago

Running make check with the PYTHONPATH @lutter used does run clean. Without the PYTHONPATH being set i get this error

test15Copy (__main__.TestAugeas) ... ERROR

======================================================================
ERROR: test15Copy (__main__.TestAugeas)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_augeas.py", line 234, in test15Copy
    a.copy(orig_path, copy_path)
AttributeError: 'Augeas' object has no attribute 'copy'

----------------------------------------------------------------------
Ran 15 tests in 9.929s

FAILED (errors=1)
Makefile:4: recipe for target 'check' failed
make[1]: *** [check] Error 1
make[1]: Leaving directory '/home/xaeth/Development/python-augeas/test'
Makefile:24: recipe for target 'check' failed
make: *** [check] Error 2
lutter commented 7 years ago

@gregswift are you sure you have the patch for this change applied ? You might also have to do a make clean (or maybe even blow build/ away). The errors you got in both attempts at make build indicate that the code is still trying to include augeas.h, which it shouldn't based on this PR.

lutter commented 7 years ago

@thedrow One problem is that setup.py requires cffi >= 1.0.0, but RHEL/CentOS 6 only come with python-cffi-0.6, which means that this new version of the Python bindings won't be available on that platform. Still an improvement to where we are today.

gregswift commented 7 years ago

Blew everything away and tried again and it did work. not sure what got gummed up.

👍

edit: well the test still fails without the PYTHONPATH .. but thats expected? should we maybe make that so it works without the manual change

lutter commented 7 years ago

Yes, I think the Makefile should set the PYTHONPATH - I don't see how tests could possibly work against what we just built without setting it.

jefferyto commented 4 years ago

Apologies for commenting on a very old PR, but I wanted to point out that by removing the header source parameter for ffi.set_source(), this changed the CFFI mode of usage from API to ABI mode (and as I mentioned in #48, it is currently a somewhat confused mix of out-of-line and in-line ABI mode).

From CFFI's documentation, it is clear that API mode is the preferred mode to use; out-of-line API mode is described as the main mode of usage.

Reading through the issues fixed by this change, I see that there were build issues related to libxml2. Perhaps a better solution would have been to set CPPFLAGS (or another similar variable) in the Makefile with the correct include path, i.e. based on a call to pkg-config.

thedrow commented 4 years ago

@jefferyto Feel free to suggest a patch.