Skip to content

mpy-cross/mpy_cross: Add a way to query the mpy version. #9437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

jimmo
Copy link
Member

@jimmo jimmo commented Sep 27, 2022

This returns the:

  • mpy_version
  • mpy_sub_version
  • native_arch
    for files compiled with this mpy-cross binary.

I considered doing this by adding a different --version mode to mpy-cross and parsing that. Happy to do it either way (and open to suggestions!)

Also fixes some other issues in the mpy_cross Python wrapper, mostly the default path (all current uses specify the path explicitly though so that's why this wasn't a problem).

This work was funded through GitHub Sponsors.

Copy link
Contributor

@dlech dlech left a comment

Choose a reason for hiding this comment

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

What is the use case for including the arch in the version?

@jimmo
Copy link
Member Author

jimmo commented Sep 27, 2022

What is the use case for including the arch in the version?

It's essentially a (complicated) way to map possible values of the -march flag to the resulting feature byte value.

Needed to be updated to use build/mpy-cross.

Also fixes some other issues in the Python wrapper:
 - Rename find_mpy_cross_binary to _find_mpy_cross_binary
 - Fix passing of -march arg.
 - Decode stdout from subprocess.
 - Print stdout from mpy-cross in __main__.py.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This returns the mpy version and sub-version for files compiled with this
mpy-cross binary.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
@jimmo jimmo force-pushed the mpy-cross-python-version branch from 12b5435 to e4d90be Compare September 28, 2022 01:50
@jimmo
Copy link
Member Author

jimmo commented Sep 28, 2022

Thanks @dlech

Updated to rename the new function to mpy_version() (we use "ABI" informally, but most things refer to this as the "mpy version"), and to parse the output of --version instead.

Also added a fix for the native arch constants (adding them to __all__), and docstrings.

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.

3 participants