Skip to content

mpremote: Use hatch to build mpremote package. #10645

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 2 commits into from
Feb 24, 2023

Conversation

jimmo
Copy link
Member

@jimmo jimmo commented Feb 2, 2023

Extending on the idea from #8404 (@andrewleech ) the idea is to use as little custom code as possible and use standard tools (i.e. hatch) from the Python packaging ecosystem to:

  • Get the correct version tag from the git history (via hatch-vcs)
  • Add pyboard.py to the package. (And soon, manifestfile.py too)

Also includes the GitHub workflow from #8404 to build the wheel. Increased the fetch depth to 1000 (we're currently 850 commits from 1.19.1 !!!)

This works both via python -m build (this is what the workflow uses) as well as hatch build. python -m build has the advantage of automatically fetching all dependencies, you don't need to manually install any hatch packages.

In order to make the versioning work, we need to add mpremote tags to this repo. I suggest adding for example mpremote-v0.4.0, which can be matched by the tag-pattern regular expression. Right now it matches the MicroPython version instead (e.g. v1.19.1). Alternatively, we could pin the mpremote releases to the MicroPython releases and use the same tags?

The version strings look like:
X.Y.Z -- Clean build at the tag
X.Y.Z.postN+gHASH -- Clean build, N revisions from the most recent tag
X.Y.Z.postN+gHASH.dYYYYMMDD -- Dirty build, N revisions from the most recent tag

@jimmo jimmo changed the title Mpremote wheel mpremote: Use hatch to build mpremote package. Feb 2, 2023
@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
        rp2:    +0 +0.000% PICO

@jimmo
Copy link
Member Author

jimmo commented Feb 2, 2023

Also adds a requirements.txt mostly for personal preference and uses that for the project requirements -- it's nice to be able tojust run pip install -r requirements.txt when running the package directly from the source repo.

@jimmo
Copy link
Member Author

jimmo commented Feb 2, 2023

Another note: I investigated using setuptools rather than hatch and wasted a lot of time trying to get the pyboard.py inclusion to work. It does not appear to be supported.

@andrewleech
Copy link
Contributor

Could also consider moving mpremote and its dependant scripts to a submodule for a much cleaner package design and ease of tag/release...

@jimmo
Copy link
Member Author

jimmo commented Feb 3, 2023

Could also consider moving mpremote and its dependant scripts to a submodule for a much cleaner package design and ease of tag/release...

Honestly there was a point when I was trying to get setuptools to work where I considered this, but you still have the same problem with pyboard.py living in main-repo/tools.

And the mpremote-vX.Y.Z tags work well.

This allows the entire configuration to be defined in a single file,
including the logic for including pyboard.py and automatically versioning
based on the git tag.

Building the package works both via `python -m build` as well as
`hatch build`.  `python -m build ` has the advantage of automatically
fetching all dependencies, you don't need to manually install any hatch
packages.

In order to make the versioning work, and also keep things simpler for end
users, mpremote releases will now be the same as MicroPython releases and
use the same tag.  The version strings for mpremote will look like:
- X.Y.Z -- clean build at the tag
- X.Y.Z.postN+gHASH -- clean build, N revisions from the most recent tag
- X.Y.Z.postN+gHASH.dYYYYMMDD -- dirty build, N revisions from out

This commit extends on the idea from micropython#8404.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
@dpgeorge
Copy link
Member

Thanks for this, it's a good improvement.

Alternatively, we could pin the mpremote releases to the MicroPython releases and use the same tags?

Yes I think this is the best and simplest solution, and will reduce confusion for users, to just have mpremote and MicroPython versioned the same. I tested this and it works, although we will need to now always have a revision number in the version, eg v1.20.0. I'm very happy to do that.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
@dpgeorge
Copy link
Member

I tuned the github workflow to only run on a pull request if tools/ files change (but it still runs unconditionally on a normal push to master).

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