소스 검색

Merge pull request #87 from takluyver/applocal-msvcrt

Applocal msvcrt
Thomas Kluyver 8 년 전
부모
커밋
eabbdca6de
91개의 변경된 파일77개의 추가작업 그리고 198개의 파일을 삭제
  1. 22 4
      doc/cfgfile.rst
  2. 10 0
      doc/releasenotes.rst
  3. 26 5
      nsist/__init__.py
  4. 1 0
      nsist/configreader.py
  5. BIN
      nsist/inetc.dll
  6. BIN
      nsist/msvcrt/x64/api-ms-win-core-console-l1-1-0.dll
  7. BIN
      nsist/msvcrt/x64/api-ms-win-core-datetime-l1-1-0.dll
  8. BIN
      nsist/msvcrt/x64/api-ms-win-core-debug-l1-1-0.dll
  9. BIN
      nsist/msvcrt/x64/api-ms-win-core-errorhandling-l1-1-0.dll
  10. BIN
      nsist/msvcrt/x64/api-ms-win-core-file-l1-1-0.dll
  11. BIN
      nsist/msvcrt/x64/api-ms-win-core-file-l1-2-0.dll
  12. BIN
      nsist/msvcrt/x64/api-ms-win-core-file-l2-1-0.dll
  13. BIN
      nsist/msvcrt/x64/api-ms-win-core-handle-l1-1-0.dll
  14. BIN
      nsist/msvcrt/x64/api-ms-win-core-heap-l1-1-0.dll
  15. BIN
      nsist/msvcrt/x64/api-ms-win-core-interlocked-l1-1-0.dll
  16. BIN
      nsist/msvcrt/x64/api-ms-win-core-libraryloader-l1-1-0.dll
  17. BIN
      nsist/msvcrt/x64/api-ms-win-core-localization-l1-2-0.dll
  18. BIN
      nsist/msvcrt/x64/api-ms-win-core-memory-l1-1-0.dll
  19. BIN
      nsist/msvcrt/x64/api-ms-win-core-namedpipe-l1-1-0.dll
  20. BIN
      nsist/msvcrt/x64/api-ms-win-core-processenvironment-l1-1-0.dll
  21. BIN
      nsist/msvcrt/x64/api-ms-win-core-processthreads-l1-1-0.dll
  22. BIN
      nsist/msvcrt/x64/api-ms-win-core-processthreads-l1-1-1.dll
  23. BIN
      nsist/msvcrt/x64/api-ms-win-core-profile-l1-1-0.dll
  24. BIN
      nsist/msvcrt/x64/api-ms-win-core-rtlsupport-l1-1-0.dll
  25. BIN
      nsist/msvcrt/x64/api-ms-win-core-string-l1-1-0.dll
  26. BIN
      nsist/msvcrt/x64/api-ms-win-core-synch-l1-1-0.dll
  27. BIN
      nsist/msvcrt/x64/api-ms-win-core-synch-l1-2-0.dll
  28. BIN
      nsist/msvcrt/x64/api-ms-win-core-sysinfo-l1-1-0.dll
  29. BIN
      nsist/msvcrt/x64/api-ms-win-core-timezone-l1-1-0.dll
  30. BIN
      nsist/msvcrt/x64/api-ms-win-core-util-l1-1-0.dll
  31. BIN
      nsist/msvcrt/x64/api-ms-win-crt-conio-l1-1-0.dll
  32. BIN
      nsist/msvcrt/x64/api-ms-win-crt-convert-l1-1-0.dll
  33. BIN
      nsist/msvcrt/x64/api-ms-win-crt-environment-l1-1-0.dll
  34. BIN
      nsist/msvcrt/x64/api-ms-win-crt-filesystem-l1-1-0.dll
  35. BIN
      nsist/msvcrt/x64/api-ms-win-crt-heap-l1-1-0.dll
  36. BIN
      nsist/msvcrt/x64/api-ms-win-crt-locale-l1-1-0.dll
  37. BIN
      nsist/msvcrt/x64/api-ms-win-crt-math-l1-1-0.dll
  38. BIN
      nsist/msvcrt/x64/api-ms-win-crt-multibyte-l1-1-0.dll
  39. BIN
      nsist/msvcrt/x64/api-ms-win-crt-private-l1-1-0.dll
  40. BIN
      nsist/msvcrt/x64/api-ms-win-crt-process-l1-1-0.dll
  41. BIN
      nsist/msvcrt/x64/api-ms-win-crt-runtime-l1-1-0.dll
  42. BIN
      nsist/msvcrt/x64/api-ms-win-crt-stdio-l1-1-0.dll
  43. BIN
      nsist/msvcrt/x64/api-ms-win-crt-string-l1-1-0.dll
  44. BIN
      nsist/msvcrt/x64/api-ms-win-crt-time-l1-1-0.dll
  45. BIN
      nsist/msvcrt/x64/api-ms-win-crt-utility-l1-1-0.dll
  46. BIN
      nsist/msvcrt/x64/ucrtbase.dll
  47. BIN
      nsist/msvcrt/x86/api-ms-win-core-console-l1-1-0.dll
  48. BIN
      nsist/msvcrt/x86/api-ms-win-core-datetime-l1-1-0.dll
  49. BIN
      nsist/msvcrt/x86/api-ms-win-core-debug-l1-1-0.dll
  50. BIN
      nsist/msvcrt/x86/api-ms-win-core-errorhandling-l1-1-0.dll
  51. BIN
      nsist/msvcrt/x86/api-ms-win-core-file-l1-1-0.dll
  52. BIN
      nsist/msvcrt/x86/api-ms-win-core-file-l1-2-0.dll
  53. BIN
      nsist/msvcrt/x86/api-ms-win-core-file-l2-1-0.dll
  54. BIN
      nsist/msvcrt/x86/api-ms-win-core-handle-l1-1-0.dll
  55. BIN
      nsist/msvcrt/x86/api-ms-win-core-heap-l1-1-0.dll
  56. BIN
      nsist/msvcrt/x86/api-ms-win-core-interlocked-l1-1-0.dll
  57. BIN
      nsist/msvcrt/x86/api-ms-win-core-libraryloader-l1-1-0.dll
  58. BIN
      nsist/msvcrt/x86/api-ms-win-core-localization-l1-2-0.dll
  59. BIN
      nsist/msvcrt/x86/api-ms-win-core-memory-l1-1-0.dll
  60. BIN
      nsist/msvcrt/x86/api-ms-win-core-namedpipe-l1-1-0.dll
  61. BIN
      nsist/msvcrt/x86/api-ms-win-core-processenvironment-l1-1-0.dll
  62. BIN
      nsist/msvcrt/x86/api-ms-win-core-processthreads-l1-1-0.dll
  63. BIN
      nsist/msvcrt/x86/api-ms-win-core-processthreads-l1-1-1.dll
  64. BIN
      nsist/msvcrt/x86/api-ms-win-core-profile-l1-1-0.dll
  65. BIN
      nsist/msvcrt/x86/api-ms-win-core-rtlsupport-l1-1-0.dll
  66. BIN
      nsist/msvcrt/x86/api-ms-win-core-string-l1-1-0.dll
  67. BIN
      nsist/msvcrt/x86/api-ms-win-core-synch-l1-1-0.dll
  68. BIN
      nsist/msvcrt/x86/api-ms-win-core-synch-l1-2-0.dll
  69. BIN
      nsist/msvcrt/x86/api-ms-win-core-sysinfo-l1-1-0.dll
  70. BIN
      nsist/msvcrt/x86/api-ms-win-core-timezone-l1-1-0.dll
  71. BIN
      nsist/msvcrt/x86/api-ms-win-core-util-l1-1-0.dll
  72. BIN
      nsist/msvcrt/x86/api-ms-win-crt-conio-l1-1-0.dll
  73. BIN
      nsist/msvcrt/x86/api-ms-win-crt-convert-l1-1-0.dll
  74. BIN
      nsist/msvcrt/x86/api-ms-win-crt-environment-l1-1-0.dll
  75. BIN
      nsist/msvcrt/x86/api-ms-win-crt-filesystem-l1-1-0.dll
  76. BIN
      nsist/msvcrt/x86/api-ms-win-crt-heap-l1-1-0.dll
  77. BIN
      nsist/msvcrt/x86/api-ms-win-crt-locale-l1-1-0.dll
  78. BIN
      nsist/msvcrt/x86/api-ms-win-crt-math-l1-1-0.dll
  79. BIN
      nsist/msvcrt/x86/api-ms-win-crt-multibyte-l1-1-0.dll
  80. BIN
      nsist/msvcrt/x86/api-ms-win-crt-private-l1-1-0.dll
  81. BIN
      nsist/msvcrt/x86/api-ms-win-crt-process-l1-1-0.dll
  82. BIN
      nsist/msvcrt/x86/api-ms-win-crt-runtime-l1-1-0.dll
  83. BIN
      nsist/msvcrt/x86/api-ms-win-crt-stdio-l1-1-0.dll
  84. BIN
      nsist/msvcrt/x86/api-ms-win-crt-string-l1-1-0.dll
  85. BIN
      nsist/msvcrt/x86/api-ms-win-crt-time-l1-1-0.dll
  86. BIN
      nsist/msvcrt/x86/api-ms-win-crt-utility-l1-1-0.dll
  87. BIN
      nsist/msvcrt/x86/ucrtbase.dll
  88. BIN
      nsist/msvcrt/x86/x86.zip
  89. 6 1
      nsist/pyapp.nsi
  90. 12 69
      nsist/pyapp_msvcrt.nsi
  91. 0 119
      nsist/windowsversion.nsh

