]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 72783 via svnmerge from
authorTarek Ziadé <ziade.tarek@gmail.com>
Tue, 19 May 2009 16:24:16 +0000 (16:24 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Tue, 19 May 2009 16:24:16 +0000 (16:24 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r72783 | tarek.ziade | 2009-05-19 18:22:57 +0200 (Tue, 19 May 2009) | 9 lines

  Merged revisions 72781 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r72781 | tarek.ziade | 2009-05-19 18:17:21 +0200 (Tue, 19 May 2009) | 1 line

    fixed the 'package' option of build_ext
  ........
................

Lib/distutils/command/build_ext.py
Lib/distutils/tests/test_build_ext.py
Misc/NEWS

index 25131eace8fd22fbc037a3d207be54652c2d8903..a43aac4ba346537fa9af99f135012f4351584def 100644 (file)
@@ -613,19 +613,21 @@ class build_ext(Command):
         The file is located in `build_lib` or directly in the package
         (inplace option).
         """
-        if self.inplace:
-            fullname = self.get_ext_fullname(ext_name)
-            modpath = fullname.split('.')
-            package = '.'.join(modpath[0:-1])
-            base = modpath[-1]
-            build_py = self.get_finalized_command('build_py')
-            package_dir = os.path.abspath(build_py.get_package_dir(package))
-            filename = self.get_ext_filename(ext_name)
-            return os.path.join(package_dir, filename)
-        else:
-            filename = self.get_ext_filename(ext_name)
+        fullname = self.get_ext_fullname(ext_name)
+        filename = self.get_ext_filename(fullname)
+        if not self.inplace:
+            # no further work needed
             return os.path.join(self.build_lib, filename)
 
+        # the inplace option requires to find the package directory
+        # using the build_py command
+        modpath = fullname.split('.')
+        package = '.'.join(modpath[0:-1])
+        base = modpath[-1]
+        build_py = self.get_finalized_command('build_py')
+        package_dir = os.path.abspath(build_py.get_package_dir(package))
+        return os.path.join(package_dir, filename)
+
     def get_ext_fullname(self, ext_name):
         """Returns the fullname of a given extension name.
 
index cbacc81c248211f642035c71898ca157747c3f6d..9c97d7f2df0df5710b7249c1e6a1f4abcc3ea4a7 100644 (file)
@@ -274,6 +274,28 @@ class BuildExtTestCase(TempdirManager,
         so_dir = os.path.dirname(so_file)
         self.assertEquals(so_dir, cmd.build_lib)
 
+        # inplace = 0, cmd.package = 'bar'
+        cmd.package = 'bar'
+        path = cmd.get_ext_fullpath('foo')
+        # checking that the last directory is bar
+        path = os.path.split(path)[0]
+        lastdir = os.path.split(path)[-1]
+        self.assertEquals(lastdir, cmd.package)
+
+        # inplace = 1, cmd.package = 'bar'
+        cmd.inplace = 1
+        other_tmp_dir = os.path.realpath(self.mkdtemp())
+        old_wd = os.getcwd()
+        os.chdir(other_tmp_dir)
+        try:
+            path = cmd.get_ext_fullpath('foo')
+        finally:
+            os.chdir(old_wd)
+        # checking that the last directory is bar
+        path = os.path.split(path)[0]
+        lastdir = os.path.split(path)[-1]
+        self.assertEquals(lastdir, cmd.package)
+
 def test_suite():
     if not sysconfig.python_build:
         if support.verbose:
index 471e75ca967b7fa24d9986ec54cf99ea9aa9b360..4162327a543c7dd0f40f27e54395f5a54c14ccf5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -285,6 +285,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #6062: In distutils, fixed the package option of build_ext. Feedback 
+  and tests on pywin32 by Tim Golden.
+
 - Issue #6046: Fixed the library extension when distutils build_ext is used
   inplace. Initial patch by Roumen Petrov.