Make the windows builder more bit-aware

This commit is contained in:
Tomas Groth 2019-03-05 20:55:59 +01:00
parent b049edfb48
commit f95a43be24
1 changed files with 7 additions and 1 deletions

View File

@ -110,6 +110,7 @@ Portable App Builds
import os
import glob
import sys
from distutils import dir_util
from shutil import copy, move, rmtree
@ -267,6 +268,8 @@ class WindowsBuilder(Builder):
super().setup_system_paths()
self.python_root = os.path.dirname(self.python)
self.site_packages = os.path.join(self.python_root, 'Lib', 'site-packages')
# Default program_files to 'Program Files (x86)' - the folder for 32-bit programs on 64-bit systems, if that
# does not exists the host system is 32-bit so fallback to 'Program Files'.
self.program_files = os.getenv('PROGRAMFILES(x86)')
if not self.program_files:
self.program_files = os.getenv('PROGRAMFILES')
@ -331,8 +334,11 @@ class WindowsBuilder(Builder):
Return a list of any extra parameters we wish to use
"""
parameters = []
# Detect python instance bit size
arch = 'x86' if sys.maxsize == 0x7fffffff else 'x64'
dll_path = '{pf}\\Windows Kits\\10\\Redist\\ucrt\\DLLs\\{arch}\\*.dll'.format(pf=self.program_files, arch=arch)
# Finds the UCRT DDLs available from the Windows 10 SDK
for binary in glob.glob('C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\ucrt\\DLLs\\x64\\*.dll'):
for binary in glob.glob(dll_path):
parameters.append('--add-binary')
parameters.append(binary + ";.")
return parameters