Полагаю, что для сборки пакета под windows необходимо изменить файл setup.py, как минимум, следующим образом:
---
+++
@@ -11,10 +11,10 @@
class libuv_build_ext(build_ext):
def build_libuv(self):
- cflags = '-fPIC'
+ cflags = '-fPIC '
env = os.environ.copy()
- env['CFLAGS'] = ('-fPIC ' +
+ env['CFLAGS'] = (cflags +
env.get('CFLAGS', '-O2') +
' ' +
env.get('ARCHFLAGS', ''))
@@ -24,7 +24,10 @@
subprocess.run(['make', '-j4'], cwd=LIBUV_DIR, env=env)
def build_extensions(self):
- libuv_lib = os.path.join(LIBUV_DIR, '.libs', 'libuv.a')
+ if sys.platform == 'win32':
+ libuv_lib = os.path.join(LIBUV_DIR, 'Release', 'lib', 'libuv.lib')
+ else:
+ libuv_lib = os.path.join(LIBUV_DIR, '.libs', 'libuv.a')
if not os.path.exists(libuv_lib):
self.build_libuv()
if not os.path.exists(libuv_lib):
@@ -33,7 +36,15 @@
self.extensions[-1].extra_objects.extend([libuv_lib])
self.compiler.add_include_dir(os.path.join(LIBUV_DIR, 'include'))
- if sys.platform.startswith('linux'):
+ if sys.platform == 'win32':
+ self.extensions[0].define_macros.append(('WIN32', 1))
+ self.extensions[0].extra_link_args.extend(['/NODEFAULTLIB:libcmt',
+ '/LTCG'])
+ self.compiler.add_library('advapi32')
+ self.compiler.add_library('iphlpapi')
+ self.compiler.add_library('psapi')
+ self.compiler.add_library('ws2_32')
+ elif sys.platform.startswith('linux'):
self.compiler.add_library('rt')
elif sys.platform.startswith('freebsd'):
self.compiler.add_library('kvm')
@@ -45,11 +56,11 @@
name='uvloop',
version='0.0.1',
packages=['uvloop'],
- cmdclass = {'build_ext': libuv_build_ext},
+ cmdclass={'build_ext': libuv_build_ext},
ext_modules=[
Extension(
"uvloop.futures",
- sources = [
+ sources=[
"uvloop/futures.c",
],
extra_compile_args=['-O2']
@@ -57,7 +68,7 @@
Extension(
"uvloop.loop",
- sources = [
+ sources=[
"uvloop/loop.c",
]
),
Пакет все равно не собирается, компилятор ругается на 419 строку файла futures.c (error C2099)
Подскажите, как обойти ошибку.