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

numpy-svn@scip... numpy-svn@scip...
Thu Sep 20 08:17:41 CDT 2007


Author: cdavid
Date: 2007-09-20 08:17:21 -0500 (Thu, 20 Sep 2007)
New Revision: 4060

Added:
   branches/numpy.scons/numpy/scons_fake/SConstruct
   branches/numpy.scons/numpy/scons_fake/foo.c
Modified:
   branches/numpy.scons/
   branches/numpy.scons/numpy/distutils/command/build_ext.py
   branches/numpy.scons/numpy/distutils/command/scons.py
   branches/numpy.scons/numpy/distutils/misc_util.py
   branches/numpy.scons/numpy/scons_fake/setup.py
Log:
Random hacks/experiments to understand how distutils create/pass build dir and source dir values


Property changes on: branches/numpy.scons
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2007-09-20 17:26:41.709000111 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

   + timestamp: 2007-09-20 22:07:30.914000034 +0900
committer: David Cournapeau <david@ar.media.kyoto-u.ac.jp>
properties: 
	branch-nick: numpy.scons

Name: bzr:file-ids
   - numpy/scons_fake/SConstruct	sconstruct-20070920082558-qarsz8evm38aeo1q-1

   + numpy/scons_fake/SConstruct	sconstruct-20070920125938-jw3np1dk1gtr5a4s-1
numpy/scons_fake/foo.f	foo.f-20070920125945-d65hghrwpt9bnt0m-1
numpy/scons_fake/foo.c	foo.c-20070920125943-f6sf0rnbhik75mtj-1

Name: bzr:revision-id:v3-trunk0
   - 3737 david@david-laptop-20070920080908-n8pj8vmszdir3zoa
3738 david@david-laptop-20070920081509-58kkojgmml3t7jxs
3739 david@david-laptop-20070920081910-phlk1ujthksgpm0z
3740 david@david-laptop-20070920082641-bdhrt6eafeoli50i

   + 3737 david@david-laptop-20070920080908-n8pj8vmszdir3zoa
3738 david@david-laptop-20070920081509-58kkojgmml3t7jxs
3739 david@david-laptop-20070920081910-phlk1ujthksgpm0z
3740 david@david-laptop-20070920082641-bdhrt6eafeoli50i
3741 david@ar.media.kyoto-u.ac.jp-20070920130730-satdeppbh1k0bq2p


Modified: branches/numpy.scons/numpy/distutils/command/build_ext.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/build_ext.py	2007-09-20 12:36:04 UTC (rev 4059)
+++ branches/numpy.scons/numpy/distutils/command/build_ext.py	2007-09-20 13:17:21 UTC (rev 4060)
@@ -295,6 +295,8 @@
                   "but no C++ linker found, using default linker" % (ext.name))
 
         kws = {'depends':ext.depends}
+        print "===================================="
+        print "tmp build dir is %s" % self.build_temp
         output_dir = self.build_temp
 
         include_dirs = ext.include_dirs + get_numpy_include_dirs()

Modified: branches/numpy.scons/numpy/distutils/command/scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-20 12:36:04 UTC (rev 4059)
+++ branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-20 13:17:21 UTC (rev 4060)
@@ -1,5 +1,13 @@
+import os
+import os.path
+
 from distutils.core import Command
+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):
     description = "Scons builder"
     user_options = []
@@ -17,7 +25,7 @@
         # 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))
             cmd = "scons -f " + i + ' -I. '
-            import os
             st = os.system(cmd)
             print "status is %d" % st

Modified: branches/numpy.scons/numpy/distutils/misc_util.py
===================================================================
--- branches/numpy.scons/numpy/distutils/misc_util.py	2007-09-20 12:36:04 UTC (rev 4059)
+++ branches/numpy.scons/numpy/distutils/misc_util.py	2007-09-20 13:17:21 UTC (rev 4060)
@@ -1178,6 +1178,8 @@
             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)
         
         if dist is not None:

Added: branches/numpy.scons/numpy/scons_fake/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-20 12:36:04 UTC (rev 4059)
+++ branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-20 13:17:21 UTC (rev 4060)
@@ -0,0 +1,3 @@
+env = Environment()
+
+env.Library('foo', source = ['foo.c'])

Added: branches/numpy.scons/numpy/scons_fake/foo.c
===================================================================
--- branches/numpy.scons/numpy/scons_fake/foo.c	2007-09-20 12:36:04 UTC (rev 4059)
+++ branches/numpy.scons/numpy/scons_fake/foo.c	2007-09-20 13:17:21 UTC (rev 4060)
@@ -0,0 +1,4 @@
+int foo(void)
+{
+        return 0;
+}

Modified: branches/numpy.scons/numpy/scons_fake/setup.py
===================================================================
--- branches/numpy.scons/numpy/scons_fake/setup.py	2007-09-20 12:36:04 UTC (rev 4059)
+++ branches/numpy.scons/numpy/scons_fake/setup.py	2007-09-20 13:17:21 UTC (rev 4060)
@@ -1,9 +1,46 @@
+import os
+import os.path
 
+def get_object_names(source_filenames, strip_dir=0, output_dir=''):
+    # ripped off distutilc.ccompiler (CCompiler_object_filenames)
+    if output_dir is None:
+        output_dir = ''
+    obj_names = []
+    for src_name in source_filenames:
+        base, ext = os.path.splitext(os.path.normpath(src_name))
+        base = os.path.splitdrive(base)[1] # Chop off the drive
+        base = base[os.path.isabs(base):]  # If abs, chop off leading /
+        if base.startswith('..'):
+            # Resolve starting relative path components, middle ones
+            # (if any) have been handled by os.path.normpath above.
+            i = base.rfind('..')+2
+            d = base[:i]
+            d = os.path.basename(os.path.abspath(d))
+            base = d + base[i:]
+        #XXX: how to know which file types are supported ?
+        #if ext not in self.src_extensions:
+        #    raise UnknownFileError, \
+        #          "unknown file type '%s' (from '%s')" % (ext, src_name)
+        if strip_dir:
+            base = os.path.basename(base)
+        #XXX: change '.o' to something like obj_extension 
+        obj_name = os.path.join(output_dir,base + '.o')
+        obj_names.append(obj_name)
+    return obj_names
+
 def configuration(parent_package='',top_path=None):
     from numpy.distutils.misc_util import Configuration
     from numpy.distutils.system_info import get_info
     config = Configuration('scons_fake',parent_package,top_path)
 
+    print "==================================================="
+    print "parent package is %s, top path %s" % (parent_package, top_path)
+    print "THIS package is %s" % config.name
+    print "THIS package path is %s" % config.package_path
+    #print get_object_names(['foo.c'])
+
+    #config.add_library('_fortran_foo',
+    #                   sources=['foo.f'])
     config.add_sconscript('SConstruct')
     return config
 



More information about the Numpy-svn mailing list