[cig-commits] r5178 - in cs/merlin/trunk: . include

leif at geodynamics.org leif at geodynamics.org
Sat Nov 4 09:52:25 PST 2006


Author: leif
Date: 2006-11-04 09:52:24 -0800 (Sat, 04 Nov 2006)
New Revision: 5178

Added:
   cs/merlin/trunk/_mpi.h
   cs/merlin/trunk/_mpi.pyx
   cs/merlin/trunk/cmpi.pxd
   cs/merlin/trunk/include/
   cs/merlin/trunk/include/mpi.h
   cs/merlin/trunk/mpi-types.h
   cs/merlin/trunk/pympi.h
   cs/merlin/trunk/virtual-python.py
Removed:
   cs/merlin/trunk/mpi.h
Modified:
   cs/merlin/trunk/
   cs/merlin/trunk/Makefile.am
   cs/merlin/trunk/configure.ac
   cs/merlin/trunk/mpi-defs.h
   cs/merlin/trunk/mpi-imports.c
   cs/merlin/trunk/mpimain.c
   cs/merlin/trunk/python.cpp
Log:
Check-in of my work on Merlin from over a week ago...
mostly pyld-related stuff, as I recall.



Property changes on: cs/merlin/trunk
___________________________________________________________________
Name: svn:externals
   - ez_setup    http://geodynamics.org/svn/cig/cs/ez_setup

   + ez_setup    http://geodynamics.org/svn/cig/cs/ez_setup
m4          http://geodynamics.org/svn/cig/cs/autoconf/trunk


Modified: cs/merlin/trunk/Makefile.am
===================================================================
--- cs/merlin/trunk/Makefile.am	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/Makefile.am	2006-11-04 17:52:24 UTC (rev 5178)
@@ -10,6 +10,7 @@
 
 
 python_SOURCES = \
+	ld.c \
 	pymain.c \
 	pymain.h \
 	python.cpp
@@ -26,6 +27,8 @@
 
 
 mpipython_SOURCES = \
+	ld.c \
+	_mpi.c \
 	mpimain.c \
 	mpimain.h \
 	mpipython.cpp \
@@ -43,4 +46,15 @@
 		$(PYTHON_LDLAST)
 
 
+include_HEADERS = include/mpi.h
+pkginclude_HEADERS = mpi-defs.h _mpi.h
+pkglib_LIBRARIES = libmpi.a
+libmpi_a_SOURCES = mpi-imports.c
+
+
+install-data-hook:
+	cd $(top_srcdir) && $(PYTHON) virtual-python.py --prefix=$(DESTDIR)$(prefix)
+	cd $(top_srcdir) && $(DESTDIR)$(bindir)/python setup.py install --prefix=$(DESTDIR)$(prefix)
+
+
 ## end of Makefile.am

Added: cs/merlin/trunk/_mpi.h
===================================================================
--- cs/merlin/trunk/_mpi.h	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/_mpi.h	2006-11-04 17:52:24 UTC (rev 5178)
@@ -0,0 +1,12 @@
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+__PYX_EXTERN_C DL_IMPORT(PyTypeObject) PyMPICommObject_Type;
+
+struct PyMPICommObject {
+  PyObject_HEAD
+  MPI_Comm comm;
+};
+PyMODINIT_FUNC init_mpi(void);

