44if vi < (3 , 8 ):
55 raise RuntimeError ('uvloop requires Python 3.8 or greater' )
66
7- # TODO: Remove Completely because Winloop Author is mergeing his project to uvloop.
8- # if sys.platform in ('win32', 'cygwin', 'cli'):
9- # raise RuntimeError('uvloop does not support Windows at the moment')
10-
117import os
128import os .path
139import pathlib
3026LIBUV_DIR = str (_ROOT / 'vendor' / 'libuv' )
3127LIBUV_BUILD_DIR = str (_ROOT / 'build' / 'libuv-{}' .format (MACHINE ))
3228
33- # NOTE: Mingw was added by another contributor in the winloop project.
34- MINGW = bool (os .environ .get ("MINGW_PREFIX" , "" ))
35-
36-
3729def _libuv_build_env ():
3830 env = os .environ .copy ()
3931
@@ -88,9 +80,7 @@ class uvloop_build_ext(build_ext):
8880
8981 def initialize_options (self ):
9082 super ().initialize_options ()
91- # Use mingw if prefix was given for it otherwise it
92- # will always be false.
93- self .use_system_libuv = MINGW
83+ self .use_system_libuv = False
9484 self .cython_always = False
9585 self .cython_annotate = None
9686 self .cython_directives = None
@@ -125,21 +115,17 @@ def finalize_options(self):
125115 import Cython
126116 except ImportError :
127117 raise RuntimeError (
128- "please install {} to compile uvloop from source" .format (
129- CYTHON_DEPENDENCY
130- )
131- )
118+ 'please install {} to compile uvloop from source' .format (
119+ CYTHON_DEPENDENCY ))
132120
133121 cython_dep = Requirement (CYTHON_DEPENDENCY )
134122 if not cython_dep .specifier .contains (Cython .__version__ ):
135123 raise RuntimeError (
136- " uvloop requires {}, got Cython=={}" .format (
124+ ' uvloop requires {}, got Cython=={}' .format (
137125 CYTHON_DEPENDENCY , Cython .__version__
138- )
139- )
126+ ))
140127
141128 from Cython .Build import cythonize
142-
143129
144130 directives = {}
145131 if self .cython_directives :
@@ -201,7 +187,7 @@ def build_libuv(self):
201187 cwd = LIBUV_BUILD_DIR , env = env , check = True )
202188
203189 def build_extensions (self ):
204- if sys .platform == "win32" and not MINGW :
190+ if sys .platform == "win32" :
205191 path = pathlib .Path ("vendor" , "libuv" , "src" )
206192 c_files = [p .as_posix () for p in path .iterdir () if p .suffix == ".c" ]
207193 c_files += [
@@ -249,41 +235,26 @@ def build_extensions(self):
249235 raise RuntimeError (
250236 'unable to read the version from uvloop/_version.py' )
251237
252- if sys .platform == "win32" :
253- from Cython .Build import cythonize
254- from Cython .Compiler .Main import default_options
255-
256- default_options ["compile_time_env" ] = dict (DEFAULT_FREELIST_SIZE = 250 )
257- ext = cythonize (
258- [
259- Extension (
260- "uvloop.loop" ,
261- sources = ["uvloop/loop.pyx" ],
262- include_dirs = []
263- if MINGW
264- else [
265- "vendor/libuv/src" ,
266- "vendor/libuv/src/win" ,
267- "vendor/libuv/include" ,
268- ],
269- # subset of libuv Windows libraries:
270- extra_link_args = [
271- (f"-l{ lib } " if MINGW else f"{ lib } .lib" )
272- for lib in (
273- "Shell32" ,
274- "Ws2_32" ,
275- "Advapi32" ,
276- "iphlpapi" ,
277- "Userenv" ,
278- "User32" ,
279- "Dbghelp" ,
280- "Ole32" ,
281- )
282- ],
283- define_macros = [("WIN32_LEAN_AND_MEAN" , 1 ), ("_WIN32_WINNT" , "0x0602" )],
284- ),
285- ]
286- )
238+ if sys .platform == 'win32' :
239+ ext = [
240+ Extension (
241+ 'uvloop.loop' ,
242+ sources = ['uvloop/loop.pyx' ],
243+ include_dirs = [
244+ 'vendor/libuv/src' ,
245+ 'vendor/libuv/src/win' ,
246+ 'vendor/libuv/include' ,
247+ ],
248+ libraries = [
249+ 'Shell32' , 'Ws2_32' , 'Advapi32' , 'iphlpapi' ,
250+ 'Userenv' , 'User32' , 'Dbghelp' , 'Ole32' ,
251+ ],
252+ define_macros = [
253+ ('WIN32_LEAN_AND_MEAN' , 1 ),
254+ ('_WIN32_WINNT' , '0x0602' ),
255+ ],
256+ ),
257+ ]
287258else :
288259 ext = [
289260 Extension (
@@ -297,14 +268,17 @@ def build_extensions(self):
297268
298269setup_requires = []
299270
300- if not (_ROOT / " uvloop" / " loop.c" ).exists () or " --cython-always" in sys .argv :
271+ if not (_ROOT / ' uvloop' / ' loop.c' ).exists () or ' --cython-always' in sys .argv :
301272 # No Cython output, require Cython to build.
302273 setup_requires .append (CYTHON_DEPENDENCY )
303-
274+
304275
305276setup (
306277 version = VERSION ,
307- cmdclass = {"sdist" : uvloop_sdist , "build_ext" : uvloop_build_ext },
278+ cmdclass = {
279+ 'sdist' : uvloop_sdist ,
280+ 'build_ext' : uvloop_build_ext
281+ },
308282 ext_modules = ext ,
309283 setup_requires = setup_requires ,
310284)
0 commit comments