Pip Install Fails Due to cppyy-backend setup.py Bug

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Pip Install Fails Due to cppyy-backend setup.py Bug

Parker Boyce
I recently had reason to try to install cppyy using Python 3 and pip. With the use of the wheels for cppyy-cling the process went smoothly enough until pip tried to build cppyy-backend. Building this package by itself results in the following error message;

$ python3 setup.py build
running build
running build_ext
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ib'/usr/local/lib/python3.5/dist-packages/cppyy_backend/include' -I/usr/include/python3.5m -c src/clingwrapper.cxx -o build/temp.linux-x86_64-3.5/src/clingwrapper.o -std=c++11 -O2
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from src/clingwrapper.cxx:4:0:
src/callcontext.h:11:20: fatal error: Rtypes.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

A careful look at the command line argument for gcc reveals a mangled include argument, -Ib'/usr/local/lib/python3.5/dist-packages/cppyy_backend/include'. This is a binary literal string introduced by the output of a system call, "cling-config --cppflags". The functions in the subprocess module return 'bytes' objects in Python 3. In this case the return value from 'check_output' was appended wholesale into the 'include_dirs' argument of your extension, and the representation thereof was used in turn to build the function call to gcc. (The representation being a binary literal string)

To fix this the bytes object returned by subprocess.check_output needs to be decoded to either 'utf-8' or 'ascii', preferably the former as Python 3 uses unicode literals. This can be accomplished by appending '.decode("utf-8")' to line 28;

--- /home/parker/Documents/cppyy/cppyy-backend-0.2.0/setup.py Fri Sep 22 12:25:29 2017
+++ /home/parker/Documents/cppyy/cppyy-backend-0.2.0/setup.py.patched Tue Sep 26 19:37:50 2017
@@ -25,7 +25,7 @@
     if root_install:
         return os.path.join(root_install, 'include')
     cli_arg = subprocess.check_output(['cling-config', '--cppflags'])
-    return cli_arg[2:-1]
+    return cli_arg[2:-1].decode("utf-8")
 
 class my_build_cpplib(_build_ext):
     def build_extension(self, ext):

With this patch pip will be able to build the cppyy-backend package from source on Python 2 or 3, and pip installing cppyy will not require user intervention.

P.S. The "Comments and Bugs" section of the cppyy docs directs the reader to a repository with issue tracking turned off, which is why you're getting this email instead.

_______________________________________________
pypy-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/pypy-dev
Reply | Threaded
Open this post in threaded view
|

Re: Pip Install Fails Due to cppyy-backend setup.py Bug

wlavrijsen@lbl.gov
Parker,

thanks! Both (encoding and tracker) are now fixed.

Best regards,
            Wim
--
[hidden email]    --    +1 (510) 486 6411    --    www.lavrijsen.net
_______________________________________________
pypy-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/pypy-dev