Skip to content

Update Blinka to pyproject.toml - #1114

Merged
makermelissa merged 25 commits into
adafruit:mainfrom
makermelissa:future-proof
Jul 7, 2026
Merged

Update Blinka to pyproject.toml#1114
makermelissa merged 25 commits into
adafruit:mainfrom
makermelissa:future-proof

Conversation

@makermelissa

@makermelissa makermelissa commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

This updates Blinka to use pyproject.toml. However, because Blinka required checking things through setup.py using mechanisms that were no longer through pyproject.toml, this conversion had not happened. The new approach is to check for dependencies at runtime and guide the user on installing those dependencies as normal. This way blinka can still be added as a dependency in the CircuitPython libraries on the many platforms it runs on and still work.

This goes a long way towards helping with #1113.

makermelissa and others added 6 commits June 23, 2026 13:55
- Add src/adafruit_blinka/microcontroller/ti/am625x/pin.py with
  libgpiod Pin definitions for all three I2C buses (MIKROBUS i2c-3,
  Grove i2c-1, QWIIC i2c-5), USR LEDs, user button, and MIKROBUS GPIOs
- Add src/adafruit_blinka/board/beagleboard/beagle_play.py exposing
  SCL/SDA (MIKROBUS), QWIIC_SCL/SDA, GROVE_SCL/SDA, LED_USRn,
  USR_BUTTON, and MIKROBUS_GPIO1_N pins
- Register BEAGLE_PLAY in board_imports.json and AM625X in
  microcontroller_imports.json
- Bump Adafruit-PlatformDetect minimum from >=3.70.1 to >=3.89.0
  (3.89.1 fixes BeaglePlay nvmem path; 3.88.0 broke XU4 detection)

Tested on BeaglePlay (aarch64, Debian Trixie, Python 3.13.5):
- board.id = BEAGLE_PLAY confirmed
- busio.I2C works on all three buses (MIKROBUS, QWIIC, Grove)
@makermelissa
makermelissa marked this pull request as ready for review June 24, 2026 19:13
@makermelissa-ai-assistant

makermelissa-ai-assistant commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Install Test Matrix

Tested pip install adafruit-blinka from the future-proof branch across five boards. All pass. Notes on required setup per board are below.

Board Arch Python OS Result
Raspberry Pi 5 aarch64 3.13 Debian Trixie ✅ PASS
Ubuntu x86_64 x86_64 3.14 Ubuntu 26.04 LTS ✅ PASS
Odroid XU4 armv7l 3.13 Armbian ✅ PASS
BeagleBone AI armv7l 3.11.2 Debian Bookworm 2023-10-07 ✅ PASS
BeaglePlay aarch64 3.13.5 Debian Trixie 2026-05-19 ✅ PASS

Notes

Raspberry Pi 5 / Pi 4 and earlier
Standard pip install into a venv. lgpio installs from the URL wheels in requirements.txt on Python 3.13–3.15 where no PyPI wheel exists yet.

Ubuntu x86_64
Clean pip install into a venv. No special setup needed.

Odroid XU4 (armv7l, Armbian)
Requires python3-libgpiod and python3-sysv-ipc from apt, and a venv created with --system-site-packages:

sudo apt install python3-libgpiod python3-sysv-ipc
python3 -m venv --system-site-packages venv

Note: Adafruit_BBIO, RPi.GPIO, and rpi_ws281x install on all armv7l boards due to the marker — pre-existing tradeoff of the marker approach vs. the old runtime detection.

BeagleBone AI (armv7l, Bookworm)
python3-libgpiod is already present on the stock Bookworm image. Venv needs --system-site-packages:

python3 -m venv --system-site-packages venv

board.id = BEAGLEBONE_AI ✓, PlatformDetect 3.89.0

BeaglePlay (aarch64, Trixie)
Same python3-libgpiod + --system-site-packages requirement. Board support added in #1115 (merged). Requires PlatformDetect>=3.89.1 for correct BEAGLE_PLAY detection (3.89.1 fixes the nvmem path lookup).
board.id = BEAGLE_PLAY ✓, I2C on all three buses (MIKROBUS, QWIIC, Grove) ✓

Jetson

No supported Jetson hardware available for testing. Jetson.GPIO install untested.

@makermelissa-ai-assistant

makermelissa-ai-assistant commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Test Matrix Results

Tested install of this branch across 6 boards. All pass.

