nRF24 / pyRF24

A python package that wraps the RF24, RF24Network, and RF24Mesh C++ libraries.
http://pyrf24.rtfd.io
GNU General Public License v2.0
24 stars 3 forks source link

building new wheels with SPIDEV (using GPIO char-dev API) #48

Closed 2bndy5 closed 7 months ago

2bndy5 commented 8 months ago

With the updates to the RF24 lib's SPIDEV driver, The list of dependencies has expanded to the linux kernel's gpio.h header. However, this header is not available in the CI when building a binary distributable "wheel" (the file that is uploaded to pypi and downloaded by pip).

Technical Detail

Technically, the gpio.h file isn't available in the [docker images that cibuildwheel uses](https://github.com/pypa/manylinux#docker-images) to create our binary distributions. The gpio.h is available in the `ubuntu-latest` runners, though the header file is not exposed to the docker container being run by [cibuildwheel](https://github.com/pypa/cibuildwheel). I considered using a customized docker image, but the `manylinux-*` tags that pip uses (to recognize compatible binary distributions hosted at pypi) implies a certain level of conformance with libc version... I'd rather not maintain a specialized docker image because of 1 missing file. If you're thinking: "What about linux/spi/spi-dev.h?" No worries there. The SPI & I2C header files are present in the docker images, presumably because those data busses are used by a plethora of PC hardware peripherals.


As a workaround, we can include a copy of the gpio.h from the linux kernel into this repo. I think the GPL allows this since we are providing the source code with distributions (as source distribution wheels to pypi). In fact the libgpiod repo does this as well (see their copy of gpio.h), but they don't provide binary distributions to pypi (piwheels picks up the slack for them on RPi OS 32-bit).

The only complexity in this workaround is that RF24/utility/SPIDEV/gpio.* files need to use quotes in the #include statements:

-#include <linux/gpio.h>
+#include "linux/gpio.h"

And Similarly for the RPI and SPIDEV drivers' interrupt implementations.

I can adjust the build system in this repo to add our copy of the gpio.h header file.