8000 Usability: Improve "tools/mpy_cross_all" to invoke the "mpy-cross" program coming from the mpy_cross distribution by amotl · Pull Request #4956 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Usability: Improve "tools/mpy_cross_all" to invoke the "mpy-cross" program coming from the mpy_cross distribution #4956

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

Closed
wants to merge 3 commits into from

Conversation

amotl
Copy link
Contributor
@amotl amotl commented Jul 28, 2019

Dear MicroPython developers and community,

Introduction

Coming from #4955 and building upon #3040 and #3057, we enabled tools/mpy_cross_all.py to invoke the mpy-cross program through the fine mpy-cross distribution package.

Setup

The operator will be able to decide to selectively install specific versions of mpy-cross like

source .venv2/bin/activate
pip install mpy-cross=1.9.4

into the Python environment running on her workstation.

Usage

Description

When running it from a Python environment where the mpy_cross modules is installed, mpy_cross_all.py will attempt to invoke mpy-cross from the mpy_cross distribution.

Otherwise, it will go down the established route of invoking mpy-cross directly, essentially expecting it to reside somewhere on $PATH.

Synopsis

source .venv2/bin/activate
time python tools/mpy_cross_all.py --out dist-packages-mpy dist-packages

real	0m0.439s
user	0m0.152s
sys	0m0.247s

We hope you like this.

With kind regards,
Andreas.

if installed within the current environment instead of invoking directly
@stinos
Copy link
Contributor
stinos commented Jul 29, 2019

Interesting, but despite the commit message title the commit does two unrelated things making it pretty hard to review: you're both introducing new functionality and refactoring the file to use functions etc. The latter should be a separate commit. For clarity, but also because suppose it isn't wanted it can just be dropped without having to change the other commit. Also the commit message doesn't adhere to project standards (missing dot at the end of the first line, body should be complete sentences I guess).

@amotl
Copy link
Contributor Author
amotl commented Jul 29, 2019

Dear @stinos,

thanks for your answer. Despite having tried hard already to be compliant with the MicroPython contribution guidelines, we will be happy to amend the patch according to your suggestions.

However, we would like to mention that the outlining of this process has a very nitpicky tone in it and would get a totally different and very much positive attitude when just telling newcomers that this are actually nits when compared to the respective content of the contribution.

Otherwise, as you will see when reviewing your own comment, the immediate talking about process related things occupying 95% of your post will definitively and instantly blast away much motivation for many newcomers. The motivational aspects of coming here and finding a way climbing all those steps onto the hills of MicroPython development already should receive more attention from the core developers, which I am counting you in.

We are usually applying high standards to our software development process and commit style so we are a bit surprised about the overinstructive tone. Saying that, we don't want to downplay the importance of nits in code reviewing but also would like to mention what they just are: nits ;].

Nevertheless, we are very happy that you are taking the time to look at our contribution and will definitively continue trying to make the contribution adhere to the project standards.

With kind regards,
Andreas.

@stinos
Copy link
Contributor
stinos commented Jul 29, 2019

@amotl apologies if my comment sounded overly negative, it was not meant as such, just wanted to explain how this PR can be improved so that when it gets an actual review by dpgeorge he can spend time on looking at the actual implementation without having to worry too much about less important aspects, i.e. the things I mentioned. Though in that light, I do think the issue about splitting the commit is just a bit more than just a nit as it really makes the review process harder, and I hope you understand that. But indeed I could have mentioned explicitly these are details in comparision with the actual functionality changed.

@andrewleech
Copy link
Contributor

For reference, the distribution of mpy-cross on pypi is not in any way official (as far as the Micropython Project or dpgeorge is concerned).
It's a convenience I provided via an auto-updating CI job I set up a long time ago that amazingly just keeps on building with zero user intervention: https://gitlab.com/alelec/mpy_cross/pipelines

As such it's possibly undesirable to have the official tools referencing the un-official distribution at all.

More importantly though, if you have the micropython source already you should always be able to compile mpy-cross for yourself quite easily, then you'll be guaranteed the version of it correctly matches the kernel being compiled.

@stinos
Copy link
Contributor
stinos commented Aug 1, 2019

Still, it wouldn't be bad to allow people to run whatever mpy-cross method they want. I think I've seen questions like 'please provide mpy-cross binaries' more than once, so I guess for beginners saying 'download source, pip install, run' is easier than 'make'.

But thinking about it for a bit, I now feel the approach in this PR is not suitable. Instead there is a simpler yet more generic solution: be to leave the original script intact, but with one change only: instead of hardcoding mpy-cross (which won't work for the Windows builds anyway since they have mpy-cross.exe ), use an environment variable. This is also consistent with how most other scripts are invoked, and is the approach offering the most extensibility with the least changes. And it allows using the pypi version, or any other version for that matter, via a simple wrapper. Which perhaps could be provided separately.

@amotl
Copy link
Contributor Author
amotl commented Aug 1, 2019

Dear @andrewleech and @stinos,

thanks for your valuable insights, for listening to what's behind our suggestion and for extrapolating it to similar demands you already recognized from the community through respective questions you have seen already. For what I am concerned about, @stinos last comment absolutely makes sense to us and we will adjust this PR accordingly.

While there would still be room for improvements to automate things like

# Will also work on Windows
pip install mpy_cross

# Get hold of the mpy-cross executable
export MPY_CROSS_BIN=$(python -c 'import mpy_cross; print mpy_cross.mpy_cross')

# Yeah!
/path/to/micropython/tools/mpy_cross_all.py --out lib-mpy lib

we will be happy to put this last mile into an external package similar to what @dhylands did with wrapping the REPL through rshell and respect the scope of core MicroPython just providing the baseline tooling for things like that.

We recognize you are busy keeping up the spirit and the very details of MicroPython so we don't want to bother you too much with our rambl 8000 ings. However, if you also like where we are aiming at here and outlined a bit through #4955 in general, we will be very happy if you could share some of your thoughts from time to time by regularly stepping by when your time permits.

In fact, we strive for making certain things easier for absolute beginners but well would like to improve other things for advanced users as well.

Thanks again and with kind regards,
Andreas.

@andrewleech
Copy link
Contributor

I'm also quite open to adding such functionality into my pypi package, or I'd suspect that mpy-cross could probably have python glob and/or walk support added directly to it at allow multiple file/folder parsing.

@dpgeorge
Copy link
Member
dpgeorge commented Jul 6, 2021

Thanks for this, but I think it's too complex. Alternatives to get the same functionality:

  1. Add support for an environment variable to set mpy-cross path/executable.
  2. Ask @andrewleech to add support to the mpy_cross package for a "mpy cross all" feature.

@dpgeorge dpgeorge closed this Jul 6, 2021
@andrewleech
Copy link
Contributor

I've added a ticket for what I think would be a good alternative to this feature in my package tracker, not sure if/when I will have a chance to look at implementing though https://gitlab.com/alelec/mpy_cross/-/issues/13

@amotl
Copy link
Contributor Author
amotl commented Jul 7, 2021 via email

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.

4 participants
0