win: Build libuv properly on Windows

This commit is contained in:
Yury Selivanov 2016-11-22 14:28:14 -05:00
parent fe0787f987
commit 2e937cfdb8
1 changed files with 20 additions and 2 deletions

View File

@ -214,7 +214,24 @@ class uvloop_build_ext(build_ext):
def build_libuv(self): def build_libuv(self):
env = _libuv_build_env() env = _libuv_build_env()
if sys.platform != 'win32':
# Make sure configure and friends are present in case
# we are building from a git checkout.
_libuv_autogen(env)
# Copy the libuv tree to build/ so that its build
# products don't pollute sdist accidentally.
if os.path.exists(LIBUV_BUILD_DIR):
shutil.rmtree(LIBUV_BUILD_DIR)
shutil.copytree(LIBUV_DIR, LIBUV_BUILD_DIR)
if sys.platform == 'win32': if sys.platform == 'win32':
env.pop('VS120COMNTOOLS', None)
env.pop('VS110COMNTOOLS', None)
env.pop('VS100COMNTOOLS', None)
env.pop('VS90COMNTOOLS', None)
env['GYP_MSVS_VERSION'] = '2015'
pypath = os.path.expandvars(os.path.join( pypath = os.path.expandvars(os.path.join(
'%SYSTEMDRIVE%', 'Python27', 'python.exe')) '%SYSTEMDRIVE%', 'Python27', 'python.exe'))
if not os.path.exists(pypath): if not os.path.exists(pypath):
@ -296,8 +313,6 @@ class uvloop_build_ext(build_ext):
elif sys.platform.startswith('sunos'): elif sys.platform.startswith('sunos'):
self.compiler.add_library('kstat') self.compiler.add_library('kstat')
self.compiler.add_library('pthread')
elif sys.platform.startswith('win'): elif sys.platform.startswith('win'):
self.compiler.add_library('advapi32') self.compiler.add_library('advapi32')
self.compiler.add_library('iphlpapi') self.compiler.add_library('iphlpapi')
@ -307,6 +322,9 @@ class uvloop_build_ext(build_ext):
self.compiler.add_library('userenv') self.compiler.add_library('userenv')
self.compiler.add_library('ws2_32') self.compiler.add_library('ws2_32')
if not sys.platform.startswith('win'):
self.compiler.add_library('pthread')
super().build_extensions() super().build_extensions()