Skip to content

Commit

Permalink
MSI by WIX5 (#365)
Browse files Browse the repository at this point in the history
* fixed wix v5 issues after automatic transformation and adaptions for heat which is not part of wix tooling
- PythonScript.wxs(52) : error WIX0094: The identifier 'WixUI:WixUI_FeatureTree_X64' could not be found. Ensure you have typed the reference correctly and that all the necessary inputs are provided to the linker.
- PythonScript.wxs(54) : warning WIX5437: It is no longer necessary to define the standard directory 'ProgramFiles64Folder'. Use the StandardDirectory element instead.
Linking installer - generating MSI

see also
oleg-shilo/wixsharp#1655 for WIX5437
https://wixtoolset.org/docs/tools/wixext/wixui/ for WIX0094
add extension as described at https://wixtoolset.org/docs/tools/wixext/

* - use files (https://wixtoolset.org/docs/fivefour/ , https://wixtoolset.org/docs/schema/wxs/files/ , wixtoolset/issues#7857) instead of heat for file harvesting
- remove unused xsl msi scripts

TODO:
Remove also __pycache__ dirs on unistall, maybe also pyc files
  • Loading branch information
chcg authored Dec 30, 2024
1 parent 9b8a1e8 commit db0c1c7
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 273 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/CI_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ jobs:
$env:PYTHONBUILDDIR_X64='${{ github.workspace }}\packages\python.3.12.8\tools'
$env:PYTHONBUILDDIR='${{ github.workspace }}\packages\pythonx86.3.12.8\tools'
Rename-Item -Path ".\buildPaths.bat.orig" -NewName "buildPaths.bat"
$env:WIX_PATH="C:\Program Files (x86)\WiX Toolset v3.11\bin"
$env:PATH = $env:PATH + ';' + $env:WIX_PATH
dotnet tool install --global wix
.\buildAll.bat ${{ matrix.build_platform }}
1 change: 1 addition & 0 deletions PythonScript/project/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WixToolset.UI.wixext" version="5.0.2" targetFramework="native" />
<package id="boost" version="1.87.0" targetFramework="native" />
<package id="boost_python312-vc143" version="1.87.0" targetFramework="native" />
<package id="python" version="3.12.8" targetFramework="native" />
Expand Down
1 change: 1 addition & 0 deletions PythonScript/project/packages_local_pydebug.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WixToolset.UI.wixext" version="5.0.2" targetFramework="native" />
<package id="boost" version="1.87.0" targetFramework="native" />
<package id="boost_python312-vc143" version="1.87.0" targetFramework="native" />
</packages>
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ after_build:
- if "%configuration%"=="Release" make.bat html

- cd "%APPVEYOR_BUILD_FOLDER%"\installer
- set WIX_PATH="C:\Program Files (x86)\WiX Toolset v3.14\bin"
- set PATH=%WIX_PATH%;%PATH%
- dotnet tool install --global wix
- if "%platform_input%"=="x64" SET PYTHONBUILDDIR_X64="%APPVEYOR_BUILD_FOLDER%"\packages\python.3.12.8\tools
- if "%platform_input%"=="Win32" SET PYTHONBUILDDIR="%APPVEYOR_BUILD_FOLDER%"\packages\pythonx86.3.12.8\tools
- copy "%APPVEYOR_BUILD_FOLDER%"\installer\buildPaths.bat.orig "%APPVEYOR_BUILD_FOLDER%"\installer\buildPaths.bat
Expand Down
133 changes: 72 additions & 61 deletions installer/PythonScript.wxs
Original file line number Diff line number Diff line change
@@ -1,70 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">


<?if $(var.Platform) = x64 ?>
<?define ProductName = "PythonScript plugin for Notepad++ (64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?else?>
<?define ProductName = "PythonScript plugin for Notepad++" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>

<Product Id="*" Language="1033" Manufacturer="Dave Brotherstone" Name="$(var.ProductName)"
UpgradeCode="717FEC91-6F2B-459D-9868-0A3A037F5195"
Version="$(var.version)">



<Package Id='*' InstallerVersion='200' Platform="$(var.Platform)" Compressed='yes' />

<Upgrade Id="717FEC91-6F2B-459D-9868-0A3A037F5195">
<UpgradeVersion Minimum="0.0.0.0" Maximum="$(var.version)"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" IncludeMaximum="no" />
<?endif?>

<Package Language="1033" Manufacturer="Dave Brotherstone" Name="$(var.ProductName)" UpgradeCode="717FEC91-6F2B-459D-9868-0A3A037F5195" Version="$(var.version)" InstallerVersion="200"><Upgrade Id="717FEC91-6F2B-459D-9868-0A3A037F5195">
<UpgradeVersion Minimum="0.0.0.0" Maximum="$(var.version)" Property="PREVIOUSVERSIONSINSTALLED" IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>

<Media Id='1' Cabinet='PythonScript.cab' EmbedCab='yes' />
<Media Id="1" Cabinet="PythonScript.cab" EmbedCab="yes" />

<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<RemoveExistingProducts Before="InstallInitialize" />
</InstallExecuteSequence>

<Property Id="INSTALLLEVEL" Value="5" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)">
<Directory Id="INSTALLDIR" Name="Notepad++">
<Directory Id="D_Plugins" Name="plugins">
<Directory Id="D_PythonScript" Name="PythonScript">
<Directory Id="D_PythonLib" Name="lib" />
<Directory Id="D_Scripts" Name="scripts">
<Component Id="C_startup.py" Guid="*" Win64="$(var.Win64)">
<RemoveFile Id="Remove_F_startup.py" Name="startup.py" On="install"/>
<RemoveFile Id="Remove_F_startup.pyc" Name="startup.pyc" On="install"/>
<File Id="F_startup.py" KeyPath="yes" Name="startup.py" Source="$(var.baseDir)\scripts\startup.py" />
</Component>
<Directory Id="D_npp_unit_tests" Name="npp_unit_tests" />
<Directory Id="D_SampleScripts" Name="Samples" />
</Directory>
<Directory Id="D_DocPythonScript" Name="doc"/>
<Component Id="C_pythonscript.dll" Guid="*" Win64="$(var.Win64)">
<RemoveFile Id="Remove_F_pythonscript.dll" Name="PythonScript.dll" On="install"/>
<File Id="F_pythonscript.dll" Name="PythonScript.dll" Source="$(var.baseDir)\$(var.variantDir)\Release\PythonScript.dll" />
</Component>
<Component Id="C_python312.dll" Guid="*" Win64="$(var.Win64)">
<RemoveFile Id="Remove_F_python312.dll" Name="python312.dll" On="install"/>
<File Id="F_python312.dll" Name="python312.dll" Source="$(var.pythonDir)\python312.dll" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>

<Feature Id="FT_PythonScriptAll" Title="PythonScript Components" Display="expand" AllowAdvertise="no" ConfigurableDirectory="INSTALLDIR"
Description="Install directory should be the install directory of your Notepad++ directory">
<Feature Id="FT_PythonScriptAll" Title="PythonScript Components" Display="expand" AllowAdvertise="no" ConfigurableDirectory="INSTALLDIR" Description="Install directory should be the install directory of your Notepad++ directory">
<Feature Id="FT_PythonScript" Title="PythonScript plugin" AllowAdvertise="no">
<ComponentRef Id="C_startup.py" />
<ComponentRef Id="C_pythonscript.dll" />
Expand All @@ -83,16 +38,72 @@
<ComponentGroupRef Id="CG_PythonTclTkLibDll" />
</Feature>
<Feature Id="FT_UnitTests" Title="Unit Tests" Level="10" AllowAdvertise="no" Description="Unit tests for PythonScript. Not usually necessary, but if you are having problems, any issues reported from the tests will be useful for diagnosis.">
<ComponentGroupRef Id="CG_UnitTests" />
<ComponentGroupRef Id="CG_Unittests" />
</Feature>
</Feature>

<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
<WixVariable Id="WixUIBannerBmp" Value="images\banner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="images\dialog.bmp" />
<UIRef Id="WixUI_FeatureTree" />

</Product>
<ui:WixUI Id="WixUI_FeatureTree" />

<ComponentGroup Id="CG_PythonLib" Directory="D_PythonLib">
<Files Include="..\pythonlib\full\**" />
</ComponentGroup>

<ComponentGroup Id="CG_PythonLibDll" Directory="D_PythonLib">
<Files Include="..\pythonlib\full_dll$(var.nameAddon)\**" />
</ComponentGroup>

<ComponentGroup Id="CG_HtmlDocs" Directory="D_DocPythonScript">
<Files Include="..\docs\build\html\**" />
</ComponentGroup>

<ComponentGroup Id="CG_SampleScripts" Directory="D_SampleScripts">
<Files Include="..\scripts\Samples\**" />
</ComponentGroup>

<ComponentGroup Id="CG_PythonTclTkLib" Directory="D_PythonLib">
<Files Include="..\pythonlib\tcl\**" />
</ComponentGroup>

<ComponentGroup Id="CG_PythonTclTkLibDll" Directory="D_PythonLib">
<Files Include="..\pythonlib\tcl_dll$(var.nameAddon)\**" />
</ComponentGroup>

<ComponentGroup Id="CG_Unittests" Directory="D_npp_unit_tests">
<Files Include="..\PythonScript\python_tests\**" />
</ComponentGroup>


<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLDIR" Name="Notepad++">
<Directory Id="D_Plugins" Name="plugins">
<Directory Id="D_PythonScript" Name="PythonScript">
<Directory Id="D_PythonLib" Name="lib" />
<Directory Id="D_Scripts" Name="scripts">
<Component Id="C_startup.py">
<RemoveFile Id="Remove_F_startup.py" Name="startup.py" On="install" />
<RemoveFile Id="Remove_F_startup.pyc" Name="startup.pyc" On="install" />
<File Id="F_startup.py" KeyPath="yes" Name="startup.py" Source="$(var.baseDir)\scripts\startup.py" />
</Component>
<Directory Id="D_npp_unit_tests" Name="npp_unit_tests" />
<Directory Id="D_SampleScripts" Name="Samples" />
</Directory>
<Directory Id="D_DocPythonScript" Name="doc" />
<Component Id="C_pythonscript.dll">
<RemoveFile Id="Remove_F_pythonscript.dll" Name="PythonScript.dll" On="install" />
<File Id="F_pythonscript.dll" Name="PythonScript.dll" Source="$(var.baseDir)\$(var.variantDir)\Release\PythonScript.dll" />
</Component>
<Component Id="C_python312.dll">
<RemoveFile Id="Remove_F_python312.dll" Name="python312.dll" On="install" />
<File Id="F_python312.dll" Name="python312.dll" Source="$(var.pythonDir)\python312.dll" />
</Component>
</Directory>
</Directory>
</Directory>
</StandardDirectory>
</Package>


</Wix>
104 changes: 7 additions & 97 deletions installer/buildInstaller.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,105 +43,15 @@ mkdir %INST_TEMP_DIR%
SET /p PYTHONSCRIPTVERSION= < %INST_TEMP_DIR%\version.txt


echo Generating WiX information for ..\pythonlib\full
heat dir ..\pythonlib\full -ag -cg CG_PythonLib -dr D_PythonScript -var var.pylibSource -t changeDirLib.xsl -o %INST_TEMP_DIR%\fullLib.wxs
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling python lib WiX source
candle %INST_TEMP_DIR%\fullLib.wxs -o %INST_TEMP_DIR%\fullLib.wixobj -dpylibSource=..\pythonlib\full -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Generating WiX information for ..\pythonlib\full_dll%NAME_ADDON%
heat dir ..\pythonlib\full_dll%NAME_ADDON% -ag -cg CG_PythonLibDll -dr D_PythonScript -var var.pylibSource -t changeDirLib.xsl -o %INST_TEMP_DIR%\fullLib_dll%NAME_ADDON%.wxs
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling python pyd lib WiX source
candle %INST_TEMP_DIR%\fullLib_dll%NAME_ADDON%.wxs -o %INST_TEMP_DIR%\fullLib_dll%NAME_ADDON%.wixobj -dpylibSource=..\pythonlib\full_dll%NAME_ADDON% -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Generating WiX information for ..\pythonlib\tcl
heat dir ..\pythonlib\tcl -ag -cg CG_PythonTclTkLib -dr D_PythonScript -var var.pylibSource -t changeDirLib.xsl -o %INST_TEMP_DIR%\tcl.wxs
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling tcl lib WiX source
candle %INST_TEMP_DIR%\tcl.wxs -o %INST_TEMP_DIR%\tcl.wixobj -dpylibSource=..\pythonlib\tcl -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Generating WiX information for ..\pythonlib\tcl_dll%NAME_ADDON%
heat dir ..\pythonlib\tcl_dll%NAME_ADDON% -ag -cg CG_PythonTclTkLibDll -dr D_PythonScript -var var.pylibSource -t changeDirLib.xsl -o %INST_TEMP_DIR%\tcl_dll%NAME_ADDON%.wxs
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling tcl lib WiX source
candle %INST_TEMP_DIR%\tcl_dll%NAME_ADDON%.wxs -o %INST_TEMP_DIR%\tcl_dll%NAME_ADDON%.wixobj -dpylibSource=..\pythonlib\tcl_dll%NAME_ADDON% -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Generating WiX information for ..\PythonScript\scripts\Samples
heat dir ..\scripts\Samples -ag -cg CG_SampleScripts -dr D_PythonScript -var var.scriptSource -t changeDirSampleScripts.xsl -o %INST_TEMP_DIR%\sampleScripts.wxs
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling Sample Scripts WiX source
candle %INST_TEMP_DIR%\sampleScripts.wxs -o %INST_TEMP_DIR%\sampleScripts.wixobj -dscriptSource=..\scripts\Samples -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)


