diff Lib/distutils/command/build_ext.py @ 54203:883ace7ea446 legacy-trunk

fixed the 'package' option of build_ext
author Tarek Ziadé <ziade.tarek@gmail.com>
date Tue, 19 May 2009 16:17:21 +0000
parents e3bb6b62bd0f
children 3dcc8fc4354e
line wrap: on
line diff
--- a/Lib/distutils/command/build_ext.py	Mon May 18 21:35:40 2009 +0000
+++ b/Lib/distutils/command/build_ext.py	Tue May 19 16:17:21 2009 +0000
@@ -642,19 +642,21 @@
         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.