Copied: cs/merlin/trunk/_mpi.pyx (from rev 5081, cs/pythia/trunk/pythia/mpi/_mpi.pyx)
===================================================================
--- cs/pythia/trunk/pythia/mpi/_mpi.pyx	2006-10-24 00:57:54 UTC (rev 5081)
+++ cs/merlin/trunk/_mpi.pyx	2006-11-04 17:52:24 UTC (rev 5178)
@@ -0,0 +1,102 @@
+# Process this file with Pyrex to produce mpi.c
+
+
+cimport cmpi
+
+
+cdef extern from "stdlib.h":
+    void *malloc(int)
+    void free(void *)
+
+
+cdef public class MPI_Comm [object PyMPICommObject, type PyMPICommObject_Type]:
+
+    cdef cmpi.MPI_Comm comm
+
+    def __init__(MPI_Comm self):
+        self.comm = cmpi.MPI_COMM_WORLD
+
+
+MPI_COMM_WORLD = MPI_Comm()
+
+
+class MPI_Error(EnvironmentError):
+    def __str__(self):
+        return MPI_Error_string(self.args[0])
+
+
+def MPI_Init(argv):
+    cdef int error, cargc, i
+    cdef char **cargv, **mycargv
+    myargv = []
+
+    # Construct a C char** argument vector from 'argv'.
+    cargc = len(argv)
+    cargv = <char **>malloc((cargc + 1) * sizeof(char *))
+    for i from 0 <= i < cargc:
+        arg = argv[i]
+        myargv.append(arg) # add ref
+        cargv[i] = arg
+    cargv[cargc] = NULL
+
+    # Call MPI_Init().
+    mycargv = cargv; # MPI might allocate & return its own.
+    error = cmpi.MPI_Init(&cargc, &cargv)
+    if error != cmpi.MPI_SUCCESS:
+        free(mycargv)
+        raise MPI_Error(error)
+
+    # Reconstruct Python's 'argv' from the modified 'cargv'.
+    del argv[:]
+    for i from 0 <= i < cargc:
+        argv.append(cargv[i])
+    free(mycargv)
+    
+    return
+
+
+def MPI_Finalize():
+    cdef int error
+    error = cmpi.MPI_Finalize()
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return
+
+
+def MPI_Comm_rank(comm):
+    cdef int error
+    cdef int rank
+    cdef MPI_Comm c_comm
+    c_comm = comm
+    error = cmpi.MPI_Comm_rank(c_comm.comm, &rank)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return rank
+
+
+def MPI_Comm_size(comm):
+    cdef int error
+    cdef int size
+    cdef MPI_Comm c_comm
+    c_comm = comm
+    error = cmpi.MPI_Comm_size(c_comm.comm, &size)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    return size
+
+
+cdef char cstring[1024]
+
+def MPI_Error_string(int errorcode):
+    cdef int error
+    cdef int resultlen
+    error = cmpi.MPI_Error_string(errorcode, cstring, &resultlen)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error(error)
+    if resultlen >= 1024:
+        raise RuntimeError("buffer overflow")
+    string = cstring
+    return string
+    
+
+# end of file

Copied: cs/merlin/trunk/cmpi.pxd (from rev 5081, cs/pythia/trunk/pythia/mpi/cmpi.pxd)

Modified: cs/merlin/trunk/configure.ac
===================================================================
--- cs/merlin/trunk/configure.ac	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/configure.ac	2006-11-04 17:52:24 UTC (rev 5178)
@@ -4,7 +4,7 @@
 
 AC_PREREQ(2.59)
 AC_INIT([merlin], [1.0], [leif at geodynamics.org])
-AC_CONFIG_SRCDIR([bin/python.c])
+AC_CONFIG_SRCDIR([python.cpp])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign])
@@ -27,17 +27,18 @@
 # Checks for typedefs, structures, and compiler characteristics.
 AC_F77_WRAPPERS
 AC_FC_WRAPPERS
-AC_FC_SRCEXT(f90)
-AC_FC_FREEFORM()
-CIT_FC_MAIN
+dnl AC_LANG(Fortran)
+dnl AC_FC_SRCEXT(f90)
+dnl AC_FC_FREEFORM()
+dnl CIT_FC_MAIN
+dnl AC_LANG(C)
 
 # Checks for library functions.
 
 # Influential environment variables.
 AC_ARG_VAR(PYTHON, [Python interpreter])
 
-AC_CONFIG_FILES([Makefile
-                 bin/Makefile])
+AC_CONFIG_FILES([Makefile])
 
 AC_OUTPUT
 

