[Python-checkins] r72781 - in python/trunk: Lib/distutils/command/build_ext.py Lib/distutils/tests/test_build_ext.py Misc/NEWS

tarek.ziade python-checkins at python.org
Tue May 19 18:17:21 CEST 2009


Author: tarek.ziade
Date: Tue May 19 18:17:21 2009
New Revision: 72781
Log:
fixed the 'package' option of build_ext
Modified:
 python/trunk/Lib/distutils/command/build_ext.py
 python/trunk/Lib/distutils/tests/test_build_ext.py
 python/trunk/Misc/NEWS
Modified: python/trunk/Lib/distutils/command/build_ext.py
==============================================================================
--- python/trunk/Lib/distutils/command/build_ext.py	(original)
+++ python/trunk/Lib/distutils/command/build_ext.py	Tue May 19 18:17:21 2009
@@ -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.
 
Modified: python/trunk/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_build_ext.py	(original)
+++ python/trunk/Lib/distutils/tests/test_build_ext.py	Tue May 19 18:17:21 2009
@@ -336,6 +336,28 @@
 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():
 src = _get_source_filename()
 if not os.path.exists(src):
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Tue May 19 18:17:21 2009
@@ -298,6 +298,9 @@
 Library
 -------
 
+- Issue #6062: In distutils, fixed the package option of build_ext. Feedback 
+ and tests on pywin32 by Tim Golden.
+
 - Issue #6053: Fixed distutils tests on win32. patch by Hirokazu Yamamoto.
 
 - Issue #6046: Fixed the library extension when distutils build_ext is used


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /