2017-05-01 10:39:39 +01:00
This is the experimental, community-supported Windows port of MicroPython.
2014-04-20 20:35:11 +01:00
It is based on Unix port, and expected to remain so.
2014-05-05 11:18:27 +01:00
The port requires additional testing, debugging, and patches. Please
consider to contribute.
2022-01-19 15:33:41 +00:00
All gcc-based builds use the gcc compiler from [Mingw-w64 ](https://www.mingw-w64.org/ ),
2020-09-22 12:59:47 +01:00
which is the advancement of the original mingw project. The latter is
getting obsolete and is not actively supported by MicroPython.
Build instruction assume you're in the ports/windows directory.
2014-04-20 20:35:11 +01:00
2017-04-29 22:37:05 +01:00
Building on Debian/Ubuntu Linux system
---------------------------------------
2014-04-20 20:35:11 +01:00
2020-09-22 12:59:47 +01:00
sudo apt-get install python3 build-essential gcc-mingw-w64
make -C ../../mpy-cross
2017-04-29 22:37:05 +01:00
make CROSS_COMPILE=i686-w64-mingw32-
2015-10-31 22:02:10 +00:00
2014-05-05 11:18:27 +01:00
2017-05-01 10:39:39 +01:00
Building under Cygwin
---------------------
2014-05-05 11:18:27 +01:00
2020-09-22 12:59:47 +01:00
Install Cygwin, then install following packages using Cygwin's setup.exe:
2015-11-01 17:20:39 +00:00
2017-04-29 22:37:05 +01:00
* mingw64-i686-gcc-core
* mingw64-x86_64-gcc-core
* make
2021-09-07 10:36:58 +01:00
* python3
2020-09-22 12:59:47 +01:00
2017-04-29 22:37:05 +01:00
Build using:
2014-05-05 11:18:27 +01:00
2020-09-22 12:59:47 +01:00
make -C ../../mpy-cross CROSS_COMPILE=i686-w64-mingw32-
2017-04-29 22:37:05 +01:00
make CROSS_COMPILE=i686-w64-mingw32-
2015-11-20 14:59:06 +00:00
2017-04-29 22:37:05 +01:00
Or for 64bit:
2015-11-20 14:59:06 +00:00
2020-09-22 12:59:47 +01:00
make -C ../../mpy-cross CROSS_COMPILE=x86_64-w64-mingw32-
2017-04-29 22:37:05 +01:00
make CROSS_COMPILE=x86_64-w64-mingw32-
2014-05-05 11:18:27 +01:00
2020-09-22 12:59:47 +01:00
Building under MSYS2
--------------------
Install MSYS2 from http://repo.msys2.org/distrib, start the msys2.exe shell and
install the build tools:
pacman -Syuu
pacman -S make mingw-w64-x86_64-gcc pkg-config python3
Start the mingw64.exe shell and build:
make -C ../../mpy-cross STRIP=echo SIZE=echo
make
2017-04-29 22:37:05 +01:00
Building using MS Visual Studio 2013 (or higher)
------------------------------------------------
2014-05-05 11:18:27 +01:00
2020-09-22 12:59:47 +01:00
Install Python. There are several ways to do this, for example: download and install the
latest Python 3 release from https://www.python.org/downloads/windows or from
https://docs.conda.io/en/latest/miniconda.html,
or open the Microsoft Store app and search for Python and install it.
Install Visual Studio and the C++ toolset (for recent versions: install
the free Visual Studio Community edition and the *Desktop development with C++* workload).
In the IDE, open `micropython-cross.vcxproj` and `micropython.vcxproj` and build.
2014-05-05 11:18:27 +01:00
2017-05-01 10:39:39 +01:00
To build from the command line:
2014-05-05 11:18:27 +01:00
2020-09-22 12:59:47 +01:00
msbuild ../../mpy-cross/mpy-cross.vcxproj
2017-04-29 22:37:05 +01:00
msbuild micropython.vcxproj
2015-06-04 17:29:51 +01:00
2021-11-25 01:16:29 +00:00
__Variants__
The msvc port supports variants (like the unix and windows mingw ports) and the one which gets built is
controlled by the `PyVariant` msbuild property. It defaults to `standard` .
The other variants can be built like:
msbuild micropython.vcxproj /p:PyVariant=dev
Or by adding a file [Directory.build.props ](https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets ) in this directory or a parent directory:
```xml
< Project >
< PropertyGroup >
< PyVariant > dev< / PyVariant >
< / PropertyGroup >
< / Project >
```
See [paths.props ](msvc/paths.props ) for other related variables like build and variant directories.
2017-05-01 10:59:39 +01:00
__Stack usage__
The msvc compiler is quite stack-hungry which might result in a "maximum recursion depth exceeded"
RuntimeError for code with lots of nested function calls.
There are several ways to deal with this:
2017-09-06 05:09:13 +01:00
- increase the threshold used for detection by altering the argument to `mp_stack_set_limit` in `ports/unix/main.c`
- disable detection all together by setting `MICROPY_STACK_CHECK` to "0" in `ports/windows/mpconfigport.h`
2017-05-01 10:59:39 +01:00
- disable the /GL compiler flag by setting `WholeProgramOptimization` to "false"
See [issue 2927 ](https://github.com/micropython/micropython/issues/2927 ) for more information.
2015-06-04 17:29:51 +01:00
2020-09-22 12:59:47 +01:00
Running the tests
-----------------
This is similar for all ports:
cd ../../tests
2021-03-11 05:09:27 +00:00
python ./run-tests.py
2021-01-14 12:23:15 +00:00
Though when running on Cygwin and using Cygwin's Python installation you'll need:
2021-03-11 05:09:27 +00:00
python3 ./run-tests.py
2020-09-22 12:59:47 +01:00
Depending on the combination of platform and Python version used it might be
needed to first set the MICROPY_MICROPYTHON environment variable to
the full path of micropython.exe.
2017-04-29 22:37:05 +01:00
Running on Linux using Wine
---------------------------
2015-06-04 17:29:51 +01:00
2015-11-01 17:20:39 +00:00
The default build (MICROPY_USE_READLINE=1) uses extended Windows console
2017-05-01 10:39:39 +01:00
functions and thus should be ran using the `wineconsole` tool. Depending
2015-11-01 17:20:39 +00:00
on the Wine build configuration, you may also want to select the curses
backend which has the look& feel of a standard Unix console:
2015-06-04 17:29:51 +01:00
wineconsole --backend=curses ./micropython.exe
2017-04-29 22:37:05 +01:00
For more info, see https://www.winehq.org/docs/wineusr-guide/cui-programs .
2015-06-04 17:29:51 +01:00
If built without line editing and history capabilities
2016-07-22 19:24:26 +01:00
(MICROPY_USE_READLINE=0), the resulting binary can be run using the standard
2017-04-29 22:37:05 +01:00
`wine` tool.