Copied: cs/merlin/trunk/include/mpi.h (from rev 5081, cs/merlin/trunk/mpi.h)
===================================================================
--- cs/merlin/trunk/mpi.h	2006-10-24 00:57:54 UTC (rev 5081)
+++ cs/merlin/trunk/include/mpi.h	2006-11-04 17:52:24 UTC (rev 5178)
@@ -0,0 +1,73 @@
+/*
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *                               merlin
+ *
+ * Copyright (c) 2006, California Institute of Technology
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    * Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ *    * Neither the name of the California Institute of Technology nor
+ *    the names of its contributors may be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+#ifndef __merlin_mpi_h__
+#define __merlin_mpi_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "merlin/mpi-types.h"
+
+#define PyLD_VAR(type, name) extern type __py_imp_ ## name;
+#define PyLD_FUNC(ret, name, proto, args) extern ret (*__py_imp_ ## name)proto;
+#include "merlin/mpi-defs.h"
+#undef PyLD_VAR
+#undef PyLD_FUNC
+
+#define PyLD_MACRO(name) __py_imp_ ## name
+#include "merlin/mpi-defs.h"
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __merlin_mpi_h__ */
+
+
+/* end of file */

Modified: cs/merlin/trunk/mpi-defs.h
===================================================================
--- cs/merlin/trunk/mpi-defs.h	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/mpi-defs.h	2006-11-04 17:52:24 UTC (rev 5178)
@@ -40,11 +40,37 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
 
+
 #ifdef PyLD_MACRO
 
 
 #define MPI_SUCCESS PyLD_MACRO(MPI_SUCCESS)
 
+#define MPI_CHAR PyLD_MACRO(MPI_CHAR)
+#define MPI_UNSIGNED_CHAR PyLD_MACRO(PI_UNSIGNED_CHAR)
+#define MPI_BYTE PyLD_MACRO(MPI_BYTE)
+#define MPI_SHORT PyLD_MACRO(MPI_SHORT)
+#define MPI_UNSIGNED_SHORT PyLD_MACRO(MPI_UNSIGNED_SHORT)
+#define MPI_INT PyLD_MACRO(MPI_INT)
+#define MPI_UNSIGNED PyLD_MACRO(MPI_UNSIGNED)
+#define MPI_LONG PyLD_MACRO(MPI_LONG)
+#define MPI_UNSIGNED_LONG PyLD_MACRO(MPI_UNSIGNED_LONG)
+#define MPI_FLOAT PyLD_MACRO(MPI_FLOAT)
+#define MPI_DOUBLE PyLD_MACRO(MPI_DOUBLE)
+
+#define MPI_MAX PyLD_MACRO(MPI_MAX)
+#define MPI_MIN PyLD_MACRO(MPI_MIN)
+#define MPI_SUM PyLD_MACRO(MPI_SUM)
+#define MPI_PROD PyLD_MACRO(MPI_PROD)
+#define MPI_LAND PyLD_MACRO(MPI_LAND)
+#define MPI_BAND PyLD_MACRO(MPI_BAND)
+#define MPI_LOR PyLD_MACRO(MPI_LOR)
+#define MPI_BOR PyLD_MACRO(MPI_BOR)
+#define MPI_LXOR PyLD_MACRO(MPI_LXOR)
+#define MPI_BXOR PyLD_MACRO(MPI_BXOR)
+#define MPI_MINLOC PyLD_MACRO(MPI_MINLOC)
+#define MPI_MAXLOC PyLD_MACRO(MPI_MAXLOC)
+
 #define MPI_Allreduce PyLD_MACRO(MPI_Allreduce)
 #define MPI_Barrier PyLD_MACRO(MPI_Barrier)
 #define MPI_Cart_coords PyLD_MACRO(MPI_Cart_coords)
@@ -74,18 +100,50 @@
 #else /* !PyLD_MACRO */
 
 
+#define MPI_Comm __py_imp_MPI_Comm
+#define MPI_Group __py_imp_MPI_Group
+#define MPI_Op __py_imp_MPI_Op
+#define MPI_Datatype __py_imp_MPI_Datatype
+#define MPI_Request __py_imp_MPI_Request
+#define MPI_Status __py_imp_MPI_Status
+
 PyLD_VAR(int, MPI_SUCCESS)
 
