|
4 | 4 | import shutil |
5 | 5 | import subprocess |
6 | 6 | import sys |
7 | | -import unittest |
8 | 7 |
|
9 | 8 |
|
10 | 9 | if sys.platform in ('win32', 'cygwin', 'cli'): |
|
29 | 28 | LIBUV_BUILD_DIR = os.path.join(os.path.dirname(__file__), 'build', 'libuv') |
30 | 29 |
|
31 | 30 |
|
32 | | -def discover_tests(): |
33 | | - test_loader = unittest.TestLoader() |
34 | | - test_suite = test_loader.discover('tests', pattern='test_*.py') |
35 | | - return test_suite |
36 | | - |
37 | | - |
38 | 31 | def _libuv_build_env(): |
39 | 32 | env = os.environ.copy() |
40 | 33 |
|
@@ -80,13 +73,25 @@ class uvloop_build_ext(build_ext): |
80 | 73 | ] |
81 | 74 |
|
82 | 75 | def initialize_options(self): |
| 76 | + # initialize_options() may be called multiple times on the |
| 77 | + # same command object, so make sure not to override previously |
| 78 | + # set options. |
| 79 | + if getattr(self, '_initialized', False): |
| 80 | + return |
| 81 | + |
83 | 82 | super().initialize_options() |
84 | 83 | self.use_system_libuv = False |
85 | 84 | self.cython_always = False |
86 | 85 | self.cython_annotate = None |
87 | 86 | self.cython_directives = None |
88 | 87 |
|
89 | 88 | def finalize_options(self): |
| 89 | + # finalize_options() may be called multiple times on the |
| 90 | + # same command object, so make sure not to override previously |
| 91 | + # set options. |
| 92 | + if getattr(self, '_initialized', False): |
| 93 | + return |
| 94 | + |
90 | 95 | need_cythonize = self.cython_always |
91 | 96 | cfiles = {} |
92 | 97 |
|
@@ -141,6 +146,8 @@ def finalize_options(self): |
141 | 146 |
|
142 | 147 | super().finalize_options() |
143 | 148 |
|
| 149 | + self._initialized = True |
| 150 | + |
144 | 151 | def _patch_cfile(self, cfile): |
145 | 152 | # Patch Cython 'async def' coroutines to have a 'tp_iter' |
146 | 153 | # slot, which makes them compatible with 'yield from' without |
@@ -303,5 +310,5 @@ def build_extensions(self): |
303 | 310 | ], |
304 | 311 | provides=['uvloop'], |
305 | 312 | include_package_data=True, |
306 | | - test_suite='setup.discover_tests' |
| 313 | + test_suite='tests.suite' |
307 | 314 | ) |
0 commit comments