brgl / libgpiod

This is a mirror of the original repository over at kernel.org. This github page is for discussions and issue reporting only. PRs can be discussed here but the patches need to go through the linux-gpio mailing list.
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/
Other
297 stars 105 forks source link

Can't build python bindings with buildroot #89

Closed jeanphi-francois closed 1 week ago

jeanphi-francois commented 2 months ago

There is a libgpiod2 package in buildroot, with the option --disable-bindings-python set. I modified it to pass the --enable-bindings-python, but it doesn't work. At the setup.py stage, the host compiler is used.

Here is the output :

GPIOD_WITH_TESTS= \
/home/jp/buildfarm/isp-cm4s-new/host/bin/python3 setup.py build_ext --inplace \                                                                                                        
        --include-dirs=../../include/:../../tests/gpiosim/ \                                                                                                                           
        --library-dirs=../../lib/.libs/:../../tests/gpiosim/.libs/                                                                                                                     
running build_ext                                                                                                                                                                      
building 'gpiod._ext' extension                                                                                                                                                        
/home/jp/buildfarm/isp-cm4s-new/host/bin/ccache /usr/bin/gcc -pthread -Wsign-compare -DNDEBUG -g -O3 -Wall -O2 -I/home/jp/buildfarm/isp-cm4s-new/host/include -fPIC -D_GNU_SOURCE=1 -I.
./../include/ -I../../tests/gpiosim/ -I/home/jp/buildfarm/isp-cm4s-new/host/include/python3.11 -c gpiod/ext/chip.c -o build/temp.linux-x86_64-cpython-311/gpiod/ext/chip.o -Wall -Wextr
a  

Has you can see, setup.py is not using the cross CC. I tried to mess with Makefile.am like this

    echo $(CC)  
    GPIOD_WITH_TESTS=$(BUILD_TESTS) \
    $(PYTHON) setup.py build_ext --inplace \
        --include-dirs=$(top_srcdir)/include/:$(top_srcdir)/tests/gpiosim/ \
        --library-dirs=$(top_builddir)/lib/.libs/:$(top_srcdir)/tests/gpiosim/.libs/

I added the echo $(CC) line, and the output is

make[7]: Nothing to be done for 'all-am'.                                                                                                                                     [30/4607]
echo /home/jp/buildfarm/isp-cm4s-new/host/bin/arm-none-linux-gnueabihf-gcc                                                                                                             
/home/jp/buildfarm/isp-cm4s-new/host/bin/arm-none-linux-gnueabihf-gcc                                                                                                                  
GPIOD_WITH_TESTS= \                                                                                                                                                                    
/home/jp/buildfarm/isp-cm4s-new/host/bin/python3 setup.py build_ext --inplace \                                                                                                        
        --include-dirs=../../include/:../../tests/gpiosim/ \                                                                                                                           
        --library-dirs=../../lib/.libs/:../../tests/gpiosim/.libs/                                                                                                                     
running build_ext                                                                                                                                                                      
building 'gpiod._ext' extension                                                                                                                                                        
/home/jp/buildfarm/isp-cm4s-new/host/bin/ccache /usr/bin/gcc -pthread -Wsign-compare -DNDEBUG -g -O3 -Wall -O2 -I/home/jp/buildfarm/isp-cm4s-new/host/include -fPIC -D_GNU_SOURCE=1 -I.
./../include/ -I../../tests/gpiosim/ -I/home/jp/buildfarm/isp-cm4s-new/host/include/python3.11 -c gpiod/ext/chip.c -o build/temp.linux-x86_64-cpython-311/gpiod/ext/chip.o -Wall -Wextr
a

Why is setup.py no using the CC variables ?

brgl commented 2 months ago

I don't support the buildroot recipe but for Python: using Makefile is just a development tool. The actual recipe should fetch sources from pypi. Please look at what meta-openembedded does.