+PyLD_VAR(MPI_Datatype, MPI_CHAR)
+PyLD_VAR(MPI_Datatype, MPI_UNSIGNED_CHAR)
+PyLD_VAR(MPI_Datatype, MPI_BYTE)
+PyLD_VAR(MPI_Datatype, MPI_SHORT)
+PyLD_VAR(MPI_Datatype, MPI_UNSIGNED_SHORT)
+PyLD_VAR(MPI_Datatype, MPI_INT)
+PyLD_VAR(MPI_Datatype, MPI_UNSIGNED)
+PyLD_VAR(MPI_Datatype, MPI_LONG)
+PyLD_VAR(MPI_Datatype, MPI_UNSIGNED_LONG)
+PyLD_VAR(MPI_Datatype, MPI_FLOAT)
+PyLD_VAR(MPI_Datatype, MPI_DOUBLE)
+
+PyLD_VAR(MPI_Op, MPI_MAX)
+PyLD_VAR(MPI_Op, MPI_MIN)
+PyLD_VAR(MPI_Op, MPI_SUM)
+PyLD_VAR(MPI_Op, MPI_PROD)
+PyLD_VAR(MPI_Op, MPI_LAND)
+PyLD_VAR(MPI_Op, MPI_BAND)
+PyLD_VAR(MPI_Op, MPI_LOR)
+PyLD_VAR(MPI_Op, MPI_BOR)
+PyLD_VAR(MPI_Op, MPI_LXOR)
+PyLD_VAR(MPI_Op, MPI_BXOR)
+PyLD_VAR(MPI_Op, MPI_MINLOC)
+PyLD_VAR(MPI_Op, MPI_MAXLOC)
+
 PyLD_FUNC(int, MPI_Allreduce, (void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm),
          (sendbuf, recvbuf, count, datatype, op, comm))
 PyLD_FUNC(int, MPI_Barrier, (MPI_Comm comm),
           (comm))
-PyLD_FUNC(int, MPI_Cart_coords, (MPI_Comm comm, int rank, int dim, int *coordinates),
-          (comm, rank, dim, coordinates))
-PyLD_FUNC(int, MPI_Cart_create, (MPI_Comm comm, int size, int *procs, int *periods, int reorder, MPI_Comm *comm),
-          (comm, size, procs, periods, reorder, comm))
-PyLD_FUNC(int, MPI_Comm_create, (MPI_Comm comm, MPI_Group group, MPI_Comm *comm),
-          (comm, group, comm))
+PyLD_FUNC(int, MPI_Cart_coords, (MPI_Comm comm, int rank, int maxdims, int *coords),
+          (comm, rank, maxdims, coords))
+PyLD_FUNC(int, MPI_Cart_create, (MPI_Comm comm_old, int ndims, int *dims, int *periods, int reorder, MPI_Comm *comm_cart),
+          (comm_old, ndims, dims, periods, reorder, comm_cart))
+PyLD_FUNC(int, MPI_Comm_create, (MPI_Comm comm, MPI_Group group, MPI_Comm *comm_out),
+          (comm, group, comm_out))
 PyLD_FUNC(int, MPI_Comm_group, (MPI_Comm comm, MPI_Group *group),
           (comm, group))
 PyLD_FUNC(int, MPI_Comm_rank, (MPI_Comm comm, int *rank),
@@ -100,12 +158,12 @@
           (sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm))
 PyLD_FUNC(int, MPI_Get_count, (MPI_Status *status, MPI_Datatype datatype, int *count),
           (status, datatype, count))
-PyLD_FUNC(int, MPI_Group_excl, (MPI_Group group, int size, int *ranks, MPI_Group *group),
-          (group, size, ranks, group))
+PyLD_FUNC(int, MPI_Group_excl, (MPI_Group group, int size, int *ranks, MPI_Group *newgroup),
+          (group, size, ranks, newgroup))
 PyLD_FUNC(int, MPI_Group_free, (MPI_Group *group),
           (group))
