mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
py/modsys: Add sys.implementation._build entry.
For a given MicroPython firmware/executable it can be sometimes important to know how it was built, which variant/board configuration it came from. This commit adds a new field `sys.implementation._build` that can help identify the configuration that MicroPython was built with. For now it's either: * <VARIANT> for unix, webassembly and windows ports * <BOARD>-<VARIANT> for microcontroller ports (the variant is optional) In the future additional elements may be added to this string, separated by a hyphen. Resolves issue #16498. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -75,6 +75,8 @@ Constants
|
||||
* *version* - tuple (major, minor, micro, releaselevel), e.g. (1, 22, 0, '')
|
||||
* *_machine* - string describing the underlying machine
|
||||
* *_mpy* - supported mpy file-format version (optional attribute)
|
||||
* *_build* - string that can help identify the configuration that
|
||||
MicroPython was built with
|
||||
|
||||
This object is the recommended way to distinguish MicroPython from other
|
||||
Python implementations (note that it still may not exist in the very
|
||||
@@ -83,6 +85,16 @@ Constants
|
||||
Starting with version 1.22.0-preview, the fourth node *releaselevel* in
|
||||
*implementation.version* is either an empty string or ``"preview"``.
|
||||
|
||||
The *_build* entry was added in version 1.25.0 and is a hyphen-separated
|
||||
set of elements. New elements may be appended in the future so it's best to
|
||||
access this field using ``sys.implementation._build.split("-")``. The
|
||||
elements that are currently used are:
|
||||
|
||||
* On the unix, webassembly and windows ports the first element is the variant
|
||||
name, for example ``'standard'``.
|
||||
* On microcontroller targets, the first element is the board name and the second
|
||||
element (if present) is the board variant, for example ``'RPI_PICO2-RISCV'``
|
||||
|
||||
.. admonition:: Difference to CPython
|
||||
:class: attention
|
||||
|
||||
|
||||
Reference in New Issue
Block a user