[Numpy-svn] r4061 - in branches/numpy.scons/numpy: distutils/command scons_fake

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Sep 20 13:34:41 EDT 2007


Author: cdavid
Date: 2007-09-20 12:34:32 -0500 (Thu, 20 Sep 2007)
New Revision: 4061

Modified:
   branches/numpy.scons/numpy/distutils/command/scons.py
   branches/numpy.scons/numpy/scons_fake/SConstruct
Log:
First working sconsified shared library, but with lot of manual work inside Scons

Modified: branches/numpy.scons/numpy/distutils/command/scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-20 13:17:21 UTC (rev 4060)
+++ branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-20 17:34:32 UTC (rev 4061)
@@ -1,31 +1,47 @@
 import os
 import os.path
 
-from distutils.core import Command
+#from distutils.core import build_py as old_build_py
+from distutils.command.build_ext import build_ext as old_build_py
 from numpy.distutils.ccompiler import CCompiler
 
 # XXX: this is super ugly. The object/source filenames generations is handled
-# inside compiler classes in distutils, so to get the same convention, we
-# instantiate a CCompiler object, which will not be used for compilation at
-# all.
-class scons(Command):
+# inside compiler classes and build_ext in distutils, so to get the same
+# convention, we derive scons command from build_ext instead of just Command.
+class scons(old_build_py):
     description = "Scons builder"
     user_options = []
 
     def initialize_options(self):
+        old_build_py.initialize_options(self)
         pass
 
     def finalize_options(self):
+        old_build_py.finalize_options(self)
         if self.distribution.has_scons_scripts():
             print "Got it: scons scripts are %s" % self.distribution.scons_scripts
             self.scons_scripts = self.distribution.scons_scripts
+        #        build_py = self.get_finalized_command('build_py')
+        #print "!!!!!!!!!!!!!!!!!!"
+        #print self.build_temp
+        #print self.build_lib
+        #print self.package
 
     def run(self):
         # XXX: when a scons script is missing, scons only prints warnings, and
         # does not return a failure (status is 0). We have to detect this from
         # distutils (this cannot work for recursive scons builds...)
         for i in self.scons_scripts:
-            print "Basename for %s is %s" % (i, os.path.dirname(i))
+            #print "For sconscript %s" % i
+            #print "\tbuild dir (object files) is %s" % \
+            #    os.path.join(self.build_temp, os.path.dirname(i))
+            #print "\ttarget dir (.so files) is %s" % \
+            #    os.path.join(self.build_lib, os.path.dirname(i))
+            #print "Basename for %s is %s" % (i, os.path.dirname(i))
             cmd = "scons -f " + i + ' -I. '
+            cmd += ' src_prefix=%s ' % os.path.dirname(i)
+            cmd += ' obj_prefix=%s ' % os.path.join(self.build_temp, os.path.dirname(i))
+            cmd += ' lib_prefix=%s ' % os.path.join(self.build_lib, os.path.dirname(i))
             st = os.system(cmd)
-            print "status is %d" % st
+            if st:
+                print "status is %d" % st

Modified: branches/numpy.scons/numpy/scons_fake/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-20 13:17:21 UTC (rev 4060)
+++ branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-20 17:34:32 UTC (rev 4061)
@@ -1,3 +1,19 @@
+# vim:syntax=python
+import os.path
+
 env = Environment()
+src_prefix = ARGUMENTS.get('src_prefix', '')
+obj_prefix = ARGUMENTS.get('obj_prefix', '')
+lib_prefix = ARGUMENTS.get('lib_prefix', '')
 
-env.Library('foo', source = ['foo.c'])
+source = ['foo.c']
+object = ['foo']
+if len(src_prefix):
+    source = [os.path.join(src_prefix, i) for i in source]
+if len(src_prefix):
+    object = [os.path.join(obj_prefix, i) for i in object]
+
+onodes = []
+for i in range(len(source)):
+    onodes.append(env.SharedObject(object[i], source = [source[i]]))
+env.SharedLibrary(os.path.join(lib_prefix, 'foo'), onodes)




More information about the Numpy-svn mailing list