blob: 203cbc98feae9fb946d209ce20c53fc2b622f381 [file] [log] [blame]
Georg Brandlb533e262008-05-25 18:19:30 +00001import sys
2import os
Georg Brandlb533e262008-05-25 18:19:30 +00003import shutil
4from io import StringIO
5
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00006from distutils.core import Distribution
Georg Brandlb533e262008-05-25 18:19:30 +00007from distutils.command.build_ext import build_ext
Tarek Ziadé36797272010-07-22 12:50:05 +00008from distutils import sysconfig
Tarek Ziadéc1375d52009-02-14 14:35:51 +00009from distutils.tests.support import TempdirManager
Tarek Ziadéb2e36f12009-03-31 22:37:55 +000010from distutils.tests.support import LoggingSilencer
11from distutils.extension import Extension
Barry Warsaw8cf4eae2010-10-16 01:04:07 +000012from distutils.errors import (
13 CompileError, DistutilsSetupError, UnknownFileError)
Georg Brandlb533e262008-05-25 18:19:30 +000014
15import unittest
16from test import support
Éric Araujo70ec44a2010-11-06 02:44:43 +000017from test.support import run_unittest
Georg Brandlb533e262008-05-25 18:19:30 +000018
Christian Heimes3e7e0692008-11-25 21:21:32 +000019# http://bugs.python.org/issue4373
20# Don't load the xx module more than once.
21ALREADY_TESTED = False
22
Neil Schemenauerd8f63bb2009-02-06 21:42:05 +000023def _get_source_filename():
24 srcdir = sysconfig.get_config_var('srcdir')
25 return os.path.join(srcdir, 'Modules', 'xxmodule.c')
26
Tarek Ziadé36797272010-07-22 12:50:05 +000027class BuildExtTestCase(TempdirManager,
28 LoggingSilencer,
29 unittest.TestCase):
Georg Brandlb533e262008-05-25 18:19:30 +000030 def setUp(self):
31 # Create a simple test environment
32 # Note that we're making changes to sys.path
Tarek Ziadé38e3d512009-02-27 12:58:56 +000033 super(BuildExtTestCase, self).setUp()
Tarek Ziadéc1375d52009-02-14 14:35:51 +000034 self.tmp_dir = self.mkdtemp()
Tarek Ziadé36797272010-07-22 12:50:05 +000035 self.sys_path = sys.path, sys.path[:]
36 sys.path.append(self.tmp_dir)
37 shutil.copy(_get_source_filename(), self.tmp_dir)
Tarek Ziadé38e3d512009-02-27 12:58:56 +000038 if sys.version > "2.6":
39 import site
40 self.old_user_base = site.USER_BASE
41 site.USER_BASE = self.mkdtemp()
42 from distutils.command import build_ext
43 build_ext.USER_BASE = site.USER_BASE
Georg Brandlb533e262008-05-25 18:19:30 +000044
Barry Warsaw8cf4eae2010-10-16 01:04:07 +000045 def _fixup_command(self, cmd):
46 # When Python was build with --enable-shared, -L. is not good enough
47 # to find the libpython<blah>.so. This is because regrtest runs it
48 # under a tempdir, not in the top level where the .so lives. By the
49 # time we've gotten here, Python's already been chdir'd to the
50 # tempdir.
51 #
52 # To further add to the fun, we can't just add library_dirs to the
53 # Extension() instance because that doesn't get plumbed through to the
54 # final compiler command.
Barry Warsaw4ebfdf02010-10-22 17:17:51 +000055 if (sysconfig.get_config_var('Py_ENABLE_SHARED') and
56 not sys.platform.startswith('win')):
Éric Araujo68fc9aa2010-10-21 23:02:07 +000057 runshared = sysconfig.get_config_var('RUNSHARED')
58 if runshared is None:
59 cmd.library_dirs = ['.']
60 else:
61 name, equals, value = runshared.partition('=')
62 cmd.library_dirs = value.split(os.pathsep)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +000063
Georg Brandlb533e262008-05-25 18:19:30 +000064 def test_build_ext(self):
Christian Heimes3e7e0692008-11-25 21:21:32 +000065 global ALREADY_TESTED
Georg Brandlb533e262008-05-25 18:19:30 +000066 xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
67 xx_ext = Extension('xx', [xx_c])
68 dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
69 dist.package_dir = self.tmp_dir
70 cmd = build_ext(dist)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +000071 self._fixup_command(cmd)
Thomas Heller84b7f0c2008-05-26 11:51:44 +000072 if os.name == "nt":
73 # On Windows, we must build a debug version iff running
74 # a debug build of Python
75 cmd.debug = sys.executable.endswith("_d.exe")
Georg Brandlb533e262008-05-25 18:19:30 +000076 cmd.build_lib = self.tmp_dir
77 cmd.build_temp = self.tmp_dir
78
79 old_stdout = sys.stdout
80 if not support.verbose:
81 # silence compiler output
82 sys.stdout = StringIO()
83 try:
84 cmd.ensure_finalized()
85 cmd.run()
86 finally:
87 sys.stdout = old_stdout
88
Christian Heimes3e7e0692008-11-25 21:21:32 +000089 if ALREADY_TESTED:
90 return
91 else:
92 ALREADY_TESTED = True
93
Georg Brandlb533e262008-05-25 18:19:30 +000094 import xx
95
96 for attr in ('error', 'foo', 'new', 'roj'):
Benjamin Petersonc9c0f202009-06-30 23:06:06 +000097 self.assertTrue(hasattr(xx, attr))
Georg Brandlb533e262008-05-25 18:19:30 +000098
99 self.assertEquals(xx.foo(2, 5), 7)
100 self.assertEquals(xx.foo(13,15), 28)
101 self.assertEquals(xx.new().demo(), None)
102 doc = 'This is a template module just for instruction.'
103 self.assertEquals(xx.__doc__, doc)
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000104 self.assertTrue(isinstance(xx.Null(), xx.Null))
105 self.assertTrue(isinstance(xx.Str(), xx.Str))
Georg Brandlb533e262008-05-25 18:19:30 +0000106
Tarek Ziadé36797272010-07-22 12:50:05 +0000107 def tearDown(self):
108 # Get everything back to normal
109 support.unload('xx')
110 sys.path = self.sys_path[0]
111 sys.path[:] = self.sys_path[1]
112 if sys.version > "2.6":
113 import site
114 site.USER_BASE = self.old_user_base
115 from distutils.command import build_ext
116 build_ext.USER_BASE = self.old_user_base
117 super(BuildExtTestCase, self).tearDown()
118
Tarek Ziadé5874ef12009-02-05 22:56:14 +0000119 def test_solaris_enable_shared(self):
120 dist = Distribution({'name': 'xx'})
121 cmd = build_ext(dist)
122 old = sys.platform
123
124 sys.platform = 'sunos' # fooling finalize_options
Tarek Ziadé36797272010-07-22 12:50:05 +0000125 from distutils.sysconfig import _config_vars
126 old_var = _config_vars.get('Py_ENABLE_SHARED')
127 _config_vars['Py_ENABLE_SHARED'] = 1
Tarek Ziadé5874ef12009-02-05 22:56:14 +0000128 try:
129 cmd.ensure_finalized()
130 finally:
131 sys.platform = old
132 if old_var is None:
Tarek Ziadé36797272010-07-22 12:50:05 +0000133 del _config_vars['Py_ENABLE_SHARED']
Tarek Ziadé5874ef12009-02-05 22:56:14 +0000134 else:
Tarek Ziadé36797272010-07-22 12:50:05 +0000135 _config_vars['Py_ENABLE_SHARED'] = old_var
Tarek Ziadé5874ef12009-02-05 22:56:14 +0000136
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000137 # make sure we get some library dirs under solaris
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000138 self.assertTrue(len(cmd.library_dirs) > 0)
Tarek Ziadé5874ef12009-02-05 22:56:14 +0000139
Tarek Ziadé38e3d512009-02-27 12:58:56 +0000140 def test_user_site(self):
141 # site.USER_SITE was introduced in 2.6
142 if sys.version < '2.6':
143 return
144
145 import site
146 dist = Distribution({'name': 'xx'})
147 cmd = build_ext(dist)
148
Tarek Ziadébe720e02009-05-09 11:55:12 +0000149 # making sure the user option is there
Tarek Ziadé38e3d512009-02-27 12:58:56 +0000150 options = [name for name, short, lable in
151 cmd.user_options]
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000152 self.assertTrue('user' in options)
Tarek Ziadé38e3d512009-02-27 12:58:56 +0000153
154 # setting a value
155 cmd.user = 1
156
157 # setting user based lib and include
158 lib = os.path.join(site.USER_BASE, 'lib')
159 incl = os.path.join(site.USER_BASE, 'include')
160 os.mkdir(lib)
161 os.mkdir(incl)
162
163 # let's run finalize
164 cmd.ensure_finalized()
165
166 # see if include_dirs and library_dirs
167 # were set
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000168 self.assertTrue(lib in cmd.library_dirs)
169 self.assertTrue(lib in cmd.rpath)
170 self.assertTrue(incl in cmd.include_dirs)
Tarek Ziadé38e3d512009-02-27 12:58:56 +0000171
Tarek Ziadéb2e36f12009-03-31 22:37:55 +0000172 def test_optional_extension(self):
173
174 # this extension will fail, but let's ignore this failure
175 # with the optional argument.
176 modules = [Extension('foo', ['xxx'], optional=False)]
177 dist = Distribution({'name': 'xx', 'ext_modules': modules})
178 cmd = build_ext(dist)
179 cmd.ensure_finalized()
Tarek Ziadé30911292009-03-31 22:50:54 +0000180 self.assertRaises((UnknownFileError, CompileError),
181 cmd.run) # should raise an error
Tarek Ziadéb2e36f12009-03-31 22:37:55 +0000182
183 modules = [Extension('foo', ['xxx'], optional=True)]
184 dist = Distribution({'name': 'xx', 'ext_modules': modules})
185 cmd = build_ext(dist)
186 cmd.ensure_finalized()
187 cmd.run() # should pass
188
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000189 def test_finalize_options(self):
190 # Make sure Python's include directories (for Python.h, pyconfig.h,
191 # etc.) are in the include search path.
192 modules = [Extension('foo', ['xxx'], optional=False)]
193 dist = Distribution({'name': 'xx', 'ext_modules': modules})
194 cmd = build_ext(dist)
195 cmd.finalize_options()
196
Tarek Ziadé36797272010-07-22 12:50:05 +0000197 from distutils import sysconfig
198 py_include = sysconfig.get_python_inc()
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000199 self.assertTrue(py_include in cmd.include_dirs)
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000200
Tarek Ziadé36797272010-07-22 12:50:05 +0000201 plat_py_include = sysconfig.get_python_inc(plat_specific=1)
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000202 self.assertTrue(plat_py_include in cmd.include_dirs)
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000203
204 # make sure cmd.libraries is turned into a list
205 # if it's a string
206 cmd = build_ext(dist)
207 cmd.libraries = 'my_lib'
208 cmd.finalize_options()
209 self.assertEquals(cmd.libraries, ['my_lib'])
210
211 # make sure cmd.library_dirs is turned into a list
212 # if it's a string
213 cmd = build_ext(dist)
214 cmd.library_dirs = 'my_lib_dir'
215 cmd.finalize_options()
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000216 self.assertTrue('my_lib_dir' in cmd.library_dirs)
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000217
218 # make sure rpath is turned into a list
219 # if it's a list of os.pathsep's paths
220 cmd = build_ext(dist)
221 cmd.rpath = os.pathsep.join(['one', 'two'])
222 cmd.finalize_options()
223 self.assertEquals(cmd.rpath, ['one', 'two'])
224
225 # XXX more tests to perform for win32
226
227 # make sure define is turned into 2-tuples
228 # strings if they are ','-separated strings
229 cmd = build_ext(dist)
230 cmd.define = 'one,two'
231 cmd.finalize_options()
232 self.assertEquals(cmd.define, [('one', '1'), ('two', '1')])
233
234 # make sure undef is turned into a list of
235 # strings if they are ','-separated strings
236 cmd = build_ext(dist)
237 cmd.undef = 'one,two'
238 cmd.finalize_options()
239 self.assertEquals(cmd.undef, ['one', 'two'])
240
241 # make sure swig_opts is turned into a list
242 cmd = build_ext(dist)
243 cmd.swig_opts = None
244 cmd.finalize_options()
245 self.assertEquals(cmd.swig_opts, [])
246
247 cmd = build_ext(dist)
248 cmd.swig_opts = '1 2'
249 cmd.finalize_options()
250 self.assertEquals(cmd.swig_opts, ['1', '2'])
251
252 def test_check_extensions_list(self):
253 dist = Distribution()
254 cmd = build_ext(dist)
255 cmd.finalize_options()
256
257 #'extensions' option must be a list of Extension instances
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000258 self.assertRaises(DistutilsSetupError,
259 cmd.check_extensions_list, 'foo')
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000260
261 # each element of 'ext_modules' option must be an
262 # Extension instance or 2-tuple
263 exts = [('bar', 'foo', 'bar'), 'foo']
264 self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, exts)
265
266 # first element of each tuple in 'ext_modules'
267 # must be the extension name (a string) and match
268 # a python dotted-separated name
269 exts = [('foo-bar', '')]
270 self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, exts)
271
272 # second element of each tuple in 'ext_modules'
273 # must be a ary (build info)
274 exts = [('foo.bar', '')]
275 self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, exts)
276
277 # ok this one should pass
278 exts = [('foo.bar', {'sources': [''], 'libraries': 'foo',
279 'some': 'bar'})]
280 cmd.check_extensions_list(exts)
281 ext = exts[0]
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000282 self.assertTrue(isinstance(ext, Extension))
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000283
284 # check_extensions_list adds in ext the values passed
285 # when they are in ('include_dirs', 'library_dirs', 'libraries'
286 # 'extra_objects', 'extra_compile_args', 'extra_link_args')
287 self.assertEquals(ext.libraries, 'foo')
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000288 self.assertTrue(not hasattr(ext, 'some'))
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000289
290 # 'macros' element of build info dict must be 1- or 2-tuple
291 exts = [('foo.bar', {'sources': [''], 'libraries': 'foo',
292 'some': 'bar', 'macros': [('1', '2', '3'), 'foo']})]
293 self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, exts)
294
295 exts[0][1]['macros'] = [('1', '2'), ('3',)]
296 cmd.check_extensions_list(exts)
297 self.assertEquals(exts[0].undef_macros, ['3'])
298 self.assertEquals(exts[0].define_macros, [('1', '2')])
299
300 def test_get_source_files(self):
301 modules = [Extension('foo', ['xxx'], optional=False)]
302 dist = Distribution({'name': 'xx', 'ext_modules': modules})
303 cmd = build_ext(dist)
304 cmd.ensure_finalized()
305 self.assertEquals(cmd.get_source_files(), ['xxx'])
306
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000307 def test_compiler_option(self):
308 # cmd.compiler is an option and
309 # should not be overriden by a compiler instance
310 # when the command is run
311 dist = Distribution()
312 cmd = build_ext(dist)
313 cmd.compiler = 'unix'
314 cmd.ensure_finalized()
315 cmd.run()
316 self.assertEquals(cmd.compiler, 'unix')
317
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000318 def test_get_outputs(self):
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000319 tmp_dir = self.mkdtemp()
320 c_file = os.path.join(tmp_dir, 'foo.c')
Victor Stinner3e2b7172010-11-09 09:32:19 +0000321 self.write_file(c_file, 'void PyInit_foo(void) {}\n')
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000322 ext = Extension('foo', [c_file], optional=False)
323 dist = Distribution({'name': 'xx',
324 'ext_modules': [ext]})
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000325 cmd = build_ext(dist)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000326 self._fixup_command(cmd)
Tarek Ziadé06fbee12009-05-10 10:34:01 +0000327 cmd.ensure_finalized()
328 self.assertEquals(len(cmd.get_outputs()), 1)
329
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000330 if os.name == "nt":
331 cmd.debug = sys.executable.endswith("_d.exe")
332
333 cmd.build_lib = os.path.join(self.tmp_dir, 'build')
334 cmd.build_temp = os.path.join(self.tmp_dir, 'tempt')
335
336 # issue #5977 : distutils build_ext.get_outputs
337 # returns wrong result with --inplace
Tarek Ziadé4210c6e2009-05-14 20:20:47 +0000338 other_tmp_dir = os.path.realpath(self.mkdtemp())
339 old_wd = os.getcwd()
340 os.chdir(other_tmp_dir)
341 try:
342 cmd.inplace = 1
343 cmd.run()
344 so_file = cmd.get_outputs()[0]
345 finally:
346 os.chdir(old_wd)
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000347 self.assertTrue(os.path.exists(so_file))
Barry Warsaw35f3a2c2010-09-03 18:30:30 +0000348 so_ext = sysconfig.get_config_var('SO')
349 self.assertTrue(so_file.endswith(so_ext))
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000350 so_dir = os.path.dirname(so_file)
Tarek Ziadé4210c6e2009-05-14 20:20:47 +0000351 self.assertEquals(so_dir, other_tmp_dir)
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000352
353 cmd.inplace = 0
Tarek Ziadé36797272010-07-22 12:50:05 +0000354 cmd.compiler = None
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000355 cmd.run()
356 so_file = cmd.get_outputs()[0]
Benjamin Petersonc9c0f202009-06-30 23:06:06 +0000357 self.assertTrue(os.path.exists(so_file))
Barry Warsaw35f3a2c2010-09-03 18:30:30 +0000358 self.assertTrue(so_file.endswith(so_ext))
Tarek Ziadéff0e5002009-05-12 17:14:01 +0000359 so_dir = os.path.dirname(so_file)
360 self.assertEquals(so_dir, cmd.build_lib)
361
Tarek Ziadé822eb842009-05-19 16:22:57 +0000362 # inplace = 0, cmd.package = 'bar'
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000363 build_py = cmd.get_finalized_command('build_py')
364 build_py.package_dir = {'': 'bar'}
Tarek Ziadé822eb842009-05-19 16:22:57 +0000365 path = cmd.get_ext_fullpath('foo')
Tarek Ziadé0156f912009-06-29 16:19:22 +0000366 # checking that the last directory is the build_dir
Tarek Ziadé822eb842009-05-19 16:22:57 +0000367 path = os.path.split(path)[0]
Tarek Ziadé0156f912009-06-29 16:19:22 +0000368 self.assertEquals(path, cmd.build_lib)
Tarek Ziadé822eb842009-05-19 16:22:57 +0000369
370 # inplace = 1, cmd.package = 'bar'
371 cmd.inplace = 1
372 other_tmp_dir = os.path.realpath(self.mkdtemp())
373 old_wd = os.getcwd()
374 os.chdir(other_tmp_dir)
375 try:
376 path = cmd.get_ext_fullpath('foo')
377 finally:
378 os.chdir(old_wd)
379 # checking that the last directory is bar
380 path = os.path.split(path)[0]
381 lastdir = os.path.split(path)[-1]
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000382 self.assertEquals(lastdir, 'bar')
Tarek Ziadé822eb842009-05-19 16:22:57 +0000383
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000384 def test_ext_fullpath(self):
Tarek Ziadéb7815e32009-07-10 09:14:31 +0000385 ext = sysconfig.get_config_vars()['SO']
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000386 # building lxml.etree inplace
387 #etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
388 #etree_ext = Extension('lxml.etree', [etree_c])
389 #dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
390 dist = Distribution()
Tarek Ziadé0156f912009-06-29 16:19:22 +0000391 cmd = build_ext(dist)
392 cmd.inplace = 1
393 cmd.distribution.package_dir = {'': 'src'}
394 cmd.distribution.packages = ['lxml', 'lxml.html']
395 curdir = os.getcwd()
Tarek Ziadéb7815e32009-07-10 09:14:31 +0000396 wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
Tarek Ziadé0156f912009-06-29 16:19:22 +0000397 path = cmd.get_ext_fullpath('lxml.etree')
398 self.assertEquals(wanted, path)
399
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000400 # building lxml.etree not inplace
401 cmd.inplace = 0
402 cmd.build_lib = os.path.join(curdir, 'tmpdir')
Tarek Ziadéb7815e32009-07-10 09:14:31 +0000403 wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000404 path = cmd.get_ext_fullpath('lxml.etree')
405 self.assertEquals(wanted, path)
406
407 # building twisted.runner.portmap not inplace
408 build_py = cmd.get_finalized_command('build_py')
409 build_py.package_dir = {}
410 cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
411 path = cmd.get_ext_fullpath('twisted.runner.portmap')
412 wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
Tarek Ziadéb7815e32009-07-10 09:14:31 +0000413 'portmap' + ext)
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000414 self.assertEquals(wanted, path)
415
416 # building twisted.runner.portmap inplace
417 cmd.inplace = 1
418 path = cmd.get_ext_fullpath('twisted.runner.portmap')
Tarek Ziadéb7815e32009-07-10 09:14:31 +0000419 wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
Tarek Ziadée10d6de2009-07-03 08:33:28 +0000420 self.assertEquals(wanted, path)
421
Georg Brandlb533e262008-05-25 18:19:30 +0000422def test_suite():
Neil Schemenauerd8f63bb2009-02-06 21:42:05 +0000423 src = _get_source_filename()
424 if not os.path.exists(src):
Georg Brandlb533e262008-05-25 18:19:30 +0000425 if support.verbose:
Neil Schemenauerd8f63bb2009-02-06 21:42:05 +0000426 print('test_build_ext: Cannot find source code (test'
427 ' must run in python build dir)')
Georg Brandlb533e262008-05-25 18:19:30 +0000428 return unittest.TestSuite()
429 else: return unittest.makeSuite(BuildExtTestCase)
430
431if __name__ == '__main__':
432 support.run_unittest(test_suite())