[Numpy-svn] r4681 - branches/build_with_scons/numpy/distutils

numpy-svn@scip... numpy-svn@scip...
Sun Jan 6 04:33:04 CST 2008


Author: cdavid
Date: 2008-01-06 04:33:00 -0600 (Sun, 06 Jan 2008)
New Revision: 4681

Modified:
   branches/build_with_scons/numpy/distutils/misc_util.py
Log:

Add the infrastructure to add SConstruct files in
numpy.distutils.Configuration.



Modified: branches/build_with_scons/numpy/distutils/misc_util.py
===================================================================
--- branches/build_with_scons/numpy/distutils/misc_util.py	2008-01-06 10:32:14 UTC (rev 4680)
+++ branches/build_with_scons/numpy/distutils/misc_util.py	2008-01-06 10:33:00 UTC (rev 4681)
@@ -574,7 +574,7 @@
 class Configuration(object):
 
     _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs',
-                  'libraries', 'headers', 'scripts', 'py_modules']
+                  'libraries', 'headers', 'scripts', 'py_modules', 'scons_data']
     _dict_keys = ['package_dir']
     _extra_keys = ['name', 'version']
 
@@ -1165,6 +1165,50 @@
             self.warn('distutils distribution has been initialized,'\
                       ' it may be too late to add a library '+ name)
 
+    def add_sconscript(self, sconscript, subpackage_path=None,
+                       standalone = False, pre_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
+        use before and after executing scons. """
+        if standalone:
+            parent_name = None
+        else:
+            parent_name = self.name
+
+        dist = self.get_distribution()
+        # Convert the sconscript name to a relative filename (relative from top
+        # setup.py's directory)
+        fullsconsname = self.paths(sconscript)[0]
+
+        # XXX: Think about a way to automatically register source files from
+        # scons...
+        full_source_files = []
+        if source_files:
+            full_source_files.extend([self.paths(i)[0] for i in source_files])
+
+        if dist is not None:
+            dist.scons_data.append((fullsconsname, 
+                                    pre_hook, 
+                                    post_hook,
+                                    full_source_files,
+                                    parent_name))
+            self.warn('distutils distribution has been initialized,'\
+                      ' it may be too late to add a subpackage '+ subpackage_name)
+            # XXX: we add a fake extension, to correctly initialize some
+            # options in distutils command.
+            dist.add_extension('', sources = [])
+        else:
+            self.scons_data.append((fullsconsname, 
+                                    pre_hook, 
+                                    post_hook,
+                                    full_source_files,
+                                    parent_name))
+            # XXX: we add a fake extension, to correctly initialize some
+            # options in distutils command.
+            self.add_extension('', sources = [])
+
     def add_scripts(self,*files):
         """Add scripts to configuration.
         """



More information about the Numpy-svn mailing list