-PyLD_FUNC(int, MPI_Group_incl, (MPI_Group group, int size, int *ranks, MPI_Group *group),
-          (group, size, ranks, group))
+PyLD_FUNC(int, MPI_Group_incl, (MPI_Group group, int size, int *ranks, MPI_Group *group_out),
+          (group, size, ranks, group_out))
 PyLD_FUNC(int, MPI_Group_rank, (MPI_Group group, int *rank),
           (group, rank))
 PyLD_FUNC(int, MPI_Group_size, (MPI_Group group, int *size),
@@ -122,13 +180,14 @@
           (buf, count, datatype, dest, tag, comm))
 PyLD_FUNC(int, MPI_Sendrecv, (void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag,
                               void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag,
-                              MPI_Comm comm, MPI_Status * status),
+                              MPI_Comm comm, MPI_Status *status),
           (sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, status))
 PyLD_FUNC(int, MPI_Waitall, (int count, MPI_Request *array_of_requests, MPI_Status *array_of_statuses),
           (count, array_of_requests, array_of_statuses))
 PyLD_FUNC(double, MPI_Wtime, (void),
           ())
-    
+
+
 #endif /* !PyLD_MACRO */
 
 

Modified: cs/merlin/trunk/mpi-imports.c
===================================================================
--- cs/merlin/trunk/mpi-imports.c	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/mpi-imports.c	2006-11-04 17:52:24 UTC (rev 5178)
@@ -40,26 +40,26 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#define PyImportEntry_INIT(name) PyObject_HEAD_INIT(&PyImportEntry_Type), sizeof(#name)-1, #name, (void *)&__py_imp_ ## name
+#include <Python.h>
+#include "mpi-types.h"
+#include "ld.h"
 
+#define PyImportEntry_INIT(name) PyObject_HEAD_INIT(&PyImportEntry_Type) sizeof(#name)-1, #name, (void *)&__py_imp_ ## name
+
+#define PyLD_VAR(type, name) type __py_imp_ ## name;
 #define PyLD_FUNC(ret, name, proto, args) \
 ret (*__py_imp_ ## name)proto;
 #include "mpi-defs.h"
+#undef PyLD_VAR
 #undef PyLD_FUNC
 
-static PyImportEntryObject __py_importTable[] = {
+static struct PyImportEntryObject __py_importTable[] = {
+#define PyLD_VAR(type, name) { PyImportEntry_INIT(name) },
 #define PyLD_FUNC(ret, name, proto, args) { PyImportEntry_INIT(name) },
 #include "mpi-defs.h"
-}
+    { 0 }
+};
+#undef PyLD_VAR
 #undef PyLD_FUNC
 
-#define PyLD_FUNC(ret, name, proto, args) \
-ret name proto \
-{ \
-    return (*__py_imp_ ## name)args; \
-}
-#include "mpi-defs.h"
-#undef PyLD_FUNC
-
-    
 /* end of file */

Added: cs/merlin/trunk/mpi-types.h
===================================================================
--- cs/merlin/trunk/mpi-types.h	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/mpi-types.h	2006-11-04 17:52:24 UTC (rev 5178)
@@ -0,0 +1,58 @@
+/*
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *                               merlin
+ *
+ * Copyright (c) 2006, California Institute of Technology
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    * Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ *    * Neither the name of the California Institute of Technology nor
+ *    the names of its contributors may be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*/
+
+#ifndef __merlin_mpi_types_h__
+#define __merlin_mpi_types_h__
+
+
+typedef struct __py_imp_MPI_Comm *__py_imp_MPI_Comm;
+typedef struct __py_imp_MPI_Group *__py_imp_MPI_Group;
+typedef struct __py_imp_MPI_Op *__py_imp_MPI_Op;
+typedef struct __py_imp_MPI_Datatype *__py_imp_MPI_Datatype;
+typedef struct __py_imp_MPI_Request *__py_imp_MPI_Request;
+typedef struct __py_imp_MPI_Status *__py_imp_MPI_Status;
+
+
+#endif /* __merlin_mpi_types_h__ */
+
+
+/* end of file */

Deleted: cs/merlin/trunk/mpi.h
===================================================================
--- cs/merlin/trunk/mpi.h	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/mpi.h	2006-11-04 17:52:24 UTC (rev 5178)
@@ -1,70 +0,0 @@
-/*
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *                               merlin
- *
- * Copyright (c) 2006, California Institute of Technology
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *
- *    * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- *    * Redistributions in binary form must reproduce the above
- *    copyright notice, this list of conditions and the following
- *    disclaimer in the documentation and/or other materials provided
- *    with the distribution.
- *
- *    * Neither the name of the California Institute of Technology nor
- *    the names of its contributors may be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-
-#ifndef __merlin_mpi_h__
-#define __merlin_mpi_h__
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define PyLD_FUNC(ret, name, proto, args) ret (*__py_imp_ ## name)proto;
-#include "mpi-defs.h"
-#undef PyLD_FUNC
-
-#define PyLD_MACRO(name) (__py_imp_ ## name)
-#include "mpi-defs.h"
-#undef PyLD_MACRO
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* __merlin_mpi_h__ */
-
-
-/* end of file */

Modified: cs/merlin/trunk/mpimain.c
===================================================================
--- cs/merlin/trunk/mpimain.c	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/mpimain.c	2006-11-04 17:52:24 UTC (rev 5178)
@@ -49,9 +49,8 @@
 #include "pymain.h"
 
 
-/* include the implementations of our built-in extension modules */
-#include "ld.c"
-#include "_mpi.c"
+PyMODINIT_FUNC initld(void);
+PyMODINIT_FUNC init_mpi(void);
 
 
 struct _inittab inittab[] = {

Copied: cs/merlin/trunk/pympi.h (from rev 5081, cs/pythia/trunk/pythia/mpi/pympi.h)
===================================================================
--- cs/pythia/trunk/pythia/mpi/pympi.h	2006-10-24 00:57:54 UTC (rev 5081)
+++ cs/merlin/trunk/pympi.h	2006-11-04 17:52:24 UTC (rev 5178)
@@ -0,0 +1,28 @@
+/* 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//                        California Institute of Technology
+//                          (C) 2006  All Rights Reserved
+// 
+//  <LicenseText>
+// 
+//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*/ 
+
+#if !defined(mpi_pympi_h)
+#define mpi_pympi_h
+
+
+#include <mpi.h>
+#include <Python.h>
+
+
+/* include the header generated by Pyrex */
+#include "merlin/_mpi.h"
+
+typedef struct PyMPICommObject PyMPICommObject;
+
+
+#endif /* mpi_pympi_h */
+
+/* end of file */

Modified: cs/merlin/trunk/python.cpp
===================================================================
--- cs/merlin/trunk/python.cpp	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/python.cpp	2006-11-04 17:52:24 UTC (rev 5178)
@@ -45,8 +45,7 @@
 #include "pymain.h"
 
 
-// include the implementations of our built-in extension modules
-#include "ld.c"
+PyMODINIT_FUNC initld(void);
 
 
 struct _inittab inittab[] = {

Added: cs/merlin/trunk/virtual-python.py
===================================================================
--- cs/merlin/trunk/virtual-python.py	2006-11-04 01:29:44 UTC (rev 5177)
+++ cs/merlin/trunk/virtual-python.py	2006-11-04 17:52:24 UTC (rev 5178)
@@ -0,0 +1,123 @@
+"""Create a "virtual" Python installation
+
+Based on a script created by Ian Bicking."""
+
+import sys, os, optparse, shutil
+join = os.path.join
+py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
+
+def mkdir(path):
+    if not os.path.exists(path):
+        print 'Creating %s' % path
+        os.makedirs(path)
+    else:
+        if verbose:
+            print 'Directory %s already exists'
+
+def symlink(src, dest):
+    if not os.path.exists(dest):
+        if verbose:
+            print 'Creating symlink %s' % dest
+        os.symlink(src, dest)
+    else:
+        print 'Symlink %s already exists' % dest
+
+
+def rmtree(dir):
+    if os.path.exists(dir):
+        print 'Deleting tree %s' % dir
+        shutil.rmtree(dir)
+    else:
+        if verbose:
+            print 'Do not need to delete %s; already gone' % dir
+
+def make_exe(fn):
+    if os.name == 'posix':
+        oldmode = os.stat(fn).st_mode & 07777
+        newmode = (oldmode | 0555) & 07777
+        os.chmod(fn, newmode)
+        if verbose:
+            print 'Changed mode of %s to %s' % (fn, oct(newmode))
+
+def main():
+    if os.name != 'posix':
+        print "This script only works on Unix-like platforms, sorry."
+        return
+
+    parser = optparse.OptionParser()
+    
+    parser.add_option('-v', '--verbose', action='count', dest='verbose',
+        default=0, help="Increase verbosity")
+        
+    parser.add_option('--prefix', dest="prefix", default='~',
+        help="The base directory to install to (default ~)")
+        
+    parser.add_option('--clear', dest='clear', action='store_true',
+        help="Clear out the non-root install and start from scratch")
+        
+    parser.add_option('--no-site-packages', dest='no_site_packages',
+        action='store_true',
+        help="Don't copy the contents of the global site-packages dir to the "
+             "non-root site-packages")
+    
+    options, args = parser.parse_args()
+    global verbose
+
+    home_dir = os.path.expanduser(options.prefix)
+    lib_dir = join(home_dir, 'lib', py_version)
+    inc_dir = join(home_dir, 'include', py_version)
+    bin_dir = join(home_dir, 'bin')
+
+    if sys.executable.startswith(bin_dir):
+        print 'Please use the *system* python to run this script'
+        return
+
+    verbose = options.verbose
+    assert not args, "No arguments allowed"
+        
+    if options.clear:
+        rmtree(lib_dir)
+        rmtree(inc_dir)
+        print 'Not deleting', bin_dir
+
+    prefix = sys.prefix
+    mkdir(lib_dir)
+    stdlib_dir = join(prefix, 'lib', py_version)
+    for fn in os.listdir(stdlib_dir):
+        if fn != 'site-packages':
+            symlink(join(stdlib_dir, fn), join(lib_dir, fn))
+
+    mkdir(join(lib_dir, 'site-packages'))
+    if not options.no_site_packages:
+        for fn in os.listdir(join(stdlib_dir, 'site-packages')):
+            symlink(join(stdlib_dir, 'site-packages', fn),
+                    join(lib_dir, 'site-packages', fn))
+
+    mkdir(inc_dir)
+    stdinc_dir = join(prefix, 'include', py_version)
+    for fn in os.listdir(stdinc_dir):
+        symlink(join(stdinc_dir, fn), join(inc_dir, fn))
+
+    if sys.exec_prefix != sys.prefix:
+        exec_dir = join(sys.exec_prefix, 'lib', py_version)
+        for fn in os.listdir(exec_dir):
+            symlink(join(exec_dir, fn), join(lib_dir, fn))
+
+    mkdir(bin_dir)
+    print 'Copying %s to %s' % (sys.executable, bin_dir)
+    py_executable = join(bin_dir, 'python')
+    if sys.executable != py_executable:
+        shutil.copyfile(sys.executable, py_executable)
+        make_exe(py_executable)
+
+    pydistutils = os.path.expanduser('~/.pydistutils.cfg')
+    if os.path.exists(pydistutils):
+        print 'Please make sure you remove any previous custom paths from'
+        print "your", pydistutils, "file."
+
+    print "You're now ready to download ez_setup.py, and run"
+    print py_executable, "ez_setup.py"
+      
+if __name__ == '__main__':
+    main()
+



More information about the cig-commits mailing list