Board OS Arch Python Result
Ubuntu 26.04 LTS Ubuntu 26.04 x86_64 3.14 ✅ PASS
Raspberry Pi 5 Debian Trixie aarch64 3.13 ✅ PASS
Raspberry Pi 4B Debian Trixie aarch64 3.13 ✅ PASS
Odroid XU4 Armbian armv7l 3.13 ✅ PASS
BeagleBone AI Debian Bookworm armv7l 3.11 ✅ PASS
BeaglePlay Debian Trixie aarch64 3.13 ✅ PASS

Install notes by board

All boards: python3 -m venv --system-site-packages is required when the board has system-installed GPIO packages (libgpiod, lgpio, RPi.GPIO) that can't be built from source in a plain venv.

XU4 / Armbian: Needs sudo apt install python3-libgpiod python3-sysv-ipc + --system-site-packages venv. PlatformDetect >=3.89.0 required (3.88.0 broke XU4 detection).

BBB AI / Bookworm: python3-libgpiod already present. Needs --system-site-packages venv.

BeaglePlay / Trixie: Needs sudo apt install python3-libgpiod + --system-site-packages venv. PlatformDetect >=3.89.1 required (3.89.1 fixed the BeaglePlay EEPROM address from 0-00500 → glob-based lookup, since BeaglePlay exposes 0-00501). Also needs world-readable nvmem: sudo chmod a+r /sys/bus/nvmem/devices/0-00501/nvmem (or a udev rule).

Raspberry Pi (4B / 5): Needs python3-lgpio python3-rpi.gpio from apt + --system-site-packages venv. I2C must be enabled (raspi-config nonint do_i2c 0).

Bug fixed in this branch

Removed the Python.h header check from setup.py. On Python 3.13, setuptools' exec(code, locals()) (PEP 667 behavior change) drops top-level imports — the import glob was silently lost, causing NameError: name 'glob' is not defined during wheel build on any Python 3.13 host. The check was a holdover that doesn't belong in a pyproject.toml-based build anyway.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR begins the migration of Adafruit_Blinka’s packaging toward a pyproject.toml-based build, adds clearer runtime errors for missing optional/platform-specific dependencies, and refreshes installation requirements.

Changes:

  • Added pyproject.toml build-system configuration (setuptools + setuptools-scm).
  • Centralized “missing platform dependency” error handling via raise_for_missing_platform_dependency() and applied it to several platform-import entrypoints.
  • Reworked requirements.txt to list runtime dependencies explicitly and adjusted packaging metadata (including python_requires).

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pwmio.py Wraps board-specific PWMOut imports to provide a clearer error when optional deps are missing.
src/neopixel_write.py Same as above for NeoPixel backend selection/imports.
src/board.py Switches platformdetect version reporting to importlib.metadata.version().
src/adafruit_blinka/microcontroller/am335x/pin.py Uses shared missing-dependency helper for Adafruit_BBIO.
src/adafruit_blinka/importing.py Introduces the shared missing-dependency helper and integrates it into import_mod().
setup.py Adjusts packaging metadata (notably python_requires) for the packaging transition.
requirements.txt Replaces the placeholder with explicit dependencies + platform markers.
pyproject.toml Adds PEP 517/518 build configuration and setuptools-scm settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread setup.py
Comment thread setup.py
@makermelissa
makermelissa requested a review from a team June 24, 2026 20:41
@FoamyGuy

FoamyGuy commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

I tried installing from this branch on a Raspberry Pi 5, fresh flash of Ras Pi OS with python 3.13.5

I am getting this error:

