Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid SPIDevice init failure in absence of libgpiod bindings #102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ilario
Copy link

@ilario ilario commented Jan 14, 2025

When importing other Adafruit components, I observed this error:

[...]
    from adafruit_register.i2c_struct import ROUnaryStruct, UnaryStruct
  File "/opt/measurement_system-venv/lib/python3.9/site-packages/adafruit_register/i2c_struct.py", line 22, in <module>
    from circuitpython_typing.device_drivers import I2CDeviceDriver
  File "/opt/measurement_system-venv/lib/python3.9/site-packages/circuitpython_typing/device_drivers.py", line 13, in <module>
    from adafruit_bus_device.spi_device import SPIDevice
  File "/opt/measurement_system-venv/lib/python3.9/site-packages/adafruit_bus_device/spi_device.py", line 29, in <module>
    class SPIDevice:
  File "/opt/measurement_system-venv/lib/python3.9/site-packages/adafruit_bus_device/spi_device.py", line 76, in SPIDevice
    chip_select: Optional[DigitalInOut] = None,
NameError: name 'DigitalInOut' is not defined

This is happening because I did not have the "libgpiod Python bindings" (installable with pip install gpiod) and the import here fails:

from digitalio import DigitalInOut

Causing this line to fail:

chip_select: Optional[DigitalInOut] = None,

This started happening with adafruit/Adafruit_CircuitPython_Typing#42 as it introduced importing adafruit_bus_device.spi_device.SPIDevice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant