python / cpython

The Python programming language
https://www.python.org/
Other
60.82k stars 29.36k forks source link

Python WiX Build incorrect path to the wix-314 external / The imported project "C:\Wix.targets" was not found #118756

Open SebTV opened 1 month ago

SebTV commented 1 month ago

Bug report

Bug description:

On Windows try to build Python+Installer using tools\msi\buildrelease.bat: Use get_externals.batto offline-cache packages Set EXTERNALS_DIR start buildrelease.bat Result <...>Python-3.12.2\Tools\msi\launcher\launcher.wixproj" (default target) (1) -> <...>Python-3.12.2\Tools\msi\msi.targets(78,5): error MSB4019: The imported project "C:\Wix.targets" was not found. Confirm that the expression in the Import declaration "\Wix.targets" is correct, and that the file exists on disk. [<...>Python-3.12.2\Tools\msi\launcher\launcher.wixproj]

Note that get_externals.bat puts wix-314 into the root of EXTERNALS_DIR while Python-3.12.2/Tools/msi/wix.props expects a subdirectory windows-installer.

See the better workaround below. Deleting this patch as it goes into the wrong direction

CPython versions tested on:

3.12

Operating systems tested on:

Windows

SebTV commented 1 month ago

Addition: The same applies to the redist-1 path in the same file. My guess is that buildrelease.bat and wix.props (unlike get_externals.bat) do not check whether EXTERNALS_DIR is set and calculate different paths. All scripts should come to the same final results

zooba commented 1 month ago

get_externals.bat in Tools/msi should add the windows-installer directory to the path regardless of where it came from.

SebTV commented 1 month ago

Then this is the correct fix when EXTERNAL_DIRS is in use

--- Python-3.12.2/Tools/msi/get_externals.bat.org   2024-05-10 21:32:11.211387400 +0200
+++ Python-3.12.2/Tools/msi/get_externals.bat   2024-05-10 21:34:43.038714100 +0200
@@ -4,7 +4,11 @@

 set HERE=%~dp0
 if "%PCBUILD%"=="" (set PCBUILD=%HERE%..\..\PCbuild\)
-if "%EXTERNALS_DIR%"=="" (set EXTERNALS_DIR=%HERE%..\..\externals\windows-installer)
+if "%EXTERNALS_DIR%"=="" (
+  set EXTERNALS_DIR=%HERE%..\..\externals\windows-installer
+) else (
+  set EXTERNALS_DIR=%EXTERNALS_DIR%\windows-installer
+)
 if "%NUGET%"=="" (set NUGET=%EXTERNALS_DIR%\..\nuget.exe)
 if "%NUGET_URL%"=="" (set NUGET_URL=https://aka.ms/nugetclidl)

It should also be noted that EXTERNALS_DIR cannot be a UNC Path. light.exe cannot load WixUtilExtension.dll from an UNC Path.

light.exe : error LGHT0001 : The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

Exception Type: System.IO.FileNotFoundException

for the pip.wixproj

zooba commented 1 month ago

Correct, that's the fix, and we can make it in our repository, so the issue can stay open until someone makes a PR.