echo Generating WiX information for ..\PythonScript\python_tests
heat dir ..\PythonScript\python_tests -ag -cg CG_UnitTests -dr D_PythonScript -var var.unittestSource -t changeDirTests.xsl -o %INST_TEMP_DIR%\unittests.wxs -platform=%NAME_ADDON%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling Unit test WiX source
candle %INST_TEMP_DIR%\unittests.wxs -o %INST_TEMP_DIR%\unittests.wixobj -dunittestSource=..\PythonScript\python_tests -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Generating WiX information for ..\docs\build\html
heat dir ..\docs\build\html -ag -cg CG_HtmlDocs -dr D_PythonScript -var var.htmldocsSource -t changeDirHtmlDoc.xsl -o %INST_TEMP_DIR%\htmldoc.wxs -platform=%NAME_ADDON%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling Html doc WiX source
candle %INST_TEMP_DIR%\htmldoc.wxs -o %INST_TEMP_DIR%\htmldoc.wixobj -dhtmldocsSource=..\docs\build\html -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)

echo Compiling main PythonScript installer
candle pythonscript.wxs -o %INST_TEMP_DIR%\pythonscript.wixobj -dversion=%PYTHONSCRIPTVERSION% -dbaseDir=.. -dpythonDir=%PYTHONBUILDDIR% -dvariantDir=%PYTHONSCRIPTDLLDIR% -dPlatform=%MSI_ARCH% -arch %MSI_ARCH%
if NOT [%ERRORLEVEL%]==[0] (
goto error
)


