# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 2019-03-03 23:53:27
# Node ID 7a1433e904829f3aa7ef6d6c57ba5425ebe83f0c
# Parent  d7dc4ac1ff84ee4f87d1d38e9d170056d53678e5

inno: stop shipping pywin32

Ancient versions of Mercurial relied on pywin32 and I suspect
that's why we have this dependency.

We also ship the "keyring" package, which has a dependency
on "pywin32-ctypes" (providing the "win32ctypes" package).
This is a stripped down version of pywin32 that doesn't have
as many dependencies.

Since we don't have a dependency on pywin32 and since pywin32
is a bit annoying to package, let's get rid of it.

With this change, py2exe no longers picks up DLL dependencies
on various UCRT DLLs (because we no longer have a .pyd file
beloning to pywin32 which was pulling them in). So, we were
able to remove code in support of the UCRT DLLs.

.. bc::

   The Windows Inno installers no longer ship the pywin32 package.

   This package was being bundled for historical reasons. Mercurial
   stopped using pywin32 several years ago and the disappearance
   of this package should not have any meaningful impact.

Differential Revision: https://phab.mercurial-scm.org/D6067

diff --git a/contrib/packaging/inno/build.py b/contrib/packaging/inno/build.py
--- a/contrib/packaging/inno/build.py
+++ b/contrib/packaging/inno/build.py
@@ -124,20 +124,6 @@ def build(source_dir: pathlib.Path, buil
     if py_version != 2:
         raise Exception('Only Python 2 is currently supported')
 
-    # Some extensions may require DLLs from the Universal C Runtime (UCRT).
-    # These are typically not in PATH and py2exe will have trouble finding
-    # them. We find the Windows 10 SDK and the UCRT files within.
-    sdk_path = (pathlib.Path(os.environ['ProgramFiles(x86)']) /
-                'Windows Kits' / '10' / 'Redist' / 'ucrt' / 'DLLs')
-
-    if vc_x64:
-        sdk_path = sdk_path / 'x64'
-    else:
-        sdk_path = sdk_path / 'x86'
-
-    if not sdk_path.is_dir():
-        raise Exception('UCRT files could not be found at %s' % sdk_path)
-
     build_dir.mkdir(exist_ok=True)
 
     gettext_pkg = download_entry(DOWNLOADS['gettext'], build_dir)
@@ -196,11 +182,6 @@ def build(source_dir: pathlib.Path, buil
                            env=env,
                            check=True)
 
-        if str(sdk_path) not in os.environ['PATH'].split(os.pathsep):
-            print('adding %s to PATH' % sdk_path)
-            env['PATH'] = '%s%s%s' % (
-                os.environ['PATH'], os.pathsep, str(sdk_path))
-
         # Register location of msgfmt and other binaries.
         env['PATH'] = '%s%s%s' % (
             env['PATH'], os.pathsep, str(gettext_root / 'bin'))
diff --git a/contrib/packaging/inno/readme.rst b/contrib/packaging/inno/readme.rst
--- a/contrib/packaging/inno/readme.rst
+++ b/contrib/packaging/inno/readme.rst
@@ -8,9 +8,6 @@ The following system dependencies must b
 * Python 2.7 (download from https://www.python.org/downloads/)
 * Microsoft Visual C++ Compiler for Python 2.7
   (https://www.microsoft.com/en-us/download/details.aspx?id=44266)
-* Windows 10 SDK (download from
-  https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
-  or install via a modern version of Visual Studio)
 * Inno Setup (http://jrsoftware.org/isdl.php) version 5.4 or newer.
   Be sure to install the optional Inno Setup Preprocessor feature,
   which is required.
diff --git a/contrib/packaging/inno/requirements.txt b/contrib/packaging/inno/requirements.txt
--- a/contrib/packaging/inno/requirements.txt
+++ b/contrib/packaging/inno/requirements.txt
@@ -32,15 +32,6 @@ pywin32-ctypes==0.2.0 \
     --hash=sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942 \
     --hash=sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98 \
     # via keyring
-pywin32==224 \
-    --hash=sha256:22e218832a54ed206452c8f3ca9eff07ef327f8e597569a4c2828be5eaa09a77 \
-    --hash=sha256:32b37abafbfeddb0fe718008d6aada5a71efa2874f068bee1f9e703983dcc49a \
-    --hash=sha256:35451edb44162d2f603b5b18bd427bc88fcbc74849eaa7a7e7cfe0f507e5c0c8 \
-    --hash=sha256:4eda2e1e50faa706ff8226195b84fbcbd542b08c842a9b15e303589f85bfb41c \
-    --hash=sha256:5f265d72588806e134c8e1ede8561739071626ea4cc25c12d526aa7b82416ae5 \
-    --hash=sha256:6852ceac5fdd7a146b570655c37d9eacd520ed1eaeec051ff41c6fc94243d8bf \
-    --hash=sha256:6dbc4219fe45ece6a0cc6baafe0105604fdee551b5e876dc475d3955b77190ec \
-    --hash=sha256:9bd07746ce7f2198021a9fa187fa80df7b221ec5e4c234ab6f00ea355a3baf99
 urllib3==1.24.1 \
     --hash=sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39 \
     --hash=sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22 \
diff --git a/contrib/packaging/inno/requirements.txt.in b/contrib/packaging/inno/requirements.txt.in
--- a/contrib/packaging/inno/requirements.txt.in
+++ b/contrib/packaging/inno/requirements.txt.in
@@ -2,4 +2,3 @@ docutils
 dulwich
 keyring
 pygments
-pywin32
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1286,9 +1286,9 @@ if py2exeloaded:
         pass
 
     try:
-        import pywintypes
-        pywintypes.TRUE
-        py2exepackages.append('pywintypes')
+        import win32ctypes
+        win32ctypes.__version__
+        py2exepackages.append('win32ctypes')
     except ImportError:
         pass
 
@@ -1372,14 +1372,6 @@ setup(name='mercurial',
       options={
           'py2exe': {
               'packages': py2exepackages,
-              'dll_excludes': [
-                  'api-ms-win-core-apiquery-l1-1-0.dll',
-                  'api-ms-win-core-delayload-l1-1-0.dll',
-                  'api-ms-win-core-delayload-l1-1-1.dll',
-                  'api-ms-win-core-heap-l2-1-0.dll',
-                  'api-ms-win-core-libraryloader-l1-2-0.dll',
-                  'api-ms-win-core-registry-l1-1-0.dll',
-              ]
           },
           'bdist_mpkg': {
               'zipdist': False,