$ pip install ./
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing /home/timc/Adafruit_Blinka
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting Adafruit-PlatformDetect>=3.89.1 (from Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-platformdetect/adafruit_platformdetect-3.89.1-py3-none-any.whl.metadata (3.8 kB)
Collecting Adafruit-PureIO>=1.1.7 (from Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-pureio/Adafruit_PureIO-1.1.11-py3-none-any.whl.metadata (3.0 kB)
Collecting binho-host-adapter>=0.1.6 (from Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/binho-host-adapter/binho_host_adapter-0.1.6-py3-none-any.whl.metadata (2.0 kB)
Collecting pyftdi>=0.40.0 (from Adafruit-Blinka==0.1.dev2094)
  Downloading pyftdi-0.57.2-py3-none-any.whl.metadata (3.4 kB)
Collecting adafruit-circuitpython-typing (from Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-typing/adafruit_circuitpython_typing-1.12.3-py3-none-any.whl.metadata (3.3 kB)
Collecting sysv_ipc>=1.1.0 (from Adafruit-Blinka==0.1.dev2094)
  Downloading sysv_ipc-1.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.metadata (2.4 kB)
Collecting rpi_ws281x>=4.0.0 (from Adafruit-Blinka==0.1.dev2094)
  Downloading rpi_ws281x-5.0.0.tar.gz (64 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting lgpio>=0.2.2.0 (from Adafruit-Blinka==0.1.dev2094)
  Downloading lgpio-0.2.2.0.tar.gz (90 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting RPi.GPIO (from Adafruit-Blinka==0.1.dev2094)
  Downloading RPi.GPIO-0.7.1.tar.gz (29 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting Adafruit-Blinka-Raspberry-Pi5-Neopixel (from Adafruit-Blinka==0.1.dev2094)
  Downloading Adafruit_Blinka_Raspberry_Pi5_Neopixel-1.0.0rc2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.metadata (547 bytes)
Collecting pyserial (from binho-host-adapter>=0.1.6->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/pyserial/pyserial-3.5-py2.py3-none-any.whl.metadata (1.6 kB)
Collecting pyusb!=1.2.0,>=1.0.0 (from pyftdi>=0.40.0->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/pyusb/pyusb-1.3.1-py3-none-any.whl.metadata (2.6 kB)
Collecting adafruit-circuitpython-busdevice (from adafruit-circuitpython-typing->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.17-py3-none-any.whl.metadata (4.1 kB)
Collecting adafruit-circuitpython-requests (from adafruit-circuitpython-typing->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-requests/adafruit_circuitpython_requests-4.1.17-py3-none-any.whl.metadata (3.6 kB)
Collecting typing_extensions~=4.0 (from adafruit-circuitpython-typing->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/typing-extensions/typing_extensions-4.15.0-py3-none-any.whl.metadata (3.3 kB)
INFO: pip is looking at multiple versions of adafruit-circuitpython-busdevice to determine which version is compatible with other requirements. This could take a while.
Collecting adafruit-circuitpython-busdevice (from adafruit-circuitpython-typing->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.16-py3-none-any.whl.metadata (4.1 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.15-py3-none-any.whl.metadata (4.1 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.14-py3-none-any.whl.metadata (4.1 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.13-py3-none-any.whl.metadata (4.1 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.12-py3-none-any.whl.metadata (4.1 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.11-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.10-py3-none-any.whl.metadata (4.0 kB)
INFO: pip is still looking at multiple versions of adafruit-circuitpython-busdevice to determine which version is compatible with other requirements. This could take a while.
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.9-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.6-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.5-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://archive1.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.4-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.3-py3-none-any.whl.metadata (4.0 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.2-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.1-py3-none-any.whl.metadata (4.0 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.2.0-py3-none-any.whl.metadata (3.9 kB)
  Downloading https://archive1.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.10-py3-none-any.whl.metadata (3.9 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.9-py3-none-any.whl.metadata (3.9 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.8-py3-none-any.whl.metadata (3.8 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.7-py3-none-any.whl.metadata (3.8 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.6-py3-none-any.whl.metadata (3.8 kB)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.5-py3-none-any.whl.metadata (3.7 kB)
Collecting Adafruit-Circuitpython-ConnectionManager (from adafruit-circuitpython-requests->adafruit-circuitpython-typing->Adafruit-Blinka==0.1.dev2094)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-connectionmanager/adafruit_circuitpython_connectionmanager-3.1.8-py3-none-any.whl.metadata (4.5 kB)
Downloading https://www.piwheels.org/simple/adafruit-platformdetect/adafruit_platformdetect-3.89.1-py3-none-any.whl (27 kB)
Downloading https://www.piwheels.org/simple/adafruit-pureio/Adafruit_PureIO-1.1.11-py3-none-any.whl (10 kB)
Downloading https://www.piwheels.org/simple/binho-host-adapter/binho_host_adapter-0.1.6-py3-none-any.whl (10 kB)
Downloading pyftdi-0.57.2-py3-none-any.whl (146 kB)
Downloading https://www.piwheels.org/simple/pyserial/pyserial-3.5-py2.py3-none-any.whl (90 kB)
Downloading https://www.piwheels.org/simple/pyusb/pyusb-1.3.1-py3-none-any.whl (58 kB)
Downloading sysv_ipc-1.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (72 kB)
Downloading Adafruit_Blinka_Raspberry_Pi5_Neopixel-1.0.0rc2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (80 kB)
Downloading https://www.piwheels.org/simple/adafruit-circuitpython-typing/adafruit_circuitpython_typing-1.12.3-py3-none-any.whl (11 kB)
Downloading https://www.piwheels.org/simple/typing-extensions/typing_extensions-4.15.0-py3-none-any.whl (44 kB)
Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.1.5-py3-none-any.whl (8.7 kB)
Downloading https://www.piwheels.org/simple/adafruit-circuitpython-requests/adafruit_circuitpython_requests-4.1.17-py3-none-any.whl (10 kB)
Downloading https://www.piwheels.org/simple/adafruit-circuitpython-connectionmanager/adafruit_circuitpython_connectionmanager-3.1.8-py3-none-any.whl (7.8 kB)
Building wheels for collected packages: Adafruit-Blinka, lgpio, rpi_ws281x, RPi.GPIO
  Building wheel for Adafruit-Blinka (pyproject.toml) ... done
  Created wheel for Adafruit-Blinka: filename=adafruit_blinka-0.1.dev2094-py3-none-any.whl size=1068542 sha256=454ee5063d7a4f3f02ea3e857b98cf364ea0465e2a79cfa9e5eb84fd7c410aee
  Stored in directory: /tmp/pip-ephem-wheel-cache-i9ck6v0v/wheels/9a/58/9c/888cd770184f1429832e00b3d442716743cc8f8b8a6a7956f7
  Building wheel for lgpio (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for lgpio (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building '_lgpio' extension
      swigging lgpio.i to lgpio_wrap.c
      swig -python -o lgpio_wrap.c lgpio.i
      error: command 'swig' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lgpio
  Building wheel for rpi_ws281x (pyproject.toml) ... done
  Created wheel for rpi_ws281x: filename=rpi_ws281x-5.0.0-cp313-cp313-linux_aarch64.whl size=124975 sha256=3ee970cf7e3f9e4df0c30ba9b2dc225d6e105a823a1c39c0bcda201fa230e462
  Stored in directory: /home/timc/.cache/pip/wheels/29/2a/12/da24aea32d3801e27e82b5c87945725b9954185b725545f3eb
  Building wheel for RPi.GPIO (pyproject.toml) ... done
  Created wheel for RPi.GPIO: filename=rpi_gpio-0.7.1-cp313-cp313-linux_aarch64.whl size=69289 sha256=8bcfd464ba70071a4984cff3a4efe1693495780c4b93db25b018d9c72ac5b6a9
  Stored in directory: /home/timc/.cache/pip/wheels/fe/f1/d8/b4cf15eedd221009444483ab72646dee0b203f4aa2c185ec1c
Successfully built Adafruit-Blinka rpi_ws281x RPi.GPIO
Failed to build lgpio
ERROR: Failed to build installable wheels for some pyproject.toml based projects (lgpio)

@makermelissa

makermelissa commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @FoamyGuy. It looks like it might be collecting lgpio from the wrong place.

On Python 3.13+, lgpio has no pre-built wheel on PyPI or piwheels for
aarch64. When setup.py resolved lgpio as a plain >=0.2.2.0 dependency,
pip fell back to building from source and failed with:
  error: command 'swig' failed: No such file or directory

Fix: detect Python version at install time and use the pre-built URL
wheel for 3.13/3.14/3.15 on aarch64 (same wheels already referenced in
requirements.txt). Non-aarch64 and Python <3.13 keep the plain
lgpio>=0.2.2.0 spec since piwheels has those covered.

Reported by @FoamyGuy in PR review.
@makermelissa

Copy link
Copy Markdown
Collaborator Author

@FoamyGuy if you want to take another look, the newer lgpio support is now done in a cleaner way.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/adafruit_blinka/importing.py Outdated
Comment on lines +36 to +39
"lgpio": (
"pip install lgpio --find-links "
"https://github.com/adafruit/lgpio-python-wheels/raw/main/wheels/"
),
Comment thread setup.py Outdated
Comment on lines +132 to +133
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
@makermelissa
makermelissa merged commit 582a37b into adafruit:main Jul 7, 2026
1 check passed
@makermelissa makermelissa mentioned this pull request Jul 9, 2026
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.

4 participants