From 80df377e9512ac839ab19192ff1897ba30be098b Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 30 Oct 2019 16:26:11 +1100 Subject: py/modsys: Report .mpy version in sys.implementation. This commit adds a sys.implementation.mpy entry when the system supports importing .mpy files. This entry is a 16-bit integer which encodes two bytes of information from the header of .mpy files that are supported by the system being run: the second and third bytes, .mpy version, and flags and native architecture. This allows determining the supported .mpy file dynamically by code, and also for the user to find it out by inspecting this value. It's further possible to dynamically detect if the system supports importing .mpy files by `hasattr(sys.implementation, 'mpy')`. --- tests/basics/sys1.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/basics') diff --git a/tests/basics/sys1.py b/tests/basics/sys1.py index ab9138024..095824afa 100644 --- a/tests/basics/sys1.py +++ b/tests/basics/sys1.py @@ -18,3 +18,9 @@ try: except AttributeError: # Effectively skip subtests print(True) + +if hasattr(sys.implementation, 'mpy'): + print(type(sys.implementation.mpy)) +else: + # Effectively skip subtests + print(int) -- cgit v1.2.3