Răsfoiți Sursa

Various fixes for new templating

Closes gh-29
Thomas Kluyver 10 ani în urmă
părinte
comite
2aa0681463
4 a modificat fișierele cu 9 adăugiri și 19 ștergeri
  1. 3 14
      nsist/__init__.py
  2. 3 3
      nsist/nsiswriter.py
  3. 2 2
      nsist/pyapp_w_pylauncher.nsi
  4. 1 0
      setup.py

+ 3 - 14
nsist/__init__.py

@@ -34,7 +34,7 @@ logger = logging.getLogger(__name__)
 _PKGDIR = os.path.abspath(os.path.dirname(__file__))
 DEFAULT_PY_VERSION = '2.7.9' if PY2 else '3.4.2'
 DEFAULT_BUILD_DIR = pjoin('build', 'nsis')
-DEFAULT_NSI_TEMPLATE = 'pyapp_w_launcher.nsi' if PY2 else 'pyapp.nsi'
+DEFAULT_NSI_TEMPLATE = 'pyapp_w_pylauncher.nsi' if PY2 else 'pyapp.nsi'
 DEFAULT_ICON = pjoin(_PKGDIR, 'glossyorb.ico')
 if os.name == 'nt' and sys.maxsize == (2**63)-1:
     DEFAULT_BITNESS = 64
@@ -300,23 +300,12 @@ if __name__ == '__main__':
         Most of the details of this are in the template and the
         :class:`nsist.nsiswriter.NSISFileWriter` class.
         """
-        nsis_writer = NSISFileWriter(self.nsi_template, installerbuilder=self,
-            definitions = {'PRODUCT_NAME': self.appname,
-                           'PRODUCT_VERSION': self.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,
-                           'BITNESS' : str(self.py_bitness),
-                           'PRODUCT_ICON': os.path.basename(self.icon),
-                           'INSTALLER_NAME': self.installer_name,
-                           'ARCH_TAG': '.amd64' if (self.py_bitness==64) else '',
-                          },
-            )
+        nsis_writer = NSISFileWriter(self.nsi_template, installerbuilder=self)
 
         logger.info('Writing NSI file to %s', self.nsi_file)
         # Sort by destination directory, so we can group them effectively
         self.install_files.sort(key=operator.itemgetter(1))
-        nsis_writer.write(self.nsi_file)    
+        nsis_writer.write(self.nsi_file)
 
     def run_nsis(self):
         """Runs makensis using the specified .nsi file

+ 3 - 3
nsist/nsiswriter.py

@@ -37,10 +37,10 @@ class NSISFileWriter(object):
         )
         self.template = env.get_template(template_file)
         self.installerbuilder = installerbuilder
-        self.namespace = ns = {
+        self.namespace = {
             'ib': installerbuilder,
-            'grouped_files': itertools.groupby(
-                   self.installerbuilder.install_files, operator.itemgetter(1)),
+            'grouped_files': list(itertools.groupby(self.installerbuilder.install_files,
+                    operator.itemgetter(1))),
             'icon': os.path.basename(installerbuilder.icon),
             'arch_tag': '.amd64' if (installerbuilder.py_bitness==64) else '',
             'pjoin': ntpath.join,

+ 2 - 2
nsist/pyapp_w_pylauncher.nsi

@@ -1,11 +1,11 @@
-[% extends pyapp.nsi %]
+[% extends "pyapp.nsi" %]
 [# For Python 2, add the py/pyw Windows launcher. Python 3 includes it already. #]
 
 [% block sections %]
 [[ super() ]]
 
 Section "PyLauncher" sec_pylauncher
-    File "launchwin${ARCH_TAG}.msi",
+    File "launchwin${ARCH_TAG}.msi"
     ExecWait 'msiexec /i "$INSTDIR\launchwin${ARCH_TAG}.msi" /qb ALLUSERS=1'
     Delete "$INSTDIR\launchwin${ARCH_TAG}.msi"
 SectionEnd

+ 1 - 0
setup.py

@@ -56,6 +56,7 @@ setup(name='pynsist',
       url='https://github.com/takluyver/pynsist',
       packages=['nsist'],
       package_data={'nsist': ['pyapp.nsi',
+                              'pyapp_w_pylauncher.nsi',
                               'glossyorb.ico',
                              ]
                     },