1010import platform
1111import re
1212import sys
13- import unittest
1413
1514import setuptools
1615from setuptools .command import build_ext as _build_ext
2928 CFLAGS .extend (['-Wall' , '-Wsign-compare' , '-Wconversion' ])
3029
3130
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-
3831class build_ext (_build_ext .build_ext ):
3932 user_options = _build_ext .build_ext .user_options + [
4033 ('cython-always' , None ,
@@ -46,12 +39,24 @@ class build_ext(_build_ext.build_ext):
4639 ]
4740
4841 def initialize_options (self ):
42+ # initialize_options() may be called multiple times on the
43+ # same command object, so make sure not to override previously
44+ # set options.
45+ if getattr (self , '_initialized' , False ):
46+ return
47+
4948 super (build_ext , self ).initialize_options ()
5049 self .cython_always = False
5150 self .cython_annotate = None
5251 self .cython_directives = None
5352
5453 def finalize_options (self ):
54+ # finalize_options() may be called multiple times on the
55+ # same command object, so make sure not to override previously
56+ # set options.
57+ if getattr (self , '_initialized' , False ):
58+ return
59+
5560 need_cythonize = self .cython_always
5661 cfiles = {}
5762
@@ -209,5 +214,5 @@ def _patch_cfile(self, cfile):
209214 extra_link_args = LDFLAGS )
210215 ],
211216 cmdclass = {'build_ext' : build_ext },
212- test_suite = 'setup.discover_tests ' ,
217+ test_suite = 'tests.suite ' ,
213218)
0 commit comments