ソースを参照

Set Python installation directory depending on bitness

Installs Python to the 'Common Files' directory under 'Program Files' or
'Program Files (x86)' as appropriate.

Closes gh-26
Thomas Kluyver 11 年 前
コミット
ef4b3fde0f
2 ファイル変更11 行追加3 行削除
  1. 3 2
      nsist/__init__.py
  2. 8 1
      nsist/template.nsi

+ 3 - 2
nsist/__init__.py

@@ -97,7 +97,7 @@ class InstallerBuilder(object):
         self.installer_name = installer_name or self.make_installer_name()
         self.nsi_template = nsi_template
         self.nsi_file = pjoin(self.build_dir, 'installer.nsi')
-        self.py_qualifier = '.'.join(self.py_version.split('.')[:2])
+        self.py_major_version = self.py_qualifier = '.'.join(self.py_version.split('.')[:2])
         if self.py_bitness == 32:
             self.py_qualifier += '-32'
         
@@ -263,7 +263,8 @@ from {module} import {func}
         nsis_writer = NSISFileWriter(self.nsi_template, installerbuilder=self,
             definitions = {'PRODUCT_NAME': self.appname,
                            'PRODUCT_VERSION': self.version,
-                           'PY_VERSION': self.py_version,
+                           'PY_VERSION': self.py_version,  # e.g. 3.4.1
+                           'PY_MAJOR_VERSION': self.py_major_version,  #e.g. 3.4
                            'PY_QUALIFIER': self.py_qualifier,
                            'PRODUCT_ICON': os.path.basename(self.icon),
                            'INSTALLER_NAME': self.installer_name,

+ 8 - 1
nsist/template.nsi

@@ -29,9 +29,16 @@ Section -SETTINGS
   SetOverwrite ifnewer
 SectionEnd
 
+Var PyTargetDir
 Section "Python ${PY_VERSION}" sec_py
   File "python-${PY_VERSION}${ARCH_TAG}.msi"
-  ExecWait 'msiexec /i "$INSTDIR\python-${PY_VERSION}${ARCH_TAG}.msi" /qb ALLUSERS=1'
+  StrCmp "${ARCH_TAG}" ".amd64" 0 +4
+    StrCpy $PyTargetDir "$COMMONFILES64\Python\${PY_MAJOR_VERSION}"
+    DetailPrint "Installing Python ${PY_MAJOR_VERSION}, 64 bit"
+    Goto +3
+    StrCpy $PyTargetDir "$COMMONFILES32\Python\${PY_MAJOR_VERSION}"
+    DetailPrint "Installing Python ${PY_MAJOR_VERSION}, 32 bit"
+  ExecWait 'msiexec /i "$INSTDIR\python-${PY_VERSION}${ARCH_TAG}.msi" /qb ALLUSERS=1 TARGETDIR="$PyTargetDir"'
   Delete $INSTDIR\python-${PY_VERSION}.msi
 SectionEnd