[cig-commits] r5960 - in cs: . nemesis nemesis/trunk

leif at geodynamics.org leif at geodynamics.org
Fri Feb 2 16:18:50 PST 2007


Author: leif
Date: 2007-02-02 16:18:50 -0800 (Fri, 02 Feb 2007)
New Revision: 5960

Added:
   cs/nemesis/
   cs/nemesis/trunk/
   cs/nemesis/trunk/Makefile.am
   cs/nemesis/trunk/configure.ac
   cs/nemesis/trunk/nemesis.c
   cs/nemesis/trunk/setup.py
Log:
Created the initial, C-only version of Nemesis, which will be for
people who prefer to extend Python using *.so files, instead of
embedding everything in one, big executable.


Added: cs/nemesis/trunk/Makefile.am
===================================================================
--- cs/nemesis/trunk/Makefile.am	2007-02-02 23:39:47 UTC (rev 5959)
+++ cs/nemesis/trunk/Makefile.am	2007-02-03 00:18:50 UTC (rev 5960)
@@ -0,0 +1,46 @@
+## Process this file with automake to produce Makefile.in
+
+ACLOCAL_AMFLAGS = -I ./m4
+
+bin_PROGRAMS = nemesis mpinemesis
+
+INCLUDES = \
+	$(PYTHON_EGG_CPPFLAGS) \
+	-I$(PYTHON_INCDIR)
+
+
+# nemesis (links MPI, but does not initialize it)
+nemesis_SOURCES = nemesis.c
+nemesis$(EXEEXT): $(nemesis_OBJECTS) $(nemesis_DEPENDENCIES) 
+	@rm -f nemesis$(EXEEXT)
+	$(LINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) \
+		$(nemesis_LDFLAGS) $(nemesis_OBJECTS) $(nemesis_LDADD) \
+		$(PYTHON_EGG_LDFLAGS) \
+		$(PYTHON_BLDLIBRARY) \
+		$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
+		$(LIBS) \
+		$(PYTHON_LDLAST)
+
+
+# mpinemesis (initializes MPI before starting Python)
+mpinemesis_SOURCES = nemesis.c
+mpinemesis_CFLAGS = -DUSE_MPI
+mpinemesis$(EXEEXT): $(mpinemesis_OBJECTS) $(mpinemesis_DEPENDENCIES) 
+	@rm -f mpinemesis$(EXEEXT)
+	$(LINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) \
+		$(mpinemesis_LDFLAGS) $(mpinemesis_OBJECTS) $(mpinemesis_LDADD) \
+		$(PYTHON_EGG_LDFLAGS) \
+		$(PYTHON_BLDLIBRARY) \
+		$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
+		$(LIBS) \
+		$(PYTHON_LDLAST)
+
+
+install-data-hook:
+	top_builddir=`$(am__cd) $(top_builddir) && pwd` && \
+		cd $(top_srcdir) && \
+		$(PYTHON) setup.py install_deps -H None -f $$top_builddir/deps --prefix=$(prefix) && \
+		$(PYTHON) setup.py egg_info -e $(pythondir)
+
+
+## end of Makefile.am

Added: cs/nemesis/trunk/configure.ac
===================================================================
--- cs/nemesis/trunk/configure.ac	2007-02-02 23:39:47 UTC (rev 5959)
+++ cs/nemesis/trunk/configure.ac	2007-02-03 00:18:50 UTC (rev 5960)
@@ -0,0 +1,43 @@
+dnl                                               -*- Autoconf -*-
+dnl Process this file with autoconf to produce a configure script.
+dnl
+
+# $Id: configure.ac 5935 2007-01-30 21:16:23Z leif $
+
+AC_PREREQ(2.59)
+AC_INIT([nemesis], [1.0], [leif at geodynamics.org])
+AC_CONFIG_AUX_DIR([./aux-config])
+AC_CONFIG_SRCDIR([nemesis.c])
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([foreign])
+
+# 'configure' options
+AC_ARG_VAR(PYTHON, [Python interpreter])
+AC_ARG_VAR(PYTHONPATH, [Python module search path])
+
+# Check for Python.
+AM_PATH_PYTHON([2.3])
+CIT_PYTHON_SYSCONFIG
+
+# Check for Python modules and packages.
+CIT_PYTHON_EGG_SETUP
+
+# Checks for programs.
+AC_PROG_CC([mpicc hcc mpcc mpcc_r mpxlc cmpicc gcc cc cl icc ecc pgcc xlc xlc_r])
+
+# Checks for libraries.
+AC_SEARCH_LIBS([MPI_Init], [mpi mpich], [], [AC_MSG_ERROR([MPI library not found])])
+
+# Checks for header files.
+AC_CHECK_HEADER([mpi.h], [], [AC_MSG_ERROR([header 'mpi.h' not found])])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT
+
+dnl end of configure.ac

