[MOAB-dev] r2934 - MOAB/trunk/tools/iMesh/python

jvporter at wisc.edu jvporter at wisc.edu
Mon Jun 8 17:31:34 CDT 2009


Author: jvporter
Date: 2009-06-08 17:31:27 -0500 (Mon, 08 Jun 2009)
New Revision: 2934

Modified:
   MOAB/trunk/tools/iMesh/python/setup.py
Log:
Add support for PyTAPS performance testing from setup.py


Modified: MOAB/trunk/tools/iMesh/python/setup.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/setup.py	2009-06-05 21:37:21 UTC (rev 2933)
+++ MOAB/trunk/tools/iMesh/python/setup.py	2009-06-08 22:31:27 UTC (rev 2934)
@@ -10,14 +10,13 @@
 # 'extra_link_args' for unknown reasons
 iMesh_libs = []
 iMesh_libdirs = []
+iMesh_incs = []
 compileargs = ''
 
 if 'IMESHPATH' in os.environ:
     defs = parse_makefile( os.path.join(os.environ['IMESHPATH'],
                                         'lib/iMesh-Defs.inc') )
 
-    compileargs = defs['IMESH_INCLUDES']
-
     lib_match = re.compile(r'(?:(?<=\s)|^)-([lL])\s*(\S*)')
     for match in lib_match.finditer( defs['IMESH_LIBS'] ):
         if match.group(1) == 'l':
@@ -25,20 +24,24 @@
         elif match.group(1) == 'L':
             iMesh_libdirs.append( match.group(2) )
 
+    inc_match = re.compile(r'(?:(?<=\s|^)-(I)\s*(\S*)')
+    for match in defs['IMESH_INCLUDES']:
+        iMesh_incs.append( match.group(2) )
+
 iBase = Extension('itaps.iBase',
-                  extra_compile_args = [ compileargs ],
-                  depends = ['common.h', 'iBase_Python.h'],
-                  sources = ['iBase.c']
+                  include_dirs = iMesh_incs,
+                  depends      = ['common.h', 'iBase_Python.h'],
+                  sources      = ['iBase.c']
                   )
 
 iMesh = Extension('itaps.iMesh',
-                  extra_compile_args = [ compileargs ],
-                  libraries = iMesh_libs,
+                  include_dirs = iMesh_incs,
+                  libraries    = iMesh_libs,
                   library_dirs = iMesh_libdirs,
-                  depends = ['common.h', 'iMesh_Python.h', 'iBase_Python.h',
-                             'errors.h'],
-                  sources = ['iMesh.c', 'iMesh_iter.c', 'iMesh_entSet.c',
-                             'iMesh_tag.c']
+                  depends      = ['common.h', 'iMesh_Python.h',
+                                  'iBase_Python.h', 'errors.h'],
+                  sources      = ['iMesh.c', 'iMesh_iter.c', 'iMesh_entSet.c',
+                                  'iMesh_tag.c']
                   )
 
 class TestCommand(Command):
@@ -57,8 +60,8 @@
             raise DistutilsOptionError('"verbosity" option must be an integer')
 
     def run(self):
-        root = os.path.normpath(os.path.join(
-                os.path.abspath(sys.argv[0]), '../test'))
+        root = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+                                             '../test'))
         old = os.getcwd()
         tests = []
         regex = re.compile(r'^(.*).py$')
@@ -78,40 +81,74 @@
     description = 'Build documentation'
     user_options = [
         ('builder=', 'b', 'documentation builder'),
-        ('target=', 't', 'target directory')
+        ('target=',  't', 'target directory')
         ]
 
     def initialize_options(self):
         self.builder = 'html'
         self.target = None
-        self.root = os.path.normpath(os.path.join(
-                os.path.abspath(sys.argv[0]), '../doc'))
 
     def finalize_options(self):
-        if not self.target:
+        if self.target:
+            self.target = os.path.abspath(self.target)
+        else:
             self.target = '_build/' + self.builder
-        self.target = os.path.abspath(os.path.join(self.root, self.target))
 
     def run(self):
+        root = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+                                             '../doc'))
         old = os.getcwd()
 
-        os.chdir(self.root)
+        os.chdir(root)
         os.system('sphinx-build -b "%s" -d _build/doctrees . "%s"' %
                   (self.builder, self.target))
         os.chdir(old)        
 
+class PerfCommand(Command):
+    description = 'Execute performance tests'
+    user_options = [
+        ('file=',  'f', 'test file'),
+        ('count=', 'c', 'number of times to test')
+        ]
 
+    def initialize_options(self):
+        self.file = None
+        self.count = 20
+
+    def finalize_options(self):
+        if not self.file:
+            raise DistutilsOptionError('"file" must be specified')
+
+        try:
+            self.count = int(self.count)
+        except ValueError:
+            raise DistutilsOptionError('"count" option must be an integer')
+
+    def run(self):
+        root = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+                                             '../perf'))
+        old = os.getcwd()
+
+        os.chdir(root)
+        os.system('make all')
+        os.system('python perf.py -c%d "%s"' % (self.count, self.file))
+        os.chdir(old)
+
 setup(name = 'PyTAPS',
       version = '1.0b1',
       description = 'Python bindings for iBase and iMesh interfaces',
       author = 'Jim Porter',
       author_email = 'jvporter at wisc.edu',
 
+      requires = ['numpy'],
+      provides = ['itaps'],
+
       package_dir = {'itaps': 'pkg'},
       packages = ['itaps'],
       ext_modules = [iBase, iMesh],
       py_modules = ['itaps.helpers'],
 
       cmdclass = { 'test' : TestCommand,
-                   'doc'  : DocCommand }
+                   'doc'  : DocCommand,
+                   'perf' : PerfCommand }
       )



More information about the moab-dev mailing list