Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(36996)

Side by Side Diff: Lib/distutils/tests/test_build_ext.py

Issue 16754: Incorrect shared library extension on linux
Patch Set: Created 6 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/distutils/sysconfig.py ('k') | Makefile.pre.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import sys 1 import sys
2 import os 2 import os
3 from io import StringIO 3 from io import StringIO
4 import textwrap 4 import textwrap
5 5
6 from distutils.core import Distribution 6 from distutils.core import Distribution
7 from distutils.command.build_ext import build_ext 7 from distutils.command.build_ext import build_ext
8 from distutils import sysconfig 8 from distutils import sysconfig
9 from distutils.tests.support import (TempdirManager, LoggingSilencer, 9 from distutils.tests.support import (TempdirManager, LoggingSilencer,
10 copy_xxmodule_c, fixup_build_ext) 10 copy_xxmodule_c, fixup_build_ext)
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 other_tmp_dir = os.path.realpath(self.mkdtemp()) 311 other_tmp_dir = os.path.realpath(self.mkdtemp())
312 old_wd = os.getcwd() 312 old_wd = os.getcwd()
313 os.chdir(other_tmp_dir) 313 os.chdir(other_tmp_dir)
314 try: 314 try:
315 cmd.inplace = 1 315 cmd.inplace = 1
316 cmd.run() 316 cmd.run()
317 so_file = cmd.get_outputs()[0] 317 so_file = cmd.get_outputs()[0]
318 finally: 318 finally:
319 os.chdir(old_wd) 319 os.chdir(old_wd)
320 self.assertTrue(os.path.exists(so_file)) 320 self.assertTrue(os.path.exists(so_file))
321 so_ext = sysconfig.get_config_var('SO') 321 ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
322 self.assertTrue(so_file.endswith(so_ext)) 322 self.assertTrue(so_file.endswith(ext_suffix))
323 so_dir = os.path.dirname(so_file) 323 so_dir = os.path.dirname(so_file)
324 self.assertEqual(so_dir, other_tmp_dir) 324 self.assertEqual(so_dir, other_tmp_dir)
325 325
326 cmd.inplace = 0 326 cmd.inplace = 0
327 cmd.compiler = None 327 cmd.compiler = None
328 cmd.run() 328 cmd.run()
329 so_file = cmd.get_outputs()[0] 329 so_file = cmd.get_outputs()[0]
330 self.assertTrue(os.path.exists(so_file)) 330 self.assertTrue(os.path.exists(so_file))
331 self.assertTrue(so_file.endswith(so_ext)) 331 self.assertTrue(so_file.endswith(ext_suffix))
332 so_dir = os.path.dirname(so_file) 332 so_dir = os.path.dirname(so_file)
333 self.assertEqual(so_dir, cmd.build_lib) 333 self.assertEqual(so_dir, cmd.build_lib)
334 334
335 # inplace = 0, cmd.package = 'bar' 335 # inplace = 0, cmd.package = 'bar'
336 build_py = cmd.get_finalized_command('build_py') 336 build_py = cmd.get_finalized_command('build_py')
337 build_py.package_dir = {'': 'bar'} 337 build_py.package_dir = {'': 'bar'}
338 path = cmd.get_ext_fullpath('foo') 338 path = cmd.get_ext_fullpath('foo')
339 # checking that the last directory is the build_dir 339 # checking that the last directory is the build_dir
340 path = os.path.split(path)[0] 340 path = os.path.split(path)[0]
341 self.assertEqual(path, cmd.build_lib) 341 self.assertEqual(path, cmd.build_lib)
342 342
343 # inplace = 1, cmd.package = 'bar' 343 # inplace = 1, cmd.package = 'bar'
344 cmd.inplace = 1 344 cmd.inplace = 1
345 other_tmp_dir = os.path.realpath(self.mkdtemp()) 345 other_tmp_dir = os.path.realpath(self.mkdtemp())
346 old_wd = os.getcwd() 346 old_wd = os.getcwd()
347 os.chdir(other_tmp_dir) 347 os.chdir(other_tmp_dir)
348 try: 348 try:
349 path = cmd.get_ext_fullpath('foo') 349 path = cmd.get_ext_fullpath('foo')
350 finally: 350 finally:
351 os.chdir(old_wd) 351 os.chdir(old_wd)
352 # checking that the last directory is bar 352 # checking that the last directory is bar
353 path = os.path.split(path)[0] 353 path = os.path.split(path)[0]
354 lastdir = os.path.split(path)[-1] 354 lastdir = os.path.split(path)[-1]
355 self.assertEqual(lastdir, 'bar') 355 self.assertEqual(lastdir, 'bar')
356 356
357 def test_ext_fullpath(self): 357 def test_ext_fullpath(self):
358 ext = sysconfig.get_config_vars()['SO'] 358 ext = sysconfig.get_config_var('EXT_SUFFIX')
359 # building lxml.etree inplace 359 # building lxml.etree inplace
360 #etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c') 360 #etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
361 #etree_ext = Extension('lxml.etree', [etree_c]) 361 #etree_ext = Extension('lxml.etree', [etree_c])
362 #dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]}) 362 #dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
363 dist = Distribution() 363 dist = Distribution()
364 cmd = build_ext(dist) 364 cmd = build_ext(dist)
365 cmd.inplace = 1 365 cmd.inplace = 1
366 cmd.distribution.package_dir = {'': 'src'} 366 cmd.distribution.package_dir = {'': 'src'}
367 cmd.distribution.packages = ['lxml', 'lxml.html'] 367 cmd.distribution.packages = ['lxml', 'lxml.html']
368 curdir = os.getcwd() 368 curdir = os.getcwd()
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 except CompileError: 478 except CompileError:
479 self.fail("Wrong deployment target during compilation") 479 self.fail("Wrong deployment target during compilation")
480 480
481 481
482 def test_suite(): 482 def test_suite():
483 return unittest.makeSuite(BuildExtTestCase) 483 return unittest.makeSuite(BuildExtTestCase)
484 484
485 if __name__ == '__main__': 485 if __name__ == '__main__':
486 support.run_unittest(test_suite()) 486 support.run_unittest(test_suite())
OLDNEW
« no previous file with comments | « Lib/distutils/sysconfig.py ('k') | Makefile.pre.in » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+