diff -Nru -x '*pyc' ./command/build_ext.py /usr/lib/python2.5/distutils/command/build_ext.py --- ./command/build_ext.py 2008-01-20 16:18:51.617059839 -0500 +++ /usr/lib/python2.5/distutils/command/build_ext.py 2008-01-19 22:38:16.693948159 -0500 @@ -56,6 +56,7 @@ "directory for compiled extension modules"), ('build-temp=', 't', "directory for temporary files (build by-products)"), + ('src-dir=', None, "directory holding the source [default: .]"), ('inplace', 'i', "ignore build-lib and put compiled extensions into the source " + "directory alongside your pure Python modules"), @@ -114,6 +115,7 @@ self.swig = None self.swig_cpp = None self.swig_opts = None + self.src_dir = None def finalize_options (self): from distutils import sysconfig @@ -121,6 +123,7 @@ self.set_undefined_options('build', ('build_lib', 'build_lib'), ('build_temp', 'build_temp'), + ('src_dir', 'src_dir'), ('compiler', 'compiler'), ('debug', 'debug'), ('force', 'force')) @@ -226,6 +229,8 @@ else: self.swig_opts = self.swig_opts.split(' ') + if self.src_dir is None: + self.src_dir = "." # finalize_options () @@ -423,7 +428,12 @@ "'sources' must be present and must be " + "a list of source filenames") % ext.name sources = list(sources) - + new_sources = [] + for source in sources: + new_sources.append(os.path.join(self.src_dir,source)) + sources = new_sources + del new_sources + fullname = self.get_ext_fullname(ext.name) if self.inplace: # ignore build-lib -- put the compiled extension into diff -Nru -x '*pyc' ./command/build.py /usr/lib/python2.5/distutils/command/build.py --- ./command/build.py 2008-01-20 16:19:43.897510859 -0500 +++ /usr/lib/python2.5/distutils/command/build.py 2008-01-19 22:26:35.615900005 -0500 @@ -34,6 +34,8 @@ "build directory for scripts"), ('build-temp=', 't', "temporary build directory"), + ('src-dir=', None, + "source directory [default: '.']"), ('compiler=', 'c', "specify the compiler type"), ('debug', 'g', @@ -64,6 +66,7 @@ self.debug = None self.force = 0 self.executable = None + self.src_dir = None def finalize_options (self): diff -Nru -x '*pyc' ./command/build_py.py /usr/lib/python2.5/distutils/command/build_py.py --- ./command/build_py.py 2008-01-20 16:18:51.565059391 -0500 +++ /usr/lib/python2.5/distutils/command/build_py.py 2008-01-19 22:39:13.514438346 -0500 @@ -22,6 +22,7 @@ user_options = [ ('build-lib=', 'd', "directory to \"build\" (copy) to"), ('compile', 'c', "compile .py to .pyc"), + ('src-dir=', None, "directory holding the source [default: .]"), ('no-compile', None, "don't compile .py files [default]"), ('optimize=', 'O', "also compile with optimization: -O1 for \"python -O\", " @@ -42,10 +43,12 @@ self.compile = 0 self.optimize = 0 self.force = None + self.src_dir = None def finalize_options (self): self.set_undefined_options('build', ('build_lib', 'build_lib'), + ('src_dir', 'src_dir'), ('force', 'force')) # Get the distribution options that are aliases for build_py @@ -67,6 +70,9 @@ assert 0 <= self.optimize <= 2 except (ValueError, AssertionError): raise DistutilsOptionError, "optimize must be 0, 1, or 2" + if self.src_dir is None: + self.src_dir = "." + def run (self): @@ -156,9 +162,9 @@ if not self.package_dir: if path: - return apply(os.path.join, path) + return os.path.join(self.src_dir,apply(os.path.join, path)) else: - return '' + return self.src_dir else: tail = [] while path: @@ -169,7 +175,7 @@ del path[-1] else: tail.insert(0, pdir) - return apply(os.path.join, tail) + return os.path.join(self.src_dir,apply(os.path.join, tail)) else: # Oops, got all the way through 'path' without finding a # match in package_dir. If package_dir defines a directory @@ -183,9 +189,9 @@ tail.insert(0, pdir) if tail: - return apply(os.path.join, tail) + return os.path.join(self.src_dir,apply(os.path.join, tail)) else: - return '' + return self.src_dir # get_package_dir () @@ -198,8 +204,11 @@ # circumvent them. if package_dir != "": if not os.path.exists(package_dir): - raise DistutilsFileError, \ + if self.src_dir != ".": + raise DistutilsFileError, \ "package directory '%s' does not exist" % package_dir + else: + os.makedirs(package_dir) if not os.path.isdir(package_dir): raise DistutilsFileError, \ ("supposed package directory '%s' exists, " +