[Python-checkins] r73791 - in python/branches/release26-maint: Lib/distutils/command/build_ext.py Lib/distutils/tests/test_build_ext.py Misc/NEWS

tarek.ziade python-checkins at python.org
Fri Jul 3 10:31:32 CEST 2009


Author: tarek.ziade
Date: Fri Jul  3 10:31:31 2009
New Revision: 73791

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

........
  r73790 | tarek.ziade | 2009-07-03 10:22:56 +0200 (Fri, 03 Jul 2009) | 1 line
  
  Fixed #6403 : package path usage for build_ext
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/distutils/command/build_ext.py
   python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py
   python/branches/release26-maint/Misc/NEWS

Modified: python/branches/release26-maint/Lib/distutils/command/build_ext.py
==============================================================================
--- python/branches/release26-maint/Lib/distutils/command/build_ext.py	(original)
+++ python/branches/release26-maint/Lib/distutils/command/build_ext.py	Fri Jul  3 10:31:31 2009
@@ -629,18 +629,27 @@
         (inplace option).
         """
         fullname = self.get_ext_fullname(ext_name)
-        filename = self.get_ext_filename(fullname)
+        modpath = fullname.split('.')
+        filename = self.get_ext_filename(modpath[-1])
+
         if not self.inplace:
             # no further work needed
+            # returning :
+            #   build_dir/package/path/filename
+            filename = os.path.join(*modpath[:-1]+[filename])
             return os.path.join(self.build_lib, filename)
 
         # the inplace option requires to find the package directory
-        # using the build_py command
+        # using the build_py command for that
+        package = '.'.join(modpath[0:-1])
         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))
+
+        # returning
+        #   package_dir/filename
         return os.path.join(package_dir, filename)
 
     def get_ext_fullname(self, ext_name):

Modified: python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py	(original)
+++ python/branches/release26-maint/Lib/distutils/tests/test_build_ext.py	Fri Jul  3 10:31:31 2009
@@ -274,12 +274,12 @@
         self.assertEquals(so_dir, cmd.build_lib)
 
         # inplace = 0, cmd.package = 'bar'
-        cmd.package = 'bar'
+        build_py = cmd.get_finalized_command('build_py')
+        build_py.package_dir = {'': 'bar'}
         path = cmd.get_ext_fullpath('foo')
-        # checking that the last directory is bar
+        # checking that the last directory is the build_dir
         path = os.path.split(path)[0]
-        lastdir = os.path.split(path)[-1]
-        self.assertEquals(lastdir, cmd.package)
+        self.assertEquals(path, cmd.build_lib)
 
         # inplace = 1, cmd.package = 'bar'
         cmd.inplace = 1
@@ -293,7 +293,40 @@
         # checking that the last directory is bar
         path = os.path.split(path)[0]
         lastdir = os.path.split(path)[-1]
-        self.assertEquals(lastdir, cmd.package)
+        self.assertEquals(lastdir, 'bar')
+
+    def test_ext_fullpath(self):
+        dist = Distribution()
+        cmd = build_ext(dist)
+        cmd.inplace = 1
+        cmd.distribution.package_dir = {'': 'src'}
+        cmd.distribution.packages = ['lxml', 'lxml.html']
+        curdir = os.getcwd()
+        wanted = os.path.join(curdir, 'src', 'lxml', 'etree.so')
+        path = cmd.get_ext_fullpath('lxml.etree')
+        self.assertEquals(wanted, path)
+
+        # building lxml.etree not inplace
+        cmd.inplace = 0
+        cmd.build_lib = os.path.join(curdir, 'tmpdir')
+        wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree.so')
+        path = cmd.get_ext_fullpath('lxml.etree')
+        self.assertEquals(wanted, path)
+
+        # building twisted.runner.portmap not inplace
+        build_py = cmd.get_finalized_command('build_py')
+        build_py.package_dir = {}
+        cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
+        path = cmd.get_ext_fullpath('twisted.runner.portmap')
+        wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
+                              'portmap.so')
+        self.assertEquals(wanted, path)
+
+        # building twisted.runner.portmap inplace
+        cmd.inplace = 1
+        path = cmd.get_ext_fullpath('twisted.runner.portmap')
+        wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap.so')
+        self.assertEquals(wanted, path)
 
 def test_suite():
     if not sysconfig.python_build:

Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Fri Jul  3 10:31:31 2009
@@ -262,6 +262,8 @@
 Library
 -------
 
+- Issue #6403: Fixed package path usage in build_ext.
+
 - Issue #6287: Added the license field in Distutils documentation.
 
 - Issue #6263: Fixed syntax error in distutils.cygwincompiler.


More information about the Python-checkins mailing list