summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-05 16:35:45 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2009-02-05 16:35:45 (GMT)
commit014bf28ef109302a4254bfd10f25f4526aa0617d (patch)
tree6cf082d8a35f24fcdab3ad5bf76dc0a7251c5a96
parentc03a2881813f1f72c4e1dd7e81d0abe68084adb7 (diff)
downloadcpython-014bf28ef109302a4254bfd10f25f4526aa0617d.zip
cpython-014bf28ef109302a4254bfd10f25f4526aa0617d.tar.gz
cpython-014bf28ef109302a4254bfd10f25f4526aa0617d.tar.bz2
Make setup.py work when building in a directory other than the
source directory. Mainly, use 'srcdir' rather than os.getcwd() or '.'.
-rw-r--r--setup.py33
1 files changed, 9 insertions, 24 deletions
diff --git a/setup.py b/setup.py
index 174a8b2..ff37bc4 100644
--- a/setup.py
+++ b/setup.py
@@ -112,51 +112,36 @@ class PyBuildExt(build_ext):
self.extensions = extensions
# Fix up the autodetected modules, prefixing all the source files
- # with Modules/ and adding Python's include directory to the path.
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ # with Modules/.
+ srcdir = sysconfig.get_config_var('srcdir')
if not srcdir:
# Maybe running on Windows but not using CYGWIN?
raise ValueError("No source directory; cannot proceed.")
-
- # Figure out the location of the source code for extension modules
- # (This logic is copied in distutils.test.test_sysconfig,
- # so building in a separate directory does not break test_distutils.)
- moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
- moddir = os.path.normpath(moddir)
- srcdir, tail = os.path.split(moddir)
srcdir = os.path.normpath(srcdir)
- moddir = os.path.normpath(moddir)
-
- moddirlist = [moddir]
- incdirlist = ['./Include']
+ moddirlist = [os.path.join(srcdir, 'Modules')]
# Platform-dependent module source and include directories
platform = self.get_platform()
- alldirlist = moddirlist + incdirlist
-
# Fix up the paths for scripts, too
self.distribution.scripts = [os.path.join(srcdir, filename)
for filename in self.distribution.scripts]
# Python header files
- headers = glob("Include/*.h") + ["pyconfig.h"]
+ headers = [sysconfig.get_config_h_filename()]
+ headers += glob(os.path.join(sysconfig.get_python_inc(), "*.h"))
for ext in self.extensions[:]:
ext.sources = [ find_module_file(filename, moddirlist)
for filename in ext.sources ]
if ext.depends is not None:
- ext.depends = [find_module_file(filename, alldirlist)
+ ext.depends = [find_module_file(filename, moddirlist)
for filename in ext.depends]
else:
ext.depends = []
# re-compile extensions if a header file has been changed
ext.depends.extend(headers)
- ext.include_dirs.append( '.' ) # to get config.h
- for incdir in incdirlist:
- ext.include_dirs.append( os.path.join(srcdir, incdir) )
-
# If a module has already been built statically,
# don't build it here
if ext.name in sys.builtin_module_names:
@@ -368,7 +353,7 @@ class PyBuildExt(build_ext):
config_h_vars = sysconfig.parse_config_h(open(config_h))
platform = self.get_platform()
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ srcdir = sysconfig.get_config_var('srcdir')
# Check for AtheOS which has libraries in non-standard locations
if platform == 'atheos':
@@ -1285,7 +1270,7 @@ class PyBuildExt(build_ext):
def configure_ctypes_darwin(self, ext):
# Darwin (OS X) uses preconfigured files, in
# the Modules/_ctypes/libffi_osx directory.
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ srcdir = sysconfig.get_config_var('srcdir')
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
'_ctypes', 'libffi_osx'))
sources = [os.path.join(ffi_srcdir, p)
@@ -1314,7 +1299,7 @@ class PyBuildExt(build_ext):
if sys.platform == 'darwin':
return self.configure_ctypes_darwin(ext)
- (srcdir,) = sysconfig.get_config_vars('srcdir')
+ srcdir = sysconfig.get_config_var('srcdir')
ffi_builddir = os.path.join(self.build_temp, 'libffi')
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
'_ctypes', 'libffi'))