[Python-checkins] python/dist/src Makefile.pre.in, 1.148, 1.149 setup.py, 1.204, 1.205

bcannon at users.sourceforge.net bcannon at users.sourceforge.net
Tue Dec 7 01:43:02 CET 2004


Update of /cvsroot/python/python/dist/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5745

Modified Files:
	Makefile.pre.in setup.py 
Log Message:
setup.py now uses the library directories specified in LDFLAGS (``-L``
directories) and the include directories specified in CPPFLAGS (``-I``
directories) for compiling the extension modules.

This has led to the core being compiled with the values in the shell's
CPPFLAGS.  It has also removed the need for special casing to use Fink and
DarwinPorts under darwin since the needed directories can now be specified in
LDFLAGS and CPPFLAGS (e.g., DarwinPorts users can now do
``LDFLAGS=-L/opt/local/lib; CPPFLAGS=-I/opt/local/include; ./configure`` for
everything to work properly).

Parsing the values in the environment variables is done with getopt.  While optparse
would have been a nicer solution it cannot be used because of dependency issues
at execution time; optparse uses gettext which uses struct which will not have
been compiled when the code is imported.  If optparse ever makes its
importation of gettext optional by catching ImportError and setting _() to an
identity function then it can be used.


Index: Makefile.pre.in
===================================================================
RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- Makefile.pre.in	26 Sep 2004 17:26:55 -0000	1.148
+++ Makefile.pre.in	7 Dec 2004 00:42:58 -0000	1.149
@@ -56,7 +56,10 @@
 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@

Index: setup.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/setup.py,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -d -r1.204 -r1.205
--- setup.py	13 Nov 2004 11:13:34 -0000	1.204
+++ setup.py	7 Dec 2004 00:42:58 -0000	1.205
@@ -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 @@
         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,



More information about the Python-checkins mailing list