[Numpy-svn] r3825 - trunk/numpy/distutils/command

numpy-svn at scipy.org numpy-svn at scipy.org
Fri May 25 07:41:56 EDT 2007


Author: cookedm
Date: 2007-05-25 06:41:55 -0500 (Fri, 25 May 2007)
New Revision: 3825

Modified:
   trunk/numpy/distutils/command/build_src.py
Log:
merge from distutils-revamp branch (step 3)
- minor command/build_src cleanup


Modified: trunk/numpy/distutils/command/build_src.py
===================================================================
--- trunk/numpy/distutils/command/build_src.py	2007-05-25 11:41:16 UTC (rev 3824)
+++ trunk/numpy/distutils/command/build_src.py	2007-05-25 11:41:55 UTC (rev 3825)
@@ -10,6 +10,15 @@
 from distutils.util import get_platform
 from distutils.errors import DistutilsError, DistutilsSetupError
 
+try:
+    from Pyrex.Compiler import Main
+    have_pyrex = True
+except ImportError:
+    have_pyrex = False
+
+# this import can't be done here, as it uses numpy stuff only available
+# after it's installed
+#import numpy.f2py
 from numpy.distutils import log
 from numpy.distutils.misc_util import fortran_ext_match, \
      appendpath, is_string, is_sequence
@@ -56,7 +65,6 @@
         self.swig_opts = None
         self.swig_cpp = None
         self.swig = None
-        return
 
     def finalize_options(self):
         self.set_undefined_options('build',
@@ -95,7 +103,7 @@
                 self.swig_opts = self.swigflags
             self.swigflags = None
 
-        if self.swig_opts is None: 
+        if self.swig_opts is None:
             self.swig_opts = []
         else:
             self.swig_opts = splitcmdline(self.swig_opts)
@@ -115,20 +123,17 @@
                 else:
                     log.info('using "%s=%s" option from build_ext command' % (o,v))
                     setattr(self, c, v)
-        return
 
     def run(self):
         if not (self.extensions or self.libraries):
             return
         self.build_sources()
 
-        return
-
     def build_sources(self):
 
         if self.inplace:
-            self.get_package_dir = self.get_finalized_command('build_py')\
-                                   .get_package_dir
+            self.get_package_dir = \
+                     self.get_finalized_command('build_py').get_package_dir
 
         self.build_py_modules_sources()
 
@@ -143,8 +148,6 @@
 
         self.build_data_files_sources()
 
-        return
-
     def build_data_files_sources(self):
         if not self.data_files:
             return
@@ -179,7 +182,6 @@
             else:
                 raise TypeError(repr(data))
         self.data_files[:] = new_data_files
-        return
 
     def build_py_modules_sources(self):
         if not self.py_modules:
@@ -206,7 +208,6 @@
             else:
                 new_py_modules.append(source)
         self.py_modules[:] = new_py_modules
-        return
 
     def build_library_sources(self, lib_name, build_info):
         sources = list(build_info.get('sources',[]))
@@ -274,8 +275,6 @@
 
         ext.sources = sources
 
-        return
-
     def generate_sources(self, sources, extension):
         new_sources = []
         func_sources = []
@@ -370,12 +369,6 @@
         return new_sources
 
     def pyrex_sources(self, sources, extension):
-        have_pyrex = False
-        try:
-            import Pyrex
-            have_pyrex = True
-        except ImportError:
-            pass
         new_sources = []
         ext_name = extension.name.split('.')[-1]
         for source in sources:
@@ -485,8 +478,9 @@
             if (self.force or newer_group(depends, target_file,'newer')) \
                    and not skip_f2py:
                 log.info("f2py: %s" % (source))
-                import numpy.f2py as f2py2e
-                f2py2e.run_main(f2py_options + ['--build-dir',target_dir,source])
+                import numpy.f2py
+                numpy.f2py.run_main(f2py_options
+                                    + ['--build-dir',target_dir,source])
             else:
                 log.debug("  skipping '%s' f2py interface (up-to-date)" % (source))
         else:
@@ -501,10 +495,10 @@
             depends = f_sources + extension.depends
             if (self.force or newer_group(depends, target_file, 'newer')) \
                    and not skip_f2py:
-                import numpy.f2py as f2py2e
                 log.info("f2py:> %s" % (target_file))
                 self.mkpath(target_dir)
-                f2py2e.run_main(f2py_options + ['--lower',
+                import numpy.f2py
+                numpy.f2py.run_main(f2py_options + ['--lower',
                                                 '--build-dir',target_dir]+\
                                 ['-m',ext_name]+f_sources)
             else:
@@ -524,8 +518,8 @@
             extension.include_dirs.append(self.build_src)
 
         if not skip_f2py:
-            import numpy.f2py as f2py2e
-            d = os.path.dirname(f2py2e.__file__)
+            import numpy.f2py
+            d = os.path.dirname(numpy.f2py.__file__)
             source_c = os.path.join(d,'src','fortranobject.c')
             source_h = os.path.join(d,'src','fortranobject.h')
             if newer(source_c,target_c) or newer(source_h,target_h):




More information about the Numpy-svn mailing list