summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.pre.in5
-rw-r--r--Misc/NEWS9
-rw-r--r--setup.py27
3 files changed, 31 insertions, 10 deletions
diff --git a/Makefile.pre.in b/Makefile.pre.in
index d1ea4e2..16cb0fa 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -56,7 +56,10 @@ MAKESETUP= $(srcdir)/Modules/makesetup
OPT= @OPT@
BASECFLAGS= @BASECFLAGS@
CFLAGS= $(BASECFLAGS) $(OPT)
-CPPFLAGS= -I. -I$(srcdir)/Include
+# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
+# be able to build extension modules using the directories specified in the
+# environment variables
+CPPFLAGS= -I. -I$(srcdir)/Include @CPPFLAGS@
LDFLAGS= @LDFLAGS@
LDLAST= @LDLAST@
SGI_ABI= @SGI_ABI@
diff --git a/Misc/NEWS b/Misc/NEWS
index 784e782..380bf9a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -50,6 +50,15 @@ Library
Build
-----
+- setup.py now uses the directories specified in LDFLAGS using the -L option
+ and in CPPFLAGS using the -I option for adding library and include
+ directories, respectively, for compiling extension modules against. This has
+ led to the core being compiled using the values in CPPFLAGS. It also removes
+ the need for the special-casing of both DarwinPorts and Fink for darwin since
+ the proper directories can be specified in LDFLAGS (``-L/sw/lib`` for Fink,
+ ``-L/opt/local/lib`` for DarwinPorts) and CPPFLAGS (``-I/sw/include`` for
+ Fink, ``-I/opt/local/include`` for DarwinPorts).
+
C API
-----
diff --git a/setup.py b/setup.py
index 08d951e..c9f94ab 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
__version__ = "$Revision$"
-import sys, os, getopt, imp, re
+import sys, os, imp, re, getopt
from distutils import log
from distutils import sysconfig
@@ -242,14 +242,23 @@ class PyBuildExt(build_ext):
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
- # Add paths to popular package managers on OS X/darwin
- if sys.platform == "darwin":
- # Fink installs into /sw by default
- add_dir_to_list(self.compiler.library_dirs, '/sw/lib')
- add_dir_to_list(self.compiler.include_dirs, '/sw/include')
- # DarwinPorts installs into /opt/local by default
- add_dir_to_list(self.compiler.library_dirs, '/opt/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/opt/local/include')
+ # Add paths specified in the environment variables LDFLAGS and
+ # CPPFLAGS.
+ # Since this file tends to be executed by ``make install`` its
+ # environment variables are those that the Makefile sets and not what
+ # the shell has. The Makefile must keep the shell's values somewhere
+ # in order to be able to reach them at execution time.
+ for env_var, arg_name, dir_list in (
+ ('LDFLAGS', '-L', self.compiler.library_dirs),
+ ('CPPFLAGS', '-I', self.compiler.include_dirs)):
+ env_val = os.getenv(env_var)
+ if env_val:
+ # getopt is used instead of optparse because the latter imports
+ # gettext which imports struct which has not been built yet
+ # when this method is needed
+ options = getopt.getopt(env_val.split(), arg_name[1] + ':')[0]
+ for arg_option, directory in options:
+ add_dir_to_list(dir_list, directory)
if os.path.normpath(sys.prefix) != '/usr':
add_dir_to_list(self.compiler.library_dirs,