wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.

Home Page:http://wxpython.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to Build wxPython 4.2.1 on WOA

ZYPThu opened this issue · comments

Operating system: Windows 11 on ARM
wxPython version & source: wxPython 4.2.1 downloaded by pip
Python version & source: Python 3.11.6 for ARM64 stable release download from python.org

Description of the problem:
I try to build wxPython 4.2.1 on Windows 11 ARM, but it failed. I already have vsbuild tools installed.
The information are as following:

"D:\Anaconda3\envs\Python311-ARM64\Scripts\python.exe" -u build.py build
C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\build.py:43: DeprecationWarning: dep_util is Deprecated. Use functions from setuptools instead.
from distutils.dep_util import newer, newer_group
Will build using: "D:\Anaconda3\envs\Python311-ARM64\Scripts\python.exe"
3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 15:03:40) [MSC v.1935 64 bit (ARM64)]
Python's architecture is 64bit
cfg.VERSION: 4.2.1

  Running command: build
  Running command: build_wx
  Traceback (most recent call last):
    File "C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\build.py", line 2377, in <module>
      main(sys.argv[1:])
    File "C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\build.py", line 208, in main
      function(options, args)
    File "C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\build.py", line 1452, in cmd_build
      cmd_build_wx(options, args)
    File "C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\build.py", line 1462, in cmd_build_wx
      checkCompiler()
    File "C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\build.py", line 795, in checkCompiler
      info = getMSVCInfo(PYTHON, arch, set_env=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\galoi\AppData\Local\Temp\pip-req-build-4v921m59\buildtools\config.py", line 993, in getMSVCInfo
      from attrdict import AttrDict
    File "D:\Anaconda3\envs\Python311-ARM64\Lib\site-packages\attrdict\__init__.py", line 5, in <module>
      from attrdict.mapping import AttrMap
    File "D:\Anaconda3\envs\Python311-ARM64\Lib\site-packages\attrdict\mapping.py", line 4, in <module>
      **from collections import Mapping
  ImportError: cannot import name 'Mapping' from 'collections' (D:\Program Files\Python311-arm64\Lib\collections\__init__.py)**
  Finished command: build_wx (0.11s)
  Finished command: build (0.12s)
  Command '"D:\Anaconda3\envs\Python311-ARM64\Scripts\python.exe" -u build.py build' failed with exit code 1.
  [end of output]
Code Example (click to expand)
# Put code sample here

You probably have the wrong 'attrdict'.
Try attrdict3 instead.

See https://github.com/wxWidgets/Phoenix/blob/master/requirements/devel.txt

The build process also requires a bash. On my Windows I have a bash.exe on the path which will just print a message about WSL. Unfortunately wxPython tries to take this one instead of the one from cygwin.

On more trap to avoid:
When you install sip, you also get some binaries.
E.g. "...path..to..python\Scripts\sip-build.exe".
The Scripts dir needs to be on your path.

You probably have the wrong 'attrdict'. Try attrdict3 instead.

See https://github.com/wxWidgets/Phoenix/blob/master/requirements/devel.txt

The build process also requires a bash. On my Windows I have a bash.exe on the path which will just print a message about WSL. Unfortunately wxPython tries to take this one instead of the one from cygwin.

Thanks! That's really helpful.

Sadly I still cannot build this package on my own. The new problem seems caused by Setuptools probably. From the error code it seems that the setuptools does not work well for Python 3.11 ARM64. Here are the error codes.

Traceback (most recent call last):
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Scripting.py", line 119, in waf_entry_point
run_commands()
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Scripting.py", line 182, in run_commands
ctx=run_command(cmd_name)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Scripting.py", line 173, in run_command
ctx.execute()
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Configure.py", line 85, in execute
super(ConfigurationContext,self).execute()
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Context.py", line 92, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Context.py", line 133, in recurse
user_function(self)
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\wscript", line 98, in configure
conf.my_check_python_headers()
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf3-2.0.24-c88b74123ce8b9d1a27999f7cf96dff0\waflib\Configure.py", line 175, in fun
return f(*k,**kw)
^^^^^^^^^^
File "C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\wscript", line 474, in my_check_python_headers
dist_compiler.initialize()
File "D:\Anaconda3\envs\Python311-ARM64\Lib\site-packages\setuptools_distutils\msvc9compiler.py", line 373, in initialize
raise DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: --plat-name must be one of ('win32', 'win-amd64')
Command '"D:\Anaconda3\envs\Python311-ARM64\Scripts\python.exe" C:\Users\galoi\AppData\Local\Temp\pip-install-ac1iatlb\wxpython_4c1d4c335ec6495f8b8a94e42aa30259\bin\waf-2.0.24 --msvc_arch=x64 --python="D:\Anaconda3\envs\Python311-ARM64\Scripts\python.exe" --out=build/waf/3.11/x64/release configure build ' failed with exit code 2.
Finished command: build_py (0m5.292s)
Finished command: build (11m32.288s)
Command '"D:\Anaconda3\envs\Python311-ARM64\Scripts\python.exe" -u build.py build' failed with exit code 2.
[end of output]

Unfortunately, it looks like the Phoenix build process assumes 64-bit is x64, see here:
https://github.com/wxWidgets/Phoenix/blob/master/build.py#L1718

You could try tweaking those arguments. Unfortunately, arm64 w/ Windows is a rare thing, so not sure I'd have access to a machine to troubleshoot.

Windows on Arm is getting traction.

I managed to tweak build.py to make it ARM64-compatible.

The project compiles the C code, but the build fails at the waf level. Note: I am using Visual Studio 2022 on a native Windows on ARM machine.

First, I used platform.uname() instead of platform.architecture() otherwise I cannot tell if I am on ARM64.

image

Then, I added some branching to account for the new platform. Basically, whenever I see x64 I add arm64. Below are some examples; they are not exhaustive.

image
image
image

In the checkCompiler(), I have trouble getting the path to VC++ in the Hostarm64/arm64 directory. I keep getting the one in Hostx64\arm64, which didn't play well with the C code. So, I temporarily hardcoded the path.

image

I think it is setuptools issue.

The command run is python .\bin\waf-2.0.24 --msvc_arch=arm64 --python=C:\Users\X\PycharmProjects\Phoenix\.venv\Scripts\python.exe --out=build/waf/3.12/arm64/release configure build

image

I tried to tweak the waf script by hardcoding paths, but it seems compiled or obfuscated. Idk.

Any clues, please? Hope it helps

they are not exhaustive.

I think I did mistake in some places of file. Can you send your build.py file here?

Any clues, please?

in the last attempt, I edited incorrectly build.py now I edited it correctly and got the same result as you:

msvc: Impossible to find a valid architecture for building ['msvc 17.11'] - ['msvc 17.11']
(complete log in C:\Users\MaxRM\Downloads\wxPython-4.2.2\build\waf\3.9\arm64\release\config.log)
from C:\Users\MaxRM\Downloads\wxPython-4.2.2: msvc: Impossible to find a valid architecture for building ['msvc 17.11'] - ['msvc 17.11']

And here full logs of my errors:
config.log
wxPython000.txt

I will ask ChatGPT to help with this error, but almost sure that it will not help :(