[MOAB-dev] r2939 - in MOAB/trunk/tools/iMesh/python: . doc

jvporter at wisc.edu jvporter at wisc.edu
Tue Jun 9 15:00:29 CDT 2009


Author: jvporter
Date: 2009-06-09 15:00:28 -0500 (Tue, 09 Jun 2009)
New Revision: 2939

Modified:
   MOAB/trunk/tools/iMesh/python/doc/build.rst
   MOAB/trunk/tools/iMesh/python/setup.py
Log:
Simplify build process by injecting "--imesh-path" as a command option


Modified: MOAB/trunk/tools/iMesh/python/doc/build.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/build.rst	2009-06-09 13:55:32 UTC (rev 2938)
+++ MOAB/trunk/tools/iMesh/python/doc/build.rst	2009-06-09 20:00:28 UTC (rev 2939)
@@ -8,14 +8,17 @@
 additional setup.
 
 The PyTAPS setup script supports importing definitions from the
-`iMesh-Defs.inc` file. In order to make use of this, specify the root
-location of your iMesh installation in the environment variable ``IMESHPATH``.
-For example, if your `iMesh-Defs.inc` is located in
-`/usr/local/iMesh/lib/iMesh-Defs.inc`, then ``IMESHPATH`` should be
-`/usr/local/iMesh`. If the `iMesh-Defs.inc` file was not installed, or you
-don't wish to use it, you can manually specify the build options as described
-below in `Non-standard Library Locations`_.
+`iMesh-Defs.inc` file. In order to make use of this, specify the command-line
+options ``--imesh-path=PATH`` to the `build_ext` command. For example, if your
+`iMesh-Defs.inc` is located in `/usr/local/iMesh/lib/iMesh-Defs.inc`, then
+``--imesh-path`` should be `/usr/local/iMesh`.  This options may also be
+specified in the `setup.cfg` file (see below). 
 
+If the `iMesh-Defs.inc` file was not installed, or you don't wish to use it,
+you can manually specify the build options as described below in `Non-standard
+Library Locations`_.
+
+
 Requirements
 ============
 

Modified: MOAB/trunk/tools/iMesh/python/setup.py
===================================================================
--- MOAB/trunk/tools/iMesh/python/setup.py	2009-06-09 13:55:32 UTC (rev 2938)
+++ MOAB/trunk/tools/iMesh/python/setup.py	2009-06-09 20:00:28 UTC (rev 2939)
@@ -6,37 +6,44 @@
 import os
 import sys
 
-# this is an enormous hack because distutils won't let me specify libraries in
-# 'extra_link_args' for unknown reasons
-iMesh_libs = []
-iMesh_libdirs = []
-iMesh_incs = []
+from distutils.command.build_ext import build_ext
 
-if 'IMESHPATH' in os.environ:
-    defs = parse_makefile( os.path.join(os.environ['IMESHPATH'],
-                                        'lib/iMesh-Defs.inc') )
+def pair_fun(pre, post):
+    def tmp(self):
+        pre(self)
+        post(self)
+    return tmp
 
-    lib_match = re.compile(r'(?:(?<=\s)|^)-([lL])\s*(\S*)')
-    for match in lib_match.finditer( defs['IMESH_LIBS'] ):
-        if match.group(1) == 'l':
-            iMesh_libs.append( match.group(2) )
-        elif match.group(1) == 'L':
-            iMesh_libdirs.append( match.group(2) )
+def new_run(self):
+    if self.imesh_path:
+        defs = parse_makefile( os.path.join(self.imesh_path,
+                                            'lib/iMesh-Defs.inc') )
 
-    inc_match = re.compile(r'(?:(?<=\s)|^)-(I)\s*(\S*)')
-    for match in inc_match.finditer( defs['IMESH_INCLUDES'] ):
-        iMesh_incs.append( match.group(2) )
+        lib_match = re.compile(r'(?:(?<=\s)|^)-([lL])\s*(\S*)')
+        for match in lib_match.finditer( defs['IMESH_LIBS'] ):
+            if match.group(1) == 'l':
+                self.libraries.append( match.group(2) )
+            elif match.group(1) == 'L':
+                self.library_dirs.append( match.group(2) )
 
+        inc_match = re.compile(r'(?:(?<=\s)|^)-(I)\s*(\S*)')
+        for match in inc_match.finditer( defs['IMESH_INCLUDES'] ):
+            self.include_dirs.append( match.group(2) )
+
+def new_init(self):
+    self.imesh_path = None
+
+build_ext.user_options.append(('imesh-path=', None, 'blah blah'))
+build_ext.initialize_options = pair_fun(new_init, build_ext.initialize_options)
+build_ext.run = pair_fun(new_run, build_ext.run)
+
+
 iBase = Extension('itaps.iBase',
-                  include_dirs = iMesh_incs,
                   depends      = ['common.h', 'iBase_Python.h'],
                   sources      = ['iBase.c']
                   )
 
 iMesh = Extension('itaps.iMesh',
-                  include_dirs = iMesh_incs,
-                  libraries    = iMesh_libs,
-                  library_dirs = iMesh_libdirs,
                   depends      = ['common.h', 'errors.h', 'iMesh_Python.h',
                                   'iBase_Python.h', 'iMesh_entSet.inl',
                                   'iMesh_iter.inl', 'iMesh_tag.inl'],



More information about the moab-dev mailing list