pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

setup.py: use distutil's VC paths only (drop vswhere.exe)

Open kxrob opened this issue 3 years ago • 2 comments

kxrob avatar Sep 08 '22 18:09 kxrob

What problem is this solving?

mhammond avatar Sep 17 '22 05:09 mhammond

What problem is this solving?

The problems before these change were:

  • On my VS / VC Installation the search did not find the redist MFC dlls anymore at all since some months. There are 2 different path tree layouts.
  • In VS Installations where the search pattern principally matches, e.g. on github CI, it could pickup (by * wild card) a different MFC version for the DLLs than the corresponding INC/LIB paths from distutils when 2 or more VC versions were installed parallel. e.g.:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\lib\x64   (distutils)
copying C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.16.27012\x64\Microsoft.VC141.MFC\mfc140u.dll   
  instead of
copying C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.MFC\mfc140u.dll
  • (The same problem can also affect the extra ATLMFC INC/LIB paths searched in case when they are not set by vcvarsall.bat but existing.)
  • The vswhere mechanism is generally different from distutils and competing. The paths should fit to one and the same version for stable results.
  • It copied all 4 MFC redist DLLs , just 1 needed. Saves ~40% in wheel / artifacts size
  • When MFC was not installed the build of win32ui.pyd etc. was skipped (like with other modules lacking libs) but the build then broke trying to copy the MFC redist dlls nevertheless (since b222 it seems - see also #1964).
  • (minor other problems and bugs; wrong base class; in case sb would try mingw it would break early - compiler.initialized attr error; shutil.copyfile silent, no date prereserved )

Update:

  • Added: Only few skips are allowed for zero exit status / CI and release builds passing

kxrob avatar Sep 17 '22 20:09 kxrob

On my Windows 10 machine I was not able to build pywin32 on Python 3.12a1 without this change. If that is in any way relevant :)

Safihre avatar Oct 26 '22 18:10 Safihre

Fantastic, thanks!

mhammond avatar Nov 12 '22 07:11 mhammond