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

Failed to Build wxPython 4.2.1 on WOA #2521

Open
ZYPThu opened this issue Jan 25, 2024 · 18 comments · May be fixed by #2663
Open

Failed to Build wxPython 4.2.1 on WOA #2521

ZYPThu opened this issue Jan 25, 2024 · 18 comments · May be fixed by #2663
Assignees

Comments

@ZYPThu
Copy link

ZYPThu commented Jan 25, 2024

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
@DietmarSchwertberger
Copy link
Contributor

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.

@DietmarSchwertberger
Copy link
Contributor

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.

@ZYPThu
Copy link
Author

ZYPThu commented Jan 26, 2024

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.

@ZYPThu
Copy link
Author

ZYPThu commented Jan 26, 2024

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]

@swt2c
Copy link
Collaborator

swt2c commented Jan 26, 2024

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.

@RiadhKHEDHIRI
Copy link

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

@Max-RM
Copy link

Max-RM commented Sep 19, 2024

they are not exhaustive.

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

@Max-RM
Copy link

Max-RM commented Sep 23, 2024

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 :(

@swt2c swt2c self-assigned this Jan 2, 2025
@swt2c
Copy link
Collaborator

swt2c commented Jan 2, 2025

Working on this. In addition to some changes in wxPython, some changes need to be made in WAF, and possibly in setuptools.

@swt2c swt2c linked a pull request Jan 3, 2025 that will close this issue
@Max-RM
Copy link

Max-RM commented Jan 3, 2025

Working on this. In addition to some changes in wxPython, some changes need to be made in WAF, and possibly in setuptools.

FINALLY!

Thank you great hero.

@Max-RM
Copy link

Max-RM commented Jan 3, 2025

@swt2c can you also make port for Windows 10 ARM32?
Because there is unofficial ARM32 Win builds of Python 3.12

@swt2c
Copy link
Collaborator

swt2c commented Jan 4, 2025

@swt2c can you also make port for Windows 10 ARM32? Because there is unofficial ARM32 Win builds of Python 3.12

Is there MSVC for ARM32? I can't find any evidence of it.

@Max-RM
Copy link

Max-RM commented Jan 4, 2025

@swt2c can you also make port for Windows 10 ARM32? Because there is unofficial ARM32 Win builds of Python 3.12

Is there MSVC for ARM32? I can't find any evidence of it.

Hi.
It was ported unofficially several days ago. Although it has many problems right now, and need to talk with it's creator Jeybee to install it correctly.

https://discord.com/channels/710026735294349322/710026735730556969/1320041037070073906

https://files.open-rt.party/Software/dev/llvm-armv7-w64-windows-msvc.zip

Btw maybe there is way to patch wxPython to force it use llvm-mingw instead?

@Max-RM
Copy link

Max-RM commented Jan 5, 2025

@swt2c can you also make port for Windows 10 ARM32? Because there is unofficial ARM32 Win builds of Python 3.12

Is there MSVC for ARM32? I can't find any evidence of it.

Hi again. If you already have successfully compiled wxPython to ARM64 Windows, can you send pre-compilled .whl file here?

@swt2c
Copy link
Collaborator

swt2c commented Jan 5, 2025

@swt2c can you also make port for Windows 10 ARM32? Because there is unofficial ARM32 Win builds of Python 3.12

Is there MSVC for ARM32? I can't find any evidence of it.

Hi again. If you already have successfully compiled wxPython to ARM64 Windows, can you send pre-compilled .whl file here?

Which Python version?

@Max-RM
Copy link

Max-RM commented Jan 5, 2025

@swt2c can you also make port for Windows 10 ARM32? Because there is unofficial ARM32 Win builds of Python 3.12

Is there MSVC for ARM32? I can't find any evidence of it.

Hi again. If you already have successfully compiled wxPython to ARM64 Windows, can you send pre-compilled .whl file here?

Which Python version?

3.12

@swt2c
Copy link
Collaborator

swt2c commented Jan 5, 2025

@Max-RM
Copy link

Max-RM commented Jan 6, 2025

wxPython-4.2.3a1-cp312-cp312-win_arm64.whl.zip

Thanks alot!!!
(Unfortunately still need to compile some other projects to run Amulet Map Editor on ARM64 Windows and make some changes like you did for wxPython package, but all this situation isn't related with wxPython so doesn't matter).

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 a pull request may close this issue.

5 participants