+ 22 - 4
doc/cfgfile.rst

@@ -152,13 +152,32 @@ Python section
   - ``bundled`` includes an embeddable Python build, which will be installed as
     part of your application. This is available for Python 3.5 and above.
 
+.. describe:: include_msvcrt (optional)
+
+  This option is only relevant with ``format = bundled``. The default is ``true``,
+  which will include an app-local copy of the Microsoft Visual C++ Runtime,
+  required for Python to run. The installer will only install this if it doesn't
+  detect a system installation of the runtime.
+
+  Setting this to ``false`` will not include the C++ Runtime. Your application may
+  not run for all users until they install it manually (`download from Microsoft
+  <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`__). You may
+  prefer to do this for security reasons: the separately installed runtime will
+  get updates through Windows Update, but app-local copies will not.
+
+  Users on Windows 10 should already have the runtime installed systemwide, so
+  this does won't affect them. Users on Windows Vista, 7, 8 or 8.1 *may* already
+  have it, depending on what else is installed.
+
+  .. versionadded:: 1.9
+
 .. _python_bundled:
 
 Bundled Python
 ~~~~~~~~~~~~~~
 
 .. versionadded:: 1.6
-   Experimental support for bundling Python into the application.
+   Support for bundling Python into the application.
 
 Using ``format = bundled``, an embeddable Python build will be downloaded at
 build time and packaged along with the application. When the installer runs, it
