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:
Damien George
2025-03-02 23:52:13 +11:00
parent b4cf82b2d6
commit f5b4545761
5 changed files with 61 additions and 4 deletions

View File

@@ -24,6 +24,12 @@ else:
# Effectively skip subtests
print(int)
if hasattr(sys.implementation, '_build'):
print(type(sys.implementation._build))
else:
# Effectively skip subtests
print(str)
try:
print(sys.intern('micropython') == 'micropython')
has_intern = True