Skip to content

Commit

Permalink
Merge pull request #36096 from twangboy/update_setup
Browse files Browse the repository at this point in the history
[WIP] Add additional required dll's for Windows
  • Loading branch information
Mike Place committed Sep 13, 2016
2 parents b0dd6ff + dc1988a commit 931486b
Showing 1 changed file with 52 additions and 11 deletions.
63 changes: 52 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ def run(self):
self.run_command('install-pycrypto-windows')
self.distribution.salt_installing_pycrypto_windows = None

# Install PyYAML
self.distribution.salt_installing_pyyaml_windows = True
self.run_command('install-pyyaml-windows')
self.distribution.salt_installing_pyyaml_windows = None

# Download the required DLLs
self.distribution.salt_download_windows_dlls = True
self.run_command('download-windows-dlls')
Expand Down Expand Up @@ -376,6 +381,37 @@ def run(self):
call_subprocess(call_arguments)


class InstallCompiledPyYaml(Command):

description = 'Install PyYAML on Windows'

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
if getattr(self.distribution, 'salt_installing_pyyaml_windows', None) is None:
print('This command is not meant to be called on it\'s own')
exit(1)
import platform
from pip.utils import call_subprocess
from pip.utils.logging import indent_log
platform_bits, _ = platform.architecture()
call_arguments = ['easy_install', '-Z']
if platform_bits == '64bit':
call_arguments.append(
'http://repo.saltstack.com/windows/dependencies/64/PyYAML-3.11.win-amd64-py2.7.exe'
)
else:
call_arguments.append(
'http://repo.saltstack.com/windows/dependencies/32/PyYAML-3.11.win-amd64-py2.7.exe'
)
with indent_log():
call_subprocess(call_arguments)


class DownloadWindowsDlls(Command):

description = 'Download required DLL\'s for windows'
Expand All @@ -393,14 +429,14 @@ def run(self):
import platform
from pip.utils.logging import indent_log
platform_bits, _ = platform.architecture()
url = 'https://repo.saltstack.com/windows/dependencies/{bits}/{fname}32.dll'
dest = os.path.join(os.path.dirname(sys.executable), '{fname}32.dll')
url = 'http://repo.saltstack.com/windows/dependencies/{bits}/{fname}.dll'
dest = os.path.join(os.path.dirname(sys.executable), '{fname}.dll')
with indent_log():
for fname in ('libeay', 'ssleay'):
for fname in ('libeay32', 'ssleay32', 'libsodium', 'msvcr120'):
furl = url.format(bits=platform_bits[:2], fname=fname)
fdest = dest.format(fname=fname)
if not os.path.exists(fdest):
log.info('Downloading {0}32.dll to {1} from {2}'.format(fname, fdest, furl))
log.info('Downloading {0}.dll to {1} from {2}'.format(fname, fdest, furl))
try:
import requests
from contextlib import closing
Expand All @@ -413,7 +449,7 @@ def run(self):
wfh.flush()
else:
log.error(
'Failed to download {0}32.dll to {1} from {2}'.format(
'Failed to download {0}.dll to {1} from {2}'.format(
fname, fdest, furl
)
)
Expand All @@ -423,14 +459,14 @@ def run(self):
if req.getcode() == 200:
with open(fdest, 'wb') as wfh:
while True:
for chunk in req.read(4096):
if not chunk:
break
wfh.write(chunk)
wfh.flush()
chunk = req.read(4096)
if not chunk:
break
wfh.write(chunk)
wfh.flush()
else:
log.error(
'Failed to download {0}32.dll to {1} from {2}'.format(
'Failed to download {0}.dll to {1} from {2}'.format(
fname, fdest, furl
)
)
Expand Down Expand Up @@ -752,6 +788,10 @@ def run(self):
self.distribution.salt_installing_pycrypto_windows = True
self.run_command('install-pycrypto-windows')
self.distribution.salt_installing_pycrypto_windows = None
# Install PyYAML
self.distribution.salt_installing_pyyaml_windows = True
self.run_command('install-pyyaml-windows')
self.distribution.salt_installing_pyyaml_windows = None
# Download the required DLLs
self.distribution.salt_download_windows_dlls = True
self.run_command('download-windows-dlls')
Expand Down Expand Up @@ -883,6 +923,7 @@ def __init__(self, attrs=None):
'install_lib': InstallLib})
if IS_WINDOWS_PLATFORM:
self.cmdclass.update({'install-pycrypto-windows': InstallPyCryptoWindowsWheel,
'install-pyyaml-windows': InstallCompiledPyYaml,
'download-windows-dlls': DownloadWindowsDlls})
if __saltstack_version__.info < (2015, 8): # pylint: disable=undefined-variable
self.cmdclass.update({'install-m2crypto-windows': InstallM2CryptoWindows})
Expand Down

0 comments on commit 931486b

Please sign in to comment.