Build Python3 for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM


In the previous post, "Build 7-zip (19.00) for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM This time, I tried to build Python3.

I don't have much experience with Python myself, but I've seen it used occasionally as an OSS build aid script, so I thought it would be useful to make it native [here]. ](Https:// I saw an exchange that seemed to be something I could do, so I decided to take on the challenge.

Build Python3

For the time being, this time we will use the 3.8 series, which is the current Stable. Although there are some ridiculous restrictions (described later), I was able to build quickly with the following command group.

git clone -b 3.8
cd .\cpython\PCbuild
build.bat -p ARM64 -c Release



It seems that NuGet installs various external modules under . \ Cpython \ externals when building Python, but some external modules are not included for ARM64 and the build is skipped.

Among them, I thought it would be a little lonely that tkinter (TclTk), which is a standard Python GUI module, could not be used, so I tried to build TclTk.

Build tkinter (TclTk)

TclTk installed by NuGet at the time of this Python build was version 8.6.9, but I believe that the build is a little easier to pass [here]( Download and from the download.html) site and extract them to your work location.

File content modification

  1. It seems that the script does not support it, so I forcibly specified ARM64 this time. in. \ Tcl8.6.10 \ win Set ARM64 to MACHINE parameter on line 473 MACHINE=$(ARCH)MACHINE=ARM64

  2. Also, the cpuid function looks like an assembler, so I forcibly omitted it this time. tclWin32Dll.c in. \ Tcl8.6.10 \ win Comment out line 820 __cpuid(regsPtr, index);/*__cpuid(regsPtr, index);*/

Build TclTk

If expanded normally, launch a command window at the folder locations . \ Tcl8.6.10 \ win and. \ Tk8.6.10 \ win, respectively.

Prepare a toolset environment for ARM64 as usual

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_arm64

Now, start building!

However, for some reason, when building on Windows 10 on ARM, I get angry that "TCLSH_NATIVE is not set", so for the time being, I specified the x86 version of TclTk installed by NuGet when building python. ..

nmake -f release OPTS=threads TCLSH_NATIVE="work\cpython\externals\tcltk-\win32\bin\tclsh86t.exe"

Basically, the build passed with the above command, but when compiling the sqlite module of the Tcl side build, there was a skip due to an error related to the resource compiler as shown below.

.\tcl8.6.10\pkgs\sqlite3.30.1.2\win\Release_ARM64_VC1926\sqlite_ThreadedDynamic\sqlite.rc(4) : error RC2167 : unrecognized VERSIONINFO field;  BEGIN or comma expected
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\rc.EXE"' :Return code'0x2'

I thought it wouldn't affect tkinter, so I went through this time. ^^; In the future, even when I feel like it, I will investigate the handling of the resource compiler when building for ARM64.

Install TclTk

For the time being, I don't care about the difference in version numbers, and I'm stuck in the arm64 folder at TclTk, which was installed with NuGet when building Python.

nmake -f install INSTALLDIR="work\cpython\externals\tcltk-\arm64" TCLSH_NATIVE="work\cpython\externals\tcltk-\win32\bin\tclsh86t.exe"

Build tkinter (Rebuild Python)

Now that TclTk is ready, I will build tkinter (rebuild Python), but I wasn't sure if it would reconfigure well, so this time it's in . \ Cpython \ PCbuild. I launched the Visual Studio IDE from pcbuild.sln`, added tkinter in "Build Configuration" here, and rebuilt it.


I haven't verified the operation in detail, but for the time being, I managed to get to the point where the GUI window by tkinter was launched.


in conclusion

Isn't this the unique taste of a minor machine that the environment is gradually enriched while struggling? However, I hope that the official ARM64 version will be distributed as soon as possible in order to gain momentum for its widespread use.

Recommended Posts

Build Python3 for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM
Build Python development environment with Visual Studio Code
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
Build Python environment on Windows
Build python environment on windows
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
Try debugging Python on Raspberry Pi with Visual Studio.
PIL with Python on Windows 8 (for Google App Engine)
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Build an environment to execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people)
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Debugging
Build mlpy with python3.3 (64bit) (windows 64bit)
Install python and Visual Studio Code on windows10 (April 2020 version)
Getting started with Python 3.8 on Windows
Execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people) Environment construction
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Run servo with Python on ESP32 (Windows)
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Use without installing python 2.x on Windows
Build Python environment with Anaconda on Mac
Python Tools for Visual Studio Installation Guide
Installing PIL with Python 3.x on macOS
Run Python in C ++ on Visual Studio 2017
Python on Windows
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Put MeCab binding for Python with pip on Windows, mac and Linux
Rock-paper-scissors with Python Let's run on a Windows local server for beginners
Build python environment with pyenv on EC2 (ubuntu)
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Build a python environment with ansible on centos6
Run Python YOLOv3 in C ++ on Visual Studio 2017
GUI automation with Python x Windows App Driver
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Build procedure for TensorFlow 2.4.0 (Windows10, CUDA11.1.1, cuDNN 8.0.5, Python 3.8.6)
Image Processing with Python Environment Setup for Windows
Put Python 2.7.x on Mac OSX 10.15.5 with pyenv
Settings for Python coding in Visual Studio Code
Installing TensorFlow on Windows Easy for Python beginners
[Visual Studio Code] [Python] Tasks.json + problemMatcher settings for Python
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
I customized it with Visual Studio Code (mainly for python), so I will summarize it
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
Python starting with Windows 7
python basic on windows ②
Install python on windows
Build TensorFlow on Windows
Build XGBoost on Windows
build Python on Ubuntu
Install Python (for Windows)
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Problems with windows python being called on pipenv on WSL
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Summary of tools for operating Windows GUI with Python
Build a GVim-based Python development environment on Windows 10 (1) Installation
Information for controlling the motor with Python on RaspberryPi
Build a Python development environment on Mac OS X
Make Visual Studio Code autocomplete for python external libraries
Procedure for building a CDK environment on Windows (Python)
Japanese output when dealing with python in visual studio
AWS SDK for Python (Boto3) development in Visual Studio 2017