echo Linking installer - generating MSI
IF NOT EXIST "build\%PYTHONSCRIPTVERSION%" (
mkdir build\%PYTHONSCRIPTVERSION%
)
cd ..\packages
echo add UI extension globally
wix extension add -g WixToolset.UI.wixext
wix extension list -g
cd ..\installer


light %INST_TEMP_DIR%\pythonscript.wixobj %INST_TEMP_DIR%\fullLib.wixobj %INST_TEMP_DIR%\fullLib_dll%NAME_ADDON%.wixobj %INST_TEMP_DIR%\unittests.wixobj %INST_TEMP_DIR%\tcl.wixobj %INST_TEMP_DIR%\tcl_dll%NAME_ADDON%.wixobj %INST_TEMP_DIR%\sampleScripts.wixobj %INST_TEMP_DIR%\htmldoc.wixobj -o build\%PYTHONSCRIPTVERSION%\PythonScript_%PYTHONSCRIPTVERSION%%NAME_ADDON%.msi -ext WixUIExtension
echo Compiling PythonScript installer
wix build pythonscript.wxs -o build\%PYTHONSCRIPTVERSION%\PythonScript_%PYTHONSCRIPTVERSION%%NAME_ADDON%.msi -d version=%PYTHONSCRIPTVERSION% -d baseDir=.. -d pythonDir=%PYTHONBUILDDIR% -d variantDir=%PYTHONSCRIPTDLLDIR% -d Platform=%MSI_ARCH% -d nameAddon=%NAME_ADDON% -arch %MSI_ARCH% -ext "WixToolset.UI.wixext"
if NOT [%ERRORLEVEL%]==[0] (
goto error
)
Expand Down
2 changes: 1 addition & 1 deletion installer/buildReleaseZips.bat
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mkdir %INSTALLERDIR%\build\%PYTHONSCRIPTVERSION%
cd %INST_TEMP_DIR%\release\Full\plugins\PythonScript
%SEVENZIPEXE% a -r -tzip %INSTALLERDIR%\build\%PYTHONSCRIPTVERSION%\PythonScript_Full_%PYTHONSCRIPTVERSION%%NAME_ADDON%_PluginAdmin.zip .

cd %INST_TEMP_DIR%\release\Full
cd %INSTALLERDIR%\%INST_TEMP_DIR%\release\Full
%SEVENZIPEXE% a -r -t7z %INSTALLERDIR%\build\%PYTHONSCRIPTVERSION%\PythonScript_Full_%PYTHONSCRIPTVERSION%%NAME_ADDON%.7z .
%SEVENZIPEXE% a -r -tzip %INSTALLERDIR%\build\%PYTHONSCRIPTVERSION%\PythonScript_Full_%PYTHONSCRIPTVERSION%%NAME_ADDON%.zip .

Expand Down
7 changes: 0 additions & 7 deletions installer/changeDirHtmlDoc.xsl

This file was deleted.

10 changes: 0 additions & 10 deletions installer/changeDirLib.xsl

This file was deleted.

7 changes: 0 additions & 7 deletions installer/changeDirSampleScripts.xsl

This file was deleted.

7 changes: 0 additions & 7 deletions installer/changeDirTests.xsl

This file was deleted.

2 changes: 2 additions & 0 deletions installer/extractVersion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

"""Extracts the version number of PythonScript"""
from __future__ import print_function

Expand Down
Loading

0 comments on commit db0c1c7

Please sign in to comment.