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

numpy-svn@scip... numpy-svn@scip...
Tue Oct 30 02:13:35 CDT 2007


Author: cdavid
Date: 2007-10-30 02:13:30 -0500 (Tue, 30 Oct 2007)
New Revision: 4350

Modified:
   branches/numpy.scons/numpy/distutils/command/scons.py
   branches/numpy.scons/numpy/distutils/misc_util.py
   branches/numpy.scons/numpy/distutils/numpy_distribution.py
Log:

- Clean up a bit NumpyDistribution, to avoid accessing directly distribution
  data in scons command
- Add a source_file argument, to enable adding source files used in SConscripts
  and unknown to distutils (not implemented yet)



Modified: branches/numpy.scons/numpy/distutils/command/scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/scons.py	2007-10-30 06:44:56 UTC (rev 4349)
+++ branches/numpy.scons/numpy/distutils/command/scons.py	2007-10-30 07:13:30 UTC (rev 4350)
@@ -140,9 +140,11 @@
         old_build_ext.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
+            self.sconscripts = self.distribution.get_scons_scripts()
+            self.post_hooks = self.distribution.get_scons_post_hooks()
         else:
-            self.scons_scripts = []
+            self.sconscripts = []
+            self.post_hooks = []
 
         # Try to get the same compiler than the ones used by distutils: this is
         # non trivial because distutils and scons have totally different
@@ -183,7 +185,9 @@
 
         scons_exec = get_python_exec_invoc()
         scons_exec += ' ' + protect_path(pjoin(get_scons_local_path(), 'scons.py'))
-        for sconscript, pre_hook, post_hook in self.scons_scripts:
+
+        # XXX handle pre hoook
+        for sconscript, post_hook in zip(self.sconscripts, self.post_hooks):
             # XXX: This is inefficient... (use join instead)
             from numpy.distutils.misc_util import get_numpy_include_dirs
             cmd = scons_exec + " -f " + sconscript + ' -I. '

Modified: branches/numpy.scons/numpy/distutils/misc_util.py
===================================================================
--- branches/numpy.scons/numpy/distutils/misc_util.py	2007-10-30 06:44:56 UTC (rev 4349)
+++ branches/numpy.scons/numpy/distutils/misc_util.py	2007-10-30 07:13:30 UTC (rev 4350)
@@ -575,7 +575,7 @@
 class Configuration(object):
 
     _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
-                  'libraries', 'headers', 'scripts', 'py_modules', 'scons_scripts']
+                  'libraries', 'headers', 'scripts', 'py_modules', 'scons_data']
     _dict_keys = ['package_dir']
     _extra_keys = ['name', 'version']
 
@@ -1173,7 +1173,8 @@
                        subpackage_path=None,
                        standalone = False,
                        pre_hook = None,
-                       post_hook = None):
+                       post_hook = None,
+                       source_files = None):
         """Add a sconscript to configuration.
 
         pre_hook and post hook should be sequences of callable, which will be
@@ -1188,13 +1189,21 @@
         # Convert the sconscript name to a relative filename (relative from top
         # setup.py's directory)
         fullsconsname = self.paths(sconscript)[0]
-        
+        if source_files:
+            full_source_files = [self.paths(i)[0] for i in source_files]
+
         if dist is not None:
-            dist.scons_scripts.extend((fullsconsname, pre_hook, post_hook))
+            dist.scons_data.append((fullsconsname, 
+                                    pre_hook, 
+                                    post_hook,
+                                    source_files))
             self.warn('distutils distribution has been initialized,'\
                       ' it may be too late to add a subpackage '+ subpackage_name)
         else:
-            self.scons_scripts.append((fullsconsname, pre_hook, post_hook))
+            self.scons_data.append((fullsconsname, 
+                                    pre_hook, 
+                                    post_hook,
+                                    source_files))
 
     def add_scripts(self,*files):
         """Add scripts to configuration.

Modified: branches/numpy.scons/numpy/distutils/numpy_distribution.py
===================================================================
--- branches/numpy.scons/numpy/distutils/numpy_distribution.py	2007-10-30 06:44:56 UTC (rev 4349)
+++ branches/numpy.scons/numpy/distutils/numpy_distribution.py	2007-10-30 07:13:30 UTC (rev 4350)
@@ -1,12 +1,27 @@
+# XXX: Handle setuptools ?
 from distutils.core import Distribution
 
+# This class is used because we add new files (sconscripts, and so on) with the
+# scons command
 class NumpyDistribution(Distribution):
     def __init__(self, attrs = None):
-        self.scons_scripts = []
+        # A list of (sconscripts, pre_hook, post_hook, src)
+        self.scons_data = []
         Distribution.__init__(self, attrs)
 
     def has_scons_scripts(self):
-        return bool(self.scons_scripts)
+        return bool(self.scons_data)
 
     def get_scons_scripts(self):
-        return [i[0] for i in self.scons_scripts]
+        print self.scons_data
+        return [i[0] for i in self.scons_data]
+
+    def get_scons_pre_hooks(self):
+        return [i[1] for i in self.scons_data]
+
+    def get_scons_post_hooks(self):
+        return [i[2] for i in self.scons_data]
+
+    def get_scons_sources(self):
+        return [i[3] for i in self.scons_data]
+



More information about the Numpy-svn mailing list