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

Update build.py to support running on Windows using Docker via WSL2. #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Josverl
Copy link
Contributor

@Josverl Josverl commented Oct 11, 2024

Hi,

I added logic to allow mpbuild to work on Windows + WSL2
for a speedy build the micropython repo needs to be hosted on the WSL2 filesystem, but it also works (given sufficient patience) on just a windows drive.

The changes are mostly path manipulation to translate from Windows to Linux paths, and to select a correct HOME folder.

arch-pico

There are a few things that may need additional attention, but I have not bisected them against pure linux :

  • mpbuild build BOARD clean does not work correctly,
    mpbuild build BOARD VARIANT clean does work , and mpbuild clean BOARD also
     (mpbuild) PS D:\> mpbuild build PIMORONI_TINY2040  clean
    Invalid variant
    
  • Tab completion, registration seems to work, but nothing is completed
  • running against the Debian Distro does not work, seems to be a permission issue of some kind.

@maholli
Copy link

maholli commented Oct 27, 2024

Thanks for this (and that gif), works great on my end!

NOTE: not sure if it's typer or this wsl patch, but arg parsing seems goofy. To build with a different build container, the cli needs this arrangement: mpbuild build --build-container micropython/build-micropython-arm:bookworm RPI_PICO2

@mattytrentini
Copy link
Owner

NOTE: not sure if it's typer or this wsl patch, but arg parsing seems goofy. To build with a different build container, the cli needs this arrangement: mpbuild build --build-container micropython/build-micropython-arm:bookworm RPI_PICO2

Yes, it's a Typer constraint - because there is a second optional argument (board variant) when the board is specified first, the argument parser becomes confused and tries to interpret the build-container option as the board variant.

There are a few workarounds, but I haven't decided which is the best option yet...

@mattytrentini
Copy link
Owner

Hi Jos,

Sorry for my slow response and thanks for the contribution!

I added logic to allow mpbuild to work on Windows + WSL2 for a speedy build the micropython repo needs to be hosted on the WSL2 filesystem, but it also works (given sufficient patience) on just a windows drive.

Thanks for this! I was actually in two minds as to whether to make this work - or try and detect that the filesystem was on a windows drive and throw an error (maybe with an option to override). My concern is that folks that are unaware of the performance cost are likely to be frustrated.

But making it work is probably a better option. 😜

* [ ]  `mpbuild build BOARD clean` does not work correctly,

I think the right solution here is to only support mpbuild clean x y, at least for now.

* [ ]  Tab completion, registration seems to work, but nothing is completed

I have tried this numerous times (even on a new, completely fresh, work laptop) and haven't had any issues. Which terminal are you using? I'm using bash.

(You did remember to start a new terminal?)

* [ ]  running against the Debian Distro does not work, seems to be a permission issue of some kind.

As in with Debian as the WSL distro? Interesting, I'll need to test - I'm using Ubuntu primarily.

@Josverl
Copy link
Contributor Author

Josverl commented Oct 28, 2024

I have tried this numerous times (even on a new, completely fresh, work laptop) and haven't had any issues. Which terminal are you using? I'm using bash.

  • using windows pwsh 7.x. there is autocomplete just for the static command (list , build) but not for the board. Perhaps its a matter of timeouts.
  • using bash in wsl it works as advertised.

As in with Debian as the WSL distro

  • indeed, I tested with Ubuntu, unbuntu 22.04, Arch and Kali linux as the default WSL host , and all worked.
    Debian uses a different root / user setup , and I think that does not work with the --user 1000:1000 parameters to docker.
    However I don't grok linux permissions, so Ill stop at 'it does not work for me'

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