Changeset 27
- Timestamp:
- 05/22/07 11:42:51 (2 years ago)
- Files:
-
- branches/pygetsetcall/src/nrnpython/Makefile.am (modified) (1 diff)
- branches/pygetsetcall/src/nrnpython/nrnpy_hoc.cpp (modified) (4 diffs)
- branches/pygetsetcall/src/nrnpython/setup.py.in (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/pygetsetcall/src/nrnpython/Makefile.am
r17 r27 2 2 3 3 nsrc=$(top_srcdir)/src 4 DEFS = @DEFS@ @NRNPYTHON_DEFINES@ 4 5 NRNPYTHON_INCLUDES = @NRNPYTHON_INCLUDES@ 5 6 IV_INCLUDES = @IV_INCLUDE@ $(X_CFLAGS) branches/pygetsetcall/src/nrnpython/nrnpy_hoc.cpp
r26 r27 77 77 } 78 78 79 80 static PyObject* test_numpy(PyObject* self, PyObject* args) { 81 82 if (!PyArg_ParseTuple(args, "")) { 83 return NULL; 84 } 85 86 #ifdef WITH_NUMPY 87 88 PyArrayObject *po = NULL; 89 int dims = 1; 90 91 po = (PyArrayObject*)PyArray_FromDims(1,&dims,PyArray_DOUBLE); 92 *(double*)(po->data) = 0.0; 93 return Py_BuildValue("N",po); 94 95 #else 96 97 // return None 98 return Py_BuildValue(""); 99 100 #endif // WITH_NUMPY 101 102 103 104 } 105 106 107 79 108 static PyMethodDef HocMethods[] = { 80 109 {"execute", nrnexec, METH_VARARGS, "Execute a hoc command, return 1 on success, 0 on failure." }, 81 110 {"hoc_ac", hoc_ac, METH_VARARGS, "Get (or set) the scalar hoc_ac_." }, 111 112 {"test_numpy", test_numpy, METH_VARARGS, "If numpy support is available, returns an array containing 1 zero, otherwize None." }, 113 114 82 115 {NULL, NULL, 0, NULL} 83 116 }; … … 741 774 }; 742 775 776 /* 743 777 #ifdef WITH_NUMPY 744 778 … … 928 962 929 963 #endif //WITH_NUMPY 964 965 */ 930 966 931 967 static PyMemberDef hocobj_members[] = { … … 962 998 0, /* tp_iter */ 963 999 0, /* tp_iternext */ 964 hocobj_methods, /* tp_methods */1000 0,//hocobj_methods, /* tp_methods */ 965 1001 0,//hocobj_members, /* tp_members */ 966 1002 0, /* tp_getset */ branches/pygetsetcall/src/nrnpython/setup.py.in
r25 r27 2 2 from distutils.core import setup, Extension 3 3 4 import sys 4 5 5 defines = [] 6 # NRNPYTHON_DEFINES which were enabled at configure time 7 extern_defines = "@NRNPYTHON_DEFINES@" 6 8 9 ldefs = extern_defines.split('-D') 7 10 8 11 # check for numpy+version 12 13 with_numpy = False 9 14 10 15 try: 11 16 import numpy 12 17 except ImportError: 13 print " Fatal rror: numpy not installed or not in import path"18 print "Warning: numpy not installed or not in import path." 14 19 15 20 else: … … 19 24 if version[0] < '1' or (len(version[1]) > 1 and version[1] < '0rc1'): 20 25 print "Warning: Old numpy found and not being used. Please upgrade your version of numpy to > 1.0rc1" 26 21 27 else: 22 numpy_include_path = numpy.__path__[0]+'/core/include' 28 with_numpy = True 29 30 31 include_dirs = [] 32 defines = [] 33 34 35 # check that options at configure time match the detected options now 36 37 if 'WITH_NUMPY' in ldefs: 38 if with_numpy: 39 # Good, support was enabled in nrnpython.la at build time 40 # we can enable support here 41 42 include_dirs.append(numpy.__path__[0]+'/core/include') 23 43 defines.append(('WITH_NUMPY',None)) 24 44 45 else: 46 print "Error: NEURON was build with support for numpy but" 47 print "no suitable installation of numpy could be found." 48 print "1) Check that your numpy version is at least 1.0rc1" 49 print "2) Check that you are using the same python executable" 50 print "to run this setup.py script as specified at configure time:" 51 print "--with-nrnpython[=python_bin] (defaults to 'python' in path)." 52 sys.exit(1) 53 54 else: 55 if with_numpy: 56 print "Warning: NEURON was build without support for numpy." 57 print "A suitable installation for numpy was found, but cannot be used." 25 58 26 59 … … 46 79 "readline" 47 80 ], 48 include_dirs = [numpy_include_path],81 include_dirs = include_dirs, 49 82 define_macros=defines 50 83 )