@@ -172,9 +191,8 @@ limitations:
 - This option is only available for Python 3.5 and above. These versions of
   Python have dropped support for Windows XP, so your application will only work
   on Windows Vista and newer.
-- Installing in Windows Vista to 8.1 (inclusive) may need an internet connection
-  to download the necessary `Visual C++ runtime
-  <http://www.microsoft.com/en-us/download/details.aspx?id=48145>`__. This isn't
+- Installing in Windows Vista to 8.1 (inclusive) may install an app-local copy
+  of the Visual C++ runtime (see above). This isn't
   needed on Windows 10, which includes the necessary files.
 - The embeddable Python builds don't include ``tkinter``, to save space.
   Applications with a tkinter GUI can't easily use bundled Python. Workarounds

+ 10 - 0
doc/releasenotes.rst

@@ -1,6 +1,16 @@
 Release notes
 =============
 
+Version 1.9
+-----------
+
+* The C Runtime needed for bundled Python is now installed 'app-local', rather
+  than downloading and installing Windows Update packages at install time. This
+  is considerably simpler, but the app-local runtime will not be updated by
+  Windows Update. A new ``include_msvcrt`` config option allows the developer to
+  exclude the app-local runtime - their applications will then depend on the
+  runtime being installed systemwide.
+
 Version 1.8
 -----------
 

