Skip to content

Instantly share code, notes, and snippets.

@oleksis
Last active January 7, 2023 23:09
Show Gist options
  • Save oleksis/8637f096b97e18e00786e46465e97b34 to your computer and use it in GitHub Desktop.
Save oleksis/8637f096b97e18e00786e46465e97b34 to your computer and use it in GitHub Desktop.
Compile wxPython 4.1.2a1 using Microsoft C++ Build Tools 2019

Use case:

  • Windows 11 Dev Channel
  • GnuWin32: Make winget install -e --id GnuWin32.Make
  • Windows Subsystem for Linux 2
➜ wsl --version
WSL version: 0.50.2.0
Kernel version: 5.10.74.3
WSLg version: 1.0.29
Windows version: 10.0.22523.1000

Pre-requirements

sudo apt install -y graphviz
sudo apt install -y doxygen
  • Create the hard links for setuptools.msvc:EnvironmentInfo.VCRuntimeRedist
mklink /j "C:\Program Files (x86)\Microsoft Visual Studio 14.2" "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
mklink /j "C:\Program Files (x86)\Microsoft Visual Studio 14.2\VC\Redist\MSVC\v142\onecore" "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\onecore"

Apply patch to build.py

From 8c97512543a48c75a43a683fb962fb17d937c245 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oleksis=20Fraga=20Men=C3=A9ndez?= <[email protected]>
Date: Wed, 22 Dec 2021 01:44:46 -0500
Subject: [PATCH] Add WX_SKIP_DOXYGEN_VERSION_CHECK if use WSL2

---
 build.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/build.py b/build.py
index 7269d9591..6903d20c0 100755
--- a/build.py
+++ b/build.py
@@ -973,6 +973,15 @@ def _doDox(arg):
         d = posixjoin(wxDir(), 'docs/doxygen')
         d = d.replace('\\', '/')
         cmd = '"{}" -l -c "cd {} && ./regen.sh {}"'.format(bash, d, arg)
+        # If use Bash.exe and Doxygen.exe in WSL2
+        # os.environ["PATH"] = os.path.dirname(os.environ['DOXYGEN']) + ";" + os.environ["PATH"]
+        # cmd = '"{}" -l -c "cd {} && WX_SKIP_DOXYGEN_VERSION_CHECK=1 DOXYGEN="{}" ./regen.sh {}"'.format(bash, d, os.environ['DOXYGEN'], arg)
+
+        # Use WSL2
+        # Need install in the default distro doxygen and graphviz
+        if which('wsl'):
+            d = dos2bashPath(d)
+            cmd = '"{}" -l -c "cd {} && WX_SKIP_DOXYGEN_VERSION_CHECK=1 ./regen.sh {}"'.format(bash, d, arg)
     else:
         os.environ['DOXYGEN'] = doxCmd
         os.environ['WX_SKIP_DOXYGEN_VERSION_CHECK'] = '1'
powershell.exe /C "Write-Output $(Invoke-WebRequest -URI https://github.com/oleksis/Phoenix/commit/8c97512543a48c75a43a683fb962fb17d937c245.patch -UseBasicParsing).RawContent | git apply -"

Build wxPython on Windows

  • Using x86_x64 Cross Tools Command Prompt for VS 2019 (Run as Administrator)
gh repo clone wxWidgets/Phoenix
cd .\Phoenix\
git submodule update --init --recursive
%LOCALAPPDATA%\Programs\Python\Python310\python.exe -m venv venv
.\venv\Scripts\activate
pip install -r .\requirements.txt
python build.py dox etg --nodoc sip build

Create wheel

python setup.py bdist_wheel

Test wxPython

pip install dist\wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
python -c "import wx; print(wx.version());"

Clean

python -u build.py clean

TODO

  • Handle the case of using bash and wsl with doxygen and graphviz from Windows

Download wheel

Links

Pre-requirements

  • Python 3.10.1 , Packages in WSL2
  • Clone this branch with the integrated pyMSVC package and the buid.py patches
  • Now we don't need to use the "x86_x64 Cross Tools Command Prompt for VS 20xy"
  • Don't need create the hard links

Build wxPython on Windows

gh repo clone wxWidgets/Phoenix
cd .\Phoenix\
git submodule update --init --recursive
# ~\cpython\PCbuild\amd64\python.exe -m venv venv
# .\venv\Scripts\activate
python -m pip install -r .\requirements.txt
python build.py dox etg --nodoc sip build

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment