Fixed the library extension when distutils build_ext is used inplace

This commit is contained in:
Tarek Ziadé 2009-05-18 08:03:37 +00:00
parent 5605416100
commit fcc7f039ec
3 changed files with 10 additions and 10 deletions

View file

@ -649,7 +649,8 @@ class build_ext (Command):
base = modpath[-1] base = modpath[-1]
build_py = self.get_finalized_command('build_py') build_py = self.get_finalized_command('build_py')
package_dir = os.path.abspath(build_py.get_package_dir(package)) package_dir = os.path.abspath(build_py.get_package_dir(package))
return os.path.join(package_dir, base) filename = self.get_ext_filename(ext_name)
return os.path.join(package_dir, filename)
else: else:
filename = self.get_ext_filename(ext_name) filename = self.get_ext_filename(ext_name)
return os.path.join(self.build_lib, filename) return os.path.join(self.build_lib, filename)
@ -663,12 +664,11 @@ class build_ext (Command):
else: else:
return self.package + '.' + ext_name return self.package + '.' + ext_name
def get_ext_filename (self, ext_name): def get_ext_filename(self, ext_name):
r"""Convert the name of an extension (eg. "foo.bar") into the name r"""Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd"). "foo\bar.pyd").
""" """
from distutils.sysconfig import get_config_var from distutils.sysconfig import get_config_var
ext_path = string.split(ext_name, '.') ext_path = string.split(ext_name, '.')
# OS/2 has an 8 character module (extension) limit :-( # OS/2 has an 8 character module (extension) limit :-(

View file

@ -19,12 +19,6 @@ from test import test_support
# Don't load the xx module more than once. # Don't load the xx module more than once.
ALREADY_TESTED = False ALREADY_TESTED = False
if sys.platform != 'win32':
UNDER_MSVC8 = False
else:
from distutils.msvccompiler import get_build_version
UNDER_MSVC8 = get_build_version() < 8.0
def _get_source_filename(): def _get_source_filename():
srcdir = sysconfig.get_config_var('srcdir') srcdir = sysconfig.get_config_var('srcdir')
return os.path.join(srcdir, 'Modules', 'xxmodule.c') return os.path.join(srcdir, 'Modules', 'xxmodule.c')
@ -299,7 +293,6 @@ class BuildExtTestCase(support.TempdirManager,
cmd.run() cmd.run()
self.assertEquals(cmd.compiler, 'unix') self.assertEquals(cmd.compiler, 'unix')
@unittest.skipIf(UNDER_MSVC8, 'not running this test for MSVC < 8')
def test_get_outputs(self): def test_get_outputs(self):
tmp_dir = self.mkdtemp() tmp_dir = self.mkdtemp()
c_file = os.path.join(tmp_dir, 'foo.c') c_file = os.path.join(tmp_dir, 'foo.c')
@ -329,6 +322,8 @@ class BuildExtTestCase(support.TempdirManager,
finally: finally:
os.chdir(old_wd) os.chdir(old_wd)
self.assert_(os.path.exists(so_file)) self.assert_(os.path.exists(so_file))
self.assertEquals(os.path.splitext(so_file)[-1],
sysconfig.get_config_var('SO'))
so_dir = os.path.dirname(so_file) so_dir = os.path.dirname(so_file)
self.assertEquals(so_dir, other_tmp_dir) self.assertEquals(so_dir, other_tmp_dir)
@ -336,6 +331,8 @@ class BuildExtTestCase(support.TempdirManager,
cmd.run() cmd.run()
so_file = cmd.get_outputs()[0] so_file = cmd.get_outputs()[0]
self.assert_(os.path.exists(so_file)) self.assert_(os.path.exists(so_file))
self.assertEquals(os.path.splitext(so_file)[-1],
sysconfig.get_config_var('SO'))
so_dir = os.path.dirname(so_file) so_dir = os.path.dirname(so_file)
self.assertEquals(so_dir, cmd.build_lib) self.assertEquals(so_dir, cmd.build_lib)

View file

@ -298,6 +298,9 @@ Core and Builtins
Library Library
------- -------
- Issue #6046: Fixed the library extension when distutils build_ext is used
inplace. Initial patch by Roumen Petrov.
- Issue #6041: Now distutils `sdist` and `register` commands use `check` as a - Issue #6041: Now distutils `sdist` and `register` commands use `check` as a
subcommand. subcommand.