+ 26 - 5
nsist/__init__.py

@@ -84,6 +84,8 @@ class InstallerBuilder(object):
     :param str py_version: Full version of Python to bundle
     :param int py_bitness: Bitness of bundled Python (32 or 64)
     :param str py_format: 'installer' or 'bundled'
+    :param bool inc_msvcrt: True to include the Microsoft C runtime with 'bundled'
+            Python. Ignored when py_format='installer'.
     :param str build_dir: Directory to run the build in
     :param str installer_name: Filename of the installer to produce
     :param str nsi_template: Path to a template NSI file to use
@@ -91,7 +93,7 @@ class InstallerBuilder(object):
     def __init__(self, appname, version, shortcuts, icon=DEFAULT_ICON,
                 packages=None, extra_files=None, py_version=DEFAULT_PY_VERSION,
                 py_bitness=DEFAULT_BITNESS, py_format='installer',
-                build_dir=DEFAULT_BUILD_DIR,
+                inc_msvcrt=True, build_dir=DEFAULT_BUILD_DIR,
                 installer_name=None, nsi_template=None,
                 exclude=None, pypi_wheel_reqs=None, commands=None):
         self.appname = appname
@@ -123,6 +125,7 @@ class InstallerBuilder(object):
         else:
             if py_format != 'installer':
                 raise InputError('py_format', py_format, "installer (for Python < 3.5)")
+        self.inc_msvcrt = inc_msvcrt
 
         # Build details
         self.build_dir = build_dir
@@ -130,7 +133,10 @@ class InstallerBuilder(object):
         self.nsi_template = nsi_template
         if self.nsi_template is None:
             if self.py_format == 'bundled':
-                self.nsi_template = 'pyapp_msvcrt.nsi'
+                if self.inc_msvcrt:
+                    self.nsi_template = 'pyapp_msvcrt.nsi'
+                else:
+                    self.nsi_template = 'pyapp.nsi'
             elif self.py_version_tuple < (3, 3):
                 self.nsi_template = 'pyapp_w_pylauncher.nsi'
             else:
@@ -141,6 +147,7 @@ class InstallerBuilder(object):
         # To be filled later
         self.install_files = []
         self.install_dirs = []
+        self.msvcrt_files = []
     
     _py_version_pattern = re.compile(r'\d\.\d+\.\d+$')
 
@@ -212,6 +219,20 @@ class InstallerBuilder(object):
 
         self.install_dirs.append(('Python', '$INSTDIR'))
 
+    def prepare_msvcrt(self):
+        arch = 'x64' if self.py_bitness == 64 else 'x86'
+        src = pjoin(_PKGDIR, 'msvcrt', arch)
+        dst = pjoin(self.build_dir, 'msvcrt')
+        self.msvcrt_files = sorted(os.listdir(src))
+
+        try:
+            shutil.rmtree(dst)
+        except OSError as e:
+            if e.errno != errno.ENOENT:
+                raise
+
+        shutil.copytree(src, dst)
+
     def fetch_pylauncher(self):
         """Fetch the MSI for PyLauncher (required for Python2.x).
     
@@ -416,9 +437,6 @@ if __name__ == '__main__':
         self.install_files.sort(key=operator.itemgetter(1))
         nsis_writer.write(self.nsi_file)
 
-        if self.py_format == 'bundled':
-            shutil.copy2(pjoin(_PKGDIR, 'windowsversion.nsh'), self.build_dir)
-
     def run_nsis(self):
         """Runs makensis using the specified .nsi file
         
