Skip to content
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

Publish mpy files on Release creation #168

Closed

Conversation

markafarrell
Copy link

@markafarrell markafarrell commented Sep 14, 2023

This PR will automatically compile mpy files for any .py files in src/

The workflow has 3 modes:

  1. When a new tag is created matching (v*.*.*), python source files in src/ will be complied for the latest 5 versions of micropython/mpy-cross and a release created for each version of micropython/mpy-cross with the compiled mpy files attached as assets.

Example workflow:

https://github.com/markafarrell/microdot/actions/runs/6211289626

  1. Once daily a workflow will run that will iterate over all tags matching v*.*.*, python source files in src/ will be complied for the latest version of micropython/mpy-cross and a release created with the compiled mpy files attached as assets. This will mean that when new version of mpy-cross are released there will also be compiled version of microdot available for people to use.

Example workflow:

https://github.com/markafarrell/microdot/actions/runs/6211317787

  1. The workflow can also be run manually and a json list of mpy-cross versions provided as an input. e.g. ["1.19.0", "1.19.1"]. This will result in releases being created for all tags matching v*.*.* compiled for the supplied versions of micropython. This will allow for the ad-hoc creation of compiled versions of microdot for any available version of micro-python.

Example workflow:

https://github.com/markafarrell/microdot/actions/runs/6211299190

This will make it easier for consumers to be able to consume microdot using mip

e.g.

mpremote a0 mip install https://github.com/miguelgrinberg/microdot/releases/download/micropython-1.20-v1.3.3/microdot.mpy

@miguelgrinberg
Copy link
Owner

The problem with this is that mpy files are versioned and can only be used on the version of MicroPython they were generated from. So these releases will only work with the current version of MicroPython, and are bound to break as soon as a new release comes out and the mpy version is increased.

The MicroPython folks have a solution for this, but the mpy repository they maintain is not open to third party packages, they just use it for the MicroPython standard library. Once and if they decide to allow third parties to upload packages this problem will be resolved, and people will be able to install mpy files directly, and without having to provide custom URL locations.

docs/intro.rst Outdated
@@ -16,6 +16,11 @@ them to *.mpy* files. These source files can also be
`frozen <https://docs.micropython.org/en/latest/develop/optimizations.html?highlight=frozen#frozen-bytecode>`_
and incorporated into a custom MicroPython firmware.

Alternatively you can install using `mpremote` and `mip`
```
mpremote a0 mip install https://github.com/miguelgrinberg/microdot/releases/download/v1.3.3/microdot.mpy
Copy link
Owner

Choose a reason for hiding this comment

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

this method of installation is flawed, because mpy files cannot be used across MicroPython versions. When new MicroPython releases are out the mpy files that were archived in the release will not work anymore. Basically you need a set of mpy files for each MicroPython release.

Copy link
Author

Choose a reason for hiding this comment

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

Updated to use include the micropython version

@markafarrell markafarrell changed the title Publish mpy files on Release creation Draft: Publish mpy files on Release creation Sep 15, 2023
@markafarrell markafarrell changed the title Draft: Publish mpy files on Release creation WIP: Publish mpy files on Release creation Sep 15, 2023
@markafarrell
Copy link
Author

The problem with this is that mpy files are versioned and can only be used on the version of MicroPython they were generated from. So these releases will only work with the current version of MicroPython, and are bound to break as soon as a new release comes out and the mpy version is increased.

The MicroPython folks have a solution for this, but the mpy repository they maintain is not open to third party packages, they just use it for the MicroPython standard library. Once and if they decide to allow third parties to upload packages this problem will be resolved, and people will be able to install mpy files directly, and without having to provide custom URL locations.

I didn't know this.

I have updated the PR to compile the mpy files for the latest 5 versions of micropython/mpy-cross. And create a release for each set of compiled files.

Feel free to close the PR if you aren't interested in doing this.

@markafarrell markafarrell changed the title WIP: Publish mpy files on Release creation Publish mpy files on Release creation Sep 15, 2023
@miguelgrinberg
Copy link
Owner

Are there any other third-party projects implementing this type of solution that you know of?

What I see is that this still does not address the problem that once a new MicroPython release comes out, none of the existing releases of Microdot will have the mpy files for it. As I said above, the MicroPython project needs to figure out a way to support third-party packages, and they haven't done that yet. See micropython/micropython-lib#578 and #67 for context on the discussions that have already happened on this topic.

@markafarrell
Copy link
Author

Are there any other third-party projects implementing this type of solution that you know of?

Not that I know of but it doesn't seem like an unresonable way to approach the problem

What I see is that this still does not address the problem that once a new MicroPython release comes out, none of the existing releases of Microdot will have the mpy files for it. As I said above, the MicroPython project needs to figure out a way to support third-party packages, and they haven't done that yet. See micropython/micropython-lib#578 and #67 for context on the discussions that have already happened on this topic.

We could approach this by having a scheduled job that will run regularly, iterate over all tags and compile the mpy files for the latest released mpy-cross.

At this point I'm just using this as an opportunity to play with github actions. Sorry if I'm being annoying.

@markafarrell markafarrell changed the title Publish mpy files on Release creation WIP: Publish mpy files on Release creation Sep 17, 2023
@markafarrell markafarrell changed the title WIP: Publish mpy files on Release creation Publish mpy files on Release creation Sep 17, 2023
@miguelgrinberg
Copy link
Owner

While I continue to wait for MicroPython to release a solution for third-party packages, I have added a section in the documentation on cross-compiling and freezing Microdot.

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.

2 participants