Introduction
This library provides best-guess platform detection for a range of single-board computers and (potentially) other platforms. It was written primarily for use in Adafruit_Blinka, but may be useful in other contexts.
Platform detection is divided into “chip” and “board” detection, with the latter generally dependent on the former. Platform info is gathered from:
Python’s sys.platform
Various files on Linux systems:
/proc/cpuinfo (for processor info, Raspberry Pi hardware revisions, etc.)
/proc/device-tree/compatible (for 96Boards info)
Beaglebone EEPROM board IDs
Distribution-specific files such as /etc/armbian-release.
Dependencies
This driver depends on:
Python 3.7 or higher
Installing from PyPI
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install Adafruit-PlatformDetect
To install system-wide (this may be required in some cases):
sudo pip3 install Adafruit-PlatformDetect
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install Adafruit-PlatformDetect
Usage Example
from adafruit_platformdetect import Detector
detector = Detector()
print("Chip id: ", detector.chip.id)
print("Board id: ", detector.board.id)
# Check for specific board models:
print("Pi 3B+? ", detector.board.RASPBERRY_PI_3B_PLUS)
print("BBB? ", detector.board.BEAGLEBONE_BLACK)
print("Orange Pi PC? ", detector.board.ORANGE_PI_PC)
print("generic Linux PC? ", detector.board.GENERIC_LINUX_PC)
Custom boards and System-on-Module carriers
On Linux, an administrator can select a board definition by creating /etc/blinka-board. This works independently of the module’s vendor or generation, including Raspberry Pi Compute Modules, compatible third-party modules, and other System-on-Module (SoM) designs. The file must contain one public constant name from adafruit_platformdetect.constants.boards, with optional surrounding whitespace. For example, a CM4/CM4S carrier that matches the Pi 4B pin mapping can use:
RASPBERRY_PI_4B
This is a system-wide board override, like a persistent BLINKA_FORCEBOARD: choose only a definition compatible with the actual module and carrier. Sharing a connector layout does not make different chips’ GPIO mappings interchangeable. The override does not validate electrical compatibility, change chip detection, configure peripherals, or load device-tree overlays. BLINKA_FORCEBOARD takes precedence during initial detection and can select a different board for an individual process, including when using a USB adapter. Non-Linux platforms do not consult this file.
If the file is missing, unreadable, empty, or does not name a known public board constant, normal board detection is retained. Detection is cached on each Detector instance; restart the application after changing the file.
This mechanism does not add support for new carrier boards by itself. A carrier with a new pin mapping still needs a board constant and appropriate family memberships in PlatformDetect, plus a board definition and routing in Blinka. Carrier-specific Blinka routing must precede matching generic board-family entries. Do not put a Python module path or an unregistered carrier name in the file.
Contributing
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation
For information on building library documentation, please check out this guide.
Metadata
Release files for Adafruit-PlatformDetect 3.90.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| adafruit_platformdetect-3.90.0.tar.gz | 55.1 kB | Without provenance | Details for adafruit_platformdetect-3.90.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adafruit_platformdetect-3.90.0-py3-none-any.whl | Python 3 | none | any | Details for adafruit_platformdetect-3.90.0-py3-none-any.whl |
Total release size: 83.4 kB
Release files / adafruit_platformdetect-3.90.0.tar.gz
| Download URL | adafruit_platformdetect-3.90.0.tar.gz |
|---|---|
| Size | 55.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
433148eaf15967001c644a30843f542813438c28bc0ffe891b7e99ad4aeab72d
|
|
BLAKE2b-256 checksum How to use checksums |
7f54f81a6702f970dfabca29851a0545c364fdd8b65ffd0731b479a28ef8ee5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.1
|
Release files / adafruit_platformdetect-3.90.0-py3-none-any.whl
| Download URL | adafruit_platformdetect-3.90.0-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af3ff5e9cea60335014a22fd85813f586a54b182138443fb2907032b0b14a392
|
|
BLAKE2b-256 checksum How to use checksums |
47570847b854b5ae067e3d55e7d71c79041e048baf71e254e94c0081cc49a51e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.1
|
Security for Adafruit-PlatformDetect 3.90.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.