@@ -448,6 +466,8 @@ if __name__ == '__main__':
 
         if self.py_format == 'bundled':
             self.fetch_python_embeddable()
+            if self.inc_msvcrt:
+                self.prepare_msvcrt()
         else:
             self.fetch_python()
             if self.py_version < '3.3':
@@ -517,6 +537,7 @@ def main(argv=None):
             py_version = cfg.get('Python', 'version', fallback=DEFAULT_PY_VERSION),
             py_bitness = cfg.getint('Python', 'bitness', fallback=DEFAULT_BITNESS),
             py_format = cfg.get('Python', 'format', fallback='installer'),
+            inc_msvcrt = cfg.getboolean('Python', 'include_msvcrt', fallback=True),
             build_dir = cfg.get('Build', 'directory', fallback=DEFAULT_BUILD_DIR),
             installer_name = cfg.get('Build', 'installer_name', fallback=None),
             nsi_template = cfg.get('Build', 'nsi_template', fallback=None),

+ 1 - 0
nsist/configreader.py

@@ -77,6 +77,7 @@ CONFIG_VALIDATORS = {
         ('version', False),
         ('bitness', False),
         ('format', False),
+        ('include_msvcrt', False),
     ]),
     'Shortcut': SectionValidator([
         ('entry_point', False),

BIN
nsist/inetc.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-console-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-datetime-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-debug-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-errorhandling-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-file-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-file-l1-2-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-file-l2-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-handle-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-heap-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-interlocked-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-libraryloader-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-localization-l1-2-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-memory-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-namedpipe-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-processenvironment-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-processthreads-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-processthreads-l1-1-1.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-profile-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-rtlsupport-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-string-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-synch-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-synch-l1-2-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-sysinfo-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-timezone-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-core-util-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-conio-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-convert-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-environment-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-filesystem-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-heap-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-locale-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-math-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-multibyte-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-private-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-process-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-runtime-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-stdio-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-string-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-time-l1-1-0.dll


BIN
nsist/msvcrt/x64/api-ms-win-crt-utility-l1-1-0.dll


BIN
nsist/msvcrt/x64/ucrtbase.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-console-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-datetime-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-debug-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-errorhandling-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-file-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-file-l1-2-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-file-l2-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-handle-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-heap-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-interlocked-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-libraryloader-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-localization-l1-2-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-memory-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-namedpipe-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-processenvironment-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-processthreads-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-processthreads-l1-1-1.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-profile-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-rtlsupport-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-string-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-synch-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-synch-l1-2-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-sysinfo-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-timezone-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-core-util-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-conio-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-convert-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-environment-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-filesystem-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-heap-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-locale-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-math-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-multibyte-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-private-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-process-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-runtime-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-stdio-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-string-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-time-l1-1-0.dll


BIN
nsist/msvcrt/x86/api-ms-win-crt-utility-l1-1-0.dll


BIN
nsist/msvcrt/x86/ucrtbase.dll


BIN
nsist/msvcrt/x86/x86.zip


+ 6 - 1
nsist/pyapp.nsi

@@ -46,7 +46,8 @@ Section "!${PRODUCT_NAME}" sec_app
   SetOutPath "$INSTDIR\pkgs"
   File /r "pkgs\*.*"
   SetOutPath "$INSTDIR"
-  
+
+  [% block install_files %]
   ; Install files
   [% for destination, group in grouped_files %]
     SetOutPath "[[destination]]"
@@ -60,6 +61,7 @@ Section "!${PRODUCT_NAME}" sec_app
     SetOutPath "[[ pjoin(destination, dir) ]]"
     File /r "[[dir]]\*.*"
   [% endfor %]
+  [% endblock install_files %]
   
   [% block install_shortcuts %]
   ; Install shortcuts
@@ -127,6 +129,7 @@ Section "Uninstall"
   [% endif %]
   [% endblock uninstall_commands %]
 
+  [% block uninstall_files %]
   ; Uninstall files
   [% for file, destination in ib.install_files %]
     Delete "[[pjoin(destination, file)]]"
@@ -135,6 +138,8 @@ Section "Uninstall"
   [% for dir, destination in ib.install_dirs %]
     RMDir /r "[[pjoin(destination, dir)]]"
   [% endfor %]
+  [% endblock uninstall_files %]
+
   [% block uninstall_shortcuts %]
   ; Uninstall shortcuts
   [% if single_shortcut %]

+ 12 - 69
nsist/pyapp_msvcrt.nsi

@@ -1,71 +1,14 @@
 [% extends "pyapp.nsi" %]
 
-[% block sections %]
-!addplugindir [[ pynsist_pkg_dir ]]
-!include windowsversion.nsh
-!include x64.nsh
-
-Section "-msvcrt"
-  ${GetWindowsVersion} $R0
-
-  StrCpy $0 "--"
-
-  ${If} ${RunningX64}
-    ${If} $R0 == "8.1"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x64/Windows8.1-KB2999226-x64.msu"
-    ${ElseIf} $R0 == "8"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x64/Windows8-RT-KB2999226-x64.msu"
-    ${ElseIf} $R0 == "7"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x64/Windows6.1-KB2999226-x64.msu"
-    ${ElseIf} $R0 == "Vista"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x64/Windows6.0-KB2999226-x64.msu"
-    ${EndIf}
-  ${Else}
-    ${If} $R0 == "8.1"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x86/Windows8.1-KB2999226-x86.msu"
-    ${ElseIf} $R0 == "8"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x86/Windows8-RT-KB2999226-x86.msu"
-    ${ElseIf} $R0 == "7"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x86/Windows6.1-KB2999226-x86.msu"
-    ${ElseIf} $R0 == "Vista"
-      StrCpy $0 "https://cdn.rawgit.com/takluyver/pynsist/msvcrt-tag1/x86/Windows6.0-KB2999226-x86.msu"
-    ${EndIf}
-  ${EndIf}
-
-  IfFileExists "$SYSDIR\ucrtbase.dll" skip_msvcrt
-  StrCmp $0 "--" skip_msvcrt
-
-  DetailPrint "Need to install MSVCRT 2015. This may take a few minutes."
-  DetailPrint "Downloading $0"
-  inetc::get /RESUME "" "$0" "$INSTDIR\msvcrt.msu"
-  Pop $2
-  DetailPrint "Download finished ($2)"
-  ${If} $2 == "OK"
-    DetailPrint "Running wusa to install update package"
-    ExecWait 'wusa "$INSTDIR\msvcrt.msu" /quiet /norestart' $1
-    Delete "$INSTDIR\msvcrt.msu"
-  ${Else}
-    MessageBox MB_OK "Failed to download important update! \
-            ${PRODUCT_NAME} will not run until you install the Visual C++ \
-            redistributable for Visual Studio 2015.\
-            $\n$\nhttp://www.microsoft.com/en-us/download/details.aspx?id=48145"
-  ${EndIf}
-
-  # This WUSA exit code means a reboot is needed.
-  ${If} $1 = 0x00240005
-    SetRebootFlag true
-  ${Else}
-    IntOp $0 $1 & 0x80000000
-    ${If} $0 <> 0
-      MessageBox MB_OK "Failed to install important update! \
-            ${PRODUCT_NAME} will not run until you install the Visual C++ \
-            redistributable for Visual Studio 2015.\
-            $\n$\nhttp://www.microsoft.com/en-us/download/details.aspx?id=48145"
-    ${EndIf}
-  ${EndIf}
-
-  skip_msvcrt:
-SectionEnd
-
-[[ super() ]]
-[% endblock sections %]
+[% block install_files %]
+    [[ super() ]]
+
+    ; Install MSVCRT if it's not already on the system
+    IfFileExists "$SYSDIR\ucrtbase.dll" skip_msvcrt
+    SetOutPath $INSTDIR\Python
+    [% for file in ib.msvcrt_files %]
+    File msvcrt\[[file]]
+    [% endfor %]
+    skip_msvcrt:
+
+[% endblock %]

+ 0 - 119
nsist/windowsversion.nsh

@@ -1,119 +0,0 @@
-; GetWindowsVersion 4.1 (2014-10-01)
-;
-; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
-; Update by Joost Verburg
-; Update (Macro, Define, Windows 7 detection) - John T. Haller of PortableApps.com - 2008-01-07
-; Update (Windows 8 detection) - Marek Mizanin (Zanir) - 2013-02-07
-; Update (Windows 8.1 detection) - John T. Haller of PortableApps.com - 2014-04-04
-; Update (Windows 10 TP detection) - John T. Haller of PortableApps.com - 2014-10-01
-; Got from http://nsis.sourceforge.net/Get_Windows_version
-;
-; Usage: ${GetWindowsVersion} $R0
-;
-; $R0 contains: 95, 98, ME, NT x.x, 2000, XP, 2003, Vista, 7, 8, 8.1, 10.0 or '' (for unknown)
-
-Function GetWindowsVersion
-
-  Push $R0
-  Push $R1
-
-  ClearErrors
-
-  ReadRegStr $R0 HKLM \
-  "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
-
-  IfErrors 0 lbl_winnt
-
-  ; we are not NT
-  ReadRegStr $R0 HKLM \
-  "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
-
-  StrCpy $R1 $R0 1
-  StrCmp $R1 '4' 0 lbl_error
-
-  StrCpy $R1 $R0 3
-
-  StrCmp $R1 '4.0' lbl_win32_95
-  StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
-
-  lbl_win32_95:
-    StrCpy $R0 '95'
-  Goto lbl_done
-
-  lbl_win32_98:
-    StrCpy $R0 '98'
-  Goto lbl_done
-
-  lbl_win32_ME:
-    StrCpy $R0 'ME'
-  Goto lbl_done
-
-  lbl_winnt:
-
-  StrCpy $R1 $R0 1
-
-  StrCmp $R1 '3' lbl_winnt_x
-  StrCmp $R1 '4' lbl_winnt_x
-
-  StrCpy $R1 $R0 3
-
-  StrCmp $R1 '5.0' lbl_winnt_2000
-  StrCmp $R1 '5.1' lbl_winnt_XP
-  StrCmp $R1 '5.2' lbl_winnt_2003
-  StrCmp $R1 '6.0' lbl_winnt_vista
-  StrCmp $R1 '6.1' lbl_winnt_7
-  StrCmp $R1 '6.2' lbl_winnt_8
-  StrCmp $R1 '6.3' lbl_winnt_81
-  StrCmp $R1 '6.4' lbl_winnt_10 lbl_error
-
-  lbl_winnt_x:
-    StrCpy $R0 "NT $R0" 6
-  Goto lbl_done
-
-  lbl_winnt_2000:
-    Strcpy $R0 '2000'
-  Goto lbl_done
-
-  lbl_winnt_XP:
-    Strcpy $R0 'XP'
-  Goto lbl_done
-
-  lbl_winnt_2003:
-    Strcpy $R0 '2003'
-  Goto lbl_done
-
-  lbl_winnt_vista:
-    Strcpy $R0 'Vista'
-  Goto lbl_done
-
-  lbl_winnt_7:
-    Strcpy $R0 '7'
-  Goto lbl_done
-
-  lbl_winnt_8:
-    Strcpy $R0 '8'
-  Goto lbl_done
-
-  lbl_winnt_81:
-    Strcpy $R0 '8.1'
-  Goto lbl_done
-
-  lbl_winnt_10:
-    Strcpy $R0 '10.0'
-  Goto lbl_done
-
-  lbl_error:
-    Strcpy $R0 ''
-  lbl_done:
-
-  Pop $R1
-  Exch $R0
-
-FunctionEnd
-
-!macro GetWindowsVersion OUTPUT_VALUE
-	Call GetWindowsVersion
-	Pop `${OUTPUT_VALUE}`
-!macroend
-
-!define GetWindowsVersion '!insertmacro "GetWindowsVersion"'