Code: Select all
In [1]: import neuron
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Users/shhong/<ipython-input-1-861d48cbe3e0> in <module>()
----> 1 import neuron
/Library/Python/2.7/site-packages/neuron/__init__.py in <module>()
79 except:
80 #Python3.1 extending needs to look into the module explicitly
---> 81 import neuron.hoc
82
83 import nrn
ImportError: dlopen(/Library/Python/2.7/site-packages/neuron/hoc.so, 2): Symbol not found: _environ
Referenced from: /Applications/NEURON/nrn/x86_64/lib/liboc.0.dylib
Expected in: flat namespace
in /Applications/NEURON/nrn/x86_64/lib/liboc.0.dylib
Code: Select all
diff -r c4eed98bb84b src/ivoc/ivocmain.cpp
--- a/src/ivoc/ivocmain.cpp Mon Aug 15 10:58:56 2011 -0400
+++ b/src/ivoc/ivocmain.cpp Tue Aug 16 03:09:24 2011 +0900
@@ -12,17 +12,21 @@ extern "C" {
void hoc_main1_init(char*, char**);
}
#endif
#include <stdio.h>
#include <stdlib.h>
#if HAVE_UNISTD_H
#include <unistd.h>
+#if !defined (__APPLE__)
extern char** environ;
+#else
+#include <crt_externs.h>
+#endif
#endif
#if HAVE_IV
#ifdef WIN32
#include <IV-Win/MWlib.h>
void iv_display_scale(float);
#endif
@@ -466,19 +470,22 @@ int ivocmain (int argc, char** argv, cha
setenv("NEURONHOME", NEURON_DATA_DIR, 1);
neuron_home = NEURON_DATA_DIR;
#else
#error "I don't know how to set environment variables."
// Maybe in this case the user will have to set it by hand.
#endif
// putenv and setenv may invalidate env but we no longer
// use it so following should not be needed
-#if HAVE_UNISTD_H
+#if HAVE_UNISTD_H && !defined(__APPLE__)
env = environ;
#endif
+#if defined (__APPLE__)
+ env = (*_NSGetEnviron());
+#endif
}
#else // Not unix:
neuron_home = getenv("NEURONHOME");
if (!neuron_home) {
setneuronhome((argc > 0)?argv[0]:0);
}
if (!neuron_home) {
diff -r c4eed98bb84b src/oc/parallel.c
--- a/src/oc/parallel.c Mon Aug 15 10:58:56 2011 -0400
+++ b/src/oc/parallel.c Tue Aug 16 03:09:24 2011 +0900
@@ -5,16 +5,20 @@
#define WIN32 1
#endif
#if !OCSMALL
#include <stdlib.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if defined(__APPLE__)
+#include <crt_externs.h>
+#endif
+
#include "hoc.h"
#include "parse.h" /* OBJECTVAR */
static int parallel_seen;
static double *pval; /* pointer to loop counter value */
static double end_val; /* value to assign loop counter upon completion of loop */
@@ -240,20 +244,25 @@ save_parallel_argv(argc, argv)
}
*pnt = '\0'; /* place extra '\0' at end */
#endif
#endif
}
save_parallel_envp() {
#if LINDA
+#if !defined(__APPLE__)
extern char** environ;
+ char** envp = environ;
+#endif
+#if defined(__APPLE__)
+ char** envp = (*_NSGetEnviron());
+#endif
char *pnt;
int j;
- char** envp = environ;
/* count how long the block of memory should be */
for (j = 0; envp[j]; j++) {
pnt = envp[j];
while (*pnt++) { senvp++; }
senvp++; /* add room for '\0' */
}
diff -r c4eed98bb84b src/oc/plot.c
--- a/src/oc/plot.c Mon Aug 15 10:58:56 2011 -0400
+++ b/src/oc/plot.c Tue Aug 16 03:09:24 2011 +0900
@@ -1,9 +1,10 @@
#include <../../nrnconf.h>
+
/* /local/src/master/nrn/src/oc/plot.c,v 1.7 1999/06/22 12:51:55 hines Exp */
/*
plot.c,v
* Revision 1.7 1999/06/22 12:51:55 hines
* a work around for LINUX installation problem with old style x graph
* using plot (just not compile it)
*
* Revision 1.6 1999/05/11 13:56:03 hines
@@ -203,18 +204,23 @@ plot.c,v
#include <stdio.h>
#include <string.h>
#if defined(__MINGW32__)
extern char** _environ;
#else //!defined(__MINGW32__)
#if HAVE_UNISTD_H
#include <unistd.h>
+#if !defined(__APPLE__)
extern char** environ;
#endif
+#if defined(__APPLE__)
+#include <crt_externs.h>
+#endif
+#endif
#endif //defined(__MINGW32__)
#if DOS
#include <graphics.h>
#include <dos.h>
#endif
#if defined(GRX)
#define DOS 1
@@ -503,16 +509,19 @@ hoc_outtext(s) char* s; {
#endif
initplot()
{
int i;
#if defined(__MINGW32__)
char** environ=_environ;
#endif
+#if defined (__APPLE__)
+ char** environ=(*_NSGetEnviron());
+#endif
#if defined(__TURBOC__)
graphdev = 0;
#else
#if NeXTstep
graphdev = NX;
#else
graphdev = SSUN;
for (i = 0; environ[i] != NULL; i++)
diff -r c4eed98bb84b src/oc/system.c
--- a/src/oc/system.c Mon Aug 15 10:58:56 2011 -0400
+++ b/src/oc/system.c Tue Aug 16 03:09:24 2011 +0900
@@ -55,16 +55,20 @@ Supporting OS subroutines required: <<_e
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <_syslist.h>
#include <reent.h>
+#if defined (__APPLE__)
+#include <crt_externs.h>
+#endif
+
#if defined (unix) || defined (__CYGWIN__)
static int do_system ();
#endif
int
_system_r (ptr, s)
struct _reent *ptr;
_CONST char *s;
@@ -103,24 +107,29 @@ _system_r (ptr, s)
int
system (s)
_CONST char *s;
{
return _system_r (_REENT, s);
}
#endif
-
+
#if defined (unix) && !defined (__CYGWIN__) && !defined(__rtems__)
+#if !defined(__APPLE__)
extern char **environ;
/* Only deal with a pointer to environ, to work around subtle bugs with shared
libraries and/or small data systems where the user declares his own
'environ'. */
static char ***p_environ = &environ;
+#endif
+#if defined(__APPLE__)
+static char ***p_environ = _NSGetEnviron();
+#endif
static int
do_system (ptr, s)
struct _reent *ptr;
_CONST char *s;
{
char *argv[4];
int pid, status;