mhammond / pywin32

Python for Windows (pywin32) Extensions
5.06k stars 799 forks source link

build 306 cannot build with python3.12 #2249

Closed tangyinqi closed 3 months ago

tangyinqi commented 6 months ago

For all bugs, please provide the following information:

Expected behavior and actual behavior

Steps to reproduce the problem

Build 306 of pywin32 cannot be built with python 3.12. But build 306 of pywin32 can be built with python 3.86 (I built it in virtual windows environment) distutils was removed in python 3.12, which was still used in setup.py. So is that the reason?

Anyone who has successfully built pywin32 with python 3.12?

Below is where it failed building:

INFO:root:building 'win32file' extension
INFO:root:swigging win32/src/win32file.i to win32/src/win32file_swig.cpp
INFO:root:C:\__w\1\s\src\pywin32\swig\swig.exe -python -c++ -dnone -DSWIG_PY64BIT -o C:\__w\1\s\src\pywin32\win32\src\win32file_swig.cpp C:\__w\1\s\src\pywin32\win32\src\win32file.i
INFO:root:"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DDISTUTILS_BUILD -D_CRT_SECURE_NO_WARNINGS -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS -Icom/win32com/src/include -Iwin32/src -IC:\__w\1\s\out\buildenvs\venv-Test\include -IC:\__w\1\s\packages\python.3.12.1\tools\include -IC:\__w\1\s\packages\python.3.12.1\tools\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpwin32/src/win32file_comm.cpp /Fobuild\temp.win-amd64-cpython-312\Release\win32/src/win32file_comm.obj /Zi /Fdbuild\temp.win-amd64-cpython-312\Release\win32file_vc.pdb /EHsc /wd4163 -DUNICODE -D_UNICODE -DWINNT
INFO:root:"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DDISTUTILS_BUILD -D_CRT_SECURE_NO_WARNINGS -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS -Icom/win32com/src/include -Iwin32/src -IC:\__w\1\s\out\buildenvs\venv-Test\include -IC:\__w\1\s\packages\python.3.12.1\tools\include -IC:\__w\1\s\packages\python.3.12.1\tools\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /EHsc /Tpwin32/src/win32file_swig.cpp /Fobuild\temp.win-amd64-cpython-312\Release\win32/src/win32file_swig.obj /Zi /Fdbuild\temp.win-amd64-cpython-312\Release\win32file_vc.pdb /EHsc /wd4163 -DUNICODE -D_UNICODE -DWINNT
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x64\\cl.exe' failed with exit code 2
C:\__w\1\s\out\buildenvs\venv-Test\Scripts\python.exe setup.py install 
--skip-verstamp failed with exit code 1

This is the command I use to build:

setup.py install --debug --skip-verstamp

System information

Python version and distribution:

pywin32 version: build 306

Installed from PyPI or exe installer:

Windows Version:

DLL locations:

Avasam commented 6 months ago

@tangyinqi Do you have the full error log? The tests do run the install script on Python 3.12 (although not in debug mode), so I'm tempted to say it's likely an issue with your environment. https://github.com/mhammond/pywin32/blob/371f784d7a13edf6db407f25f1db286a6e9200f8/.github/workflows/main.yml#L19-L40

distutils was removed in python 3.12, which was still used in setup.py. So is that the reason?

setuptools stills vendors and patches-in distutils. So no I don't think so.

smanross commented 5 months ago

minor note as I was searching for bug notes before filing one as I found an issue in 306 using Python 3.12 on Windows... the imp module has been deprecated

imp is used in win32comext\axscript\client\pyscript.py at line 213 (in 306)

Avasam commented 5 months ago

@smanross that has been resolved in https://github.com/mhammond/pywin32/pull/2113 but isn't released yet.

If you need it, you can look at artefacts from the "CI" action: https://github.com/mhammond/pywin32/actions/workflows/main.yml?query=is%3Asuccess+branch%3Amain

Avasam commented 3 months ago

Both https://github.com/mhammond/pywin32/pull/2169 and #2113 are merged. The error shown by OP looks like issues related to missing the proper build tools on their environment. Please read https://github.com/mhammond/pywin32/blob/main/build_env.md .

If you still have this issue, please provide a complete log.