Added: cs/nemesis/trunk/nemesis.c
===================================================================
--- cs/nemesis/trunk/nemesis.c	2007-02-02 23:39:47 UTC (rev 5959)
+++ cs/nemesis/trunk/nemesis.c	2007-02-03 00:18:50 UTC (rev 5960)
@@ -0,0 +1,115 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *                             nemesis
+ *
+ * Copyright (c) 2007, 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.
+ *
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */ 
+
+#include <Python.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mpi.h>
+
+#define COMMAND \
+"import sys; " \
+"path = sys.argv[1]; " \
+"requires = sys.argv[2]; " \
+"entry = sys.argv[3]; " \
+"path = path.split(':'); " \
+"path.extend(sys.path); " \
+"sys.path = path; " \
+"from merlin import loadObject; " \
+"entry = loadObject(entry); " \
+"entry(sys.argv[3:], kwds={'requires': requires})"
+
+/* include the implementation of _mpi */
+#include "mpi/_mpi.c"
+
+struct _inittab inittab[] = {
+    { "_mpi", init_mpi },
+    { 0, 0 }
+};
+
+int main(int argc, char **argv)
+{
+    int status;
+    
+#ifdef USE_MPI
+    /* initialize MPI */
+    if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
+        fprintf(stderr, "%s: MPI_Init failed! Exiting ...", argv[0]);
+        return 1;
+    }
+#endif
+    
+    /* add our extension module */
+    if (PyImport_ExtendInittab(inittab) == -1) {
+        fprintf(stderr, "%s: PyImport_ExtendInittab failed! Exiting...\n", argv[0]);
+        return 1;
+    }
+    
+    if (argc < 3 || strcmp(argv[1], "--pyre-start") != 0) {
+        return Py_Main(argc, argv);
+    }
+    
+    /* make sure 'sys.executable' is set to the path of this program  */
+    Py_SetProgramName(argv[0]);
+    
+    /* initialize Python */
+    Py_Initialize();
+    
+    /* initialize sys.argv */
+    PySys_SetArgv(argc - 1, argv + 1);
+    
+    /* run the Python command */
+    status = PyRun_SimpleString(COMMAND) != 0;
+    
+    /* shut down Python */
+    Py_Finalize();
+    
+#ifdef USE_MPI
+    /* shut down MPI */
+    MPI_Finalize();
+#endif
+    
+    return status;
+}
+
+/* end of file */

Added: cs/nemesis/trunk/setup.py
===================================================================
--- cs/nemesis/trunk/setup.py	2007-02-02 23:39:47 UTC (rev 5959)
+++ cs/nemesis/trunk/setup.py	2007-02-03 00:18:50 UTC (rev 5960)
@@ -0,0 +1,25 @@
+
+from archimedes import use_merlin
+use_merlin()
+
+from merlin import setup, find_packages
+
+setup(
+    
+    name = 'nemesis', 
+    version = '1.0',
+
+    zip_safe = False,
+    packages = find_packages(),
+    
+    install_requires = [
+    'pythia[mpi] >= 0.8.1.0, < 0.8.2a',
+    ],
+
+    author = 'Leif Strand',
+    author_email = 'leif at geodynamics.org',
+    description = """A Python interpreter which embeds MPI.""",
+    license = 'BSD',
+    url = 'http://www.geodynamics.org/cig/software/packages/cs/pythia/',
+
+)



More information about the cig-commits mailing list