瀏覽代碼

Experiment with building MSI installer for Mu using Wix

Thomas Kluyver 7 年之前
父節點
當前提交
d31ffd430a
共有 5 個文件被更改,包括 114 次插入0 次删除
  1. 10 0
      examples/_mu/README.md
  2. 25 0
      examples/_mu/installer.cfg
  3. 32 0
      examples/_mu/prep_files.py
  4. 18 0
      examples/_mu/wixit.py
  5. 29 0
      examples/_mu/wrapper.wxs

+ 10 - 0
examples/_mu/README.md

@@ -0,0 +1,10 @@
+# Packaging Mu using WiX
+
+This is an experiment. So far, it's nearly but not quite working.
+
+To build the MSI package:
+
+1. Run `pynsist installer.cfg --no-makensis` to assemble the necessary files.
+2. Run `prep_files.py` in this folder to move some files and call 'heat' to
+   make a list of the files.
+3. Run `wixit.py` in this folder to build the msi package.

+ 25 - 0
examples/_mu/installer.cfg

@@ -0,0 +1,25 @@
+[Application]
+name=Mu
+version=1.0
+entry_point=mu.app:run
+
+[Python]
+version=3.6.3
+bitness=64
+format=bundled
+
+[Include]
+pypi_wheels= 
+	mu-editor==1.0.0b12
+    PyQt5==5.9.1
+    sip==4.19.5
+	pyserial==3.4
+	pycodestyle==2.3.1
+	pyflakes==1.6.0
+	QScintilla==2.10.1
+	qtconsole==4.3.1
+	traitlets==4.3.2
+	ipython_genutils==0.2.0
+	jupyter_core==4.4.0
+	jupyter_client==5.1.0
+	pygments==2.2.0

+ 32 - 0
examples/_mu/prep_files.py

@@ -0,0 +1,32 @@
+import os
+from subprocess import run
+
+pjoin = os.path.join
+
+# Run pynsist to gather the necessary files
+#run([sys.executable, '-m', 'nsist', 'installer.cfg', '--no-makensis'], check=True)
+
+# Remove NSIS script - we're not using it today
+try:
+	os.unlink(pjoin('build', 'nsis', 'installer.nsi'))
+except FileNotFoundError:
+	pass
+
+# Move msvcrt files into Python directory, where they need to be installed
+msvcrt_dir = pjoin('build', 'nsis', 'msvcrt')
+python_dir = pjoin('build', 'nsis', 'Python')
+if os.path.isdir(msvcrt_dir):
+	for file in os.listdir(msvcrt_dir):
+		os.rename(pjoin(msvcrt_dir, file), pjoin(python_dir, file))
+	os.rmdir(msvcrt_dir)
+	
+# Run 'heat' (part of Wix) to create a list of the files to install
+HEAT = os.path.join(os.environ['WIX'], 'bin', 'heat')
+run([HEAT, 'dir', pjoin('build', 'nsis'),
+		'-out', 'files.wxs',  # Target file (wix xml format)
+		'-ag',                # Autogenerated GUIDs for files ('*' - generated at compile time)
+		'-sfrag',             # Single fragment. Not sure if it matters, but it looks neater.
+		'-cg', 'ApplicationFiles', # Component group. Referenced from wrapper.wxs
+		'-dr', 'INSTALLDIR',  # Directory to install files into
+		'-srd',               # Suppress Root Directory (don't make 'nsis' folder in install dir)
+	], check=True)

+ 18 - 0
examples/_mu/wixit.py

@@ -0,0 +1,18 @@
+import os
+from subprocess import run, CalledProcessError
+import sys
+
+WIX_BIN = os.path.join(os.environ['WIX'], 'bin')
+
+def wix(cmd, *args):
+	cmd = os.path.join(WIX_BIN, cmd)
+	run([cmd] + list(args), check=True)
+	
+try:
+	print('Running candle (wxs to wixobj)')
+	wix('candle', 'files.wxs')
+	wix('candle', 'wrapper.wxs')
+	print('Running light (wixobj to msi)')
+	wix('light', 'files.wixobj', 'wrapper.wixobj', '-o', 'mu_editor.msi', '-b', 'build\\nsis')
+except CalledProcessError:
+	sys.exit(1)

+ 29 - 0
examples/_mu/wrapper.wxs

@@ -0,0 +1,29 @@
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+   <Product Id="*" UpgradeCode="4981284B-DCB8-4257-91CA-D79EDC94A9E8" 
+            Name="Mu Editor" Version="0.0.1" Manufacturer="Trylan Erruh" Language="1033">
+      <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/>
+      <Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
+ 
+      <Directory Id="TARGETDIR" Name="SourceDir">
+		<Directory Id="ProgramFilesFolder">
+            <Directory Id="INSTALLDIR" Name="Mu Editor">
+			</Directory>
+		</Directory>
+		<Directory Id="ProgramMenuFolder">
+		   <Component Id="ApplicationShortcuts" Guid="*">
+			  <Shortcut Id="ApplicationShortcut1" Name="Mu" Description="Run Python code" 
+						Target="[INSTALLDIR]Python\python.exe" Arguments="&quot;[INSTALLDIR]mu.launch.py&quot;"/>
+			  <!-- If this component doesn't have the registry entry below, Wix 
+			  refuses to autogenerate a GUID for it. -->
+			  <RegistryValue Root="HKCU" Key="Software\Trylan Erruh\Mu Editor" 
+						Name="installed" Type="integer" Value="1" KeyPath="yes"/>
+		   </Component>
+         </Directory>
+      </Directory>
+ 
+      <Feature Id="DefaultFeature" Level="1">
+         <ComponentGroupRef Id="ApplicationFiles"/>
+		 <ComponentRef Id="ApplicationShortcuts"/>
+      </Feature>
+   </Product>
+</Wix>