neuronsimulator / nrn

NEURON Simulator
http://nrn.readthedocs.io
Other
385 stars 115 forks source link

Building NEURON on Mac OSX with Python Anaconda #54

Closed sharkovsky closed 6 years ago

sharkovsky commented 6 years ago

Thanks to @pramodk's help, I have been able to jump through all the hoops necessary to compile NEURON on Mac OSX using Python installed via Anaconda. This issue is solved, but I'd like to leave a trace of the steps necessary for building, in case other people have similar problems.

Summary

  1. You need to add at least the following options to configure step
    ./configure macdarwin=no --with-nrnpython=$HOME/anaconda3/bin/python PYINCDIR=$HOME/anaconda3/include/python3.5m/ PYLIBDIR=$HOME/anaconda3/lib/
  2. when executing, you need to set DYLD_LIBRARY_PATH and PYTHONHOME
    export DYLD_LIBRARY_PATH=$HOME/anaconda3/lib/:$DYLD_LIBRARY_PATH
    export PYTHONHOME=$HOME/anaconda3/

More details

Problem with CarbonCore.framework

At first, I got the following problem:

gcc -g -arch i386 -Dncpu="\"x86_64\"" -I. ./launch.c ./mac2uxarg.c -framework Carbon
In file included from /usr/include/dispatch/dispatch.h:51:0,
                 from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:15,
                 from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:13,
                 from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:55,
                 from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19,
                 from /System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:20,
                 from ./mac2uxarg.c:10:
/usr/include/dispatch/object.h:143:15: error: expected identifier or '(' before '^' token
 typedef void (^dispatch_block_t)(void);
               ^
/usr/include/dispatch/object.h:362:3: error: unknown type name 'dispatch_block_t'
   dispatch_block_t notification_block);
   ^
./mac2uxarg.c: In function 'fullname':
./mac2uxarg.c:93:7: warning: 'PBGetCatInfoSync' is deprecated (declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:8732) [-Wdeprecated-declarations]
       err = PBGetCatInfoSync(&myPB);
       ^
make[2]: *** [install] Error 1

This was fixed by specifying macdarwin=no in the configure line

Linking with Anaconda Python

First, you need to find where you anaconda was installed. Mine was installed at $HOME/anaconda3. During the configure phase, you need to carefully specify the correct paths.

For example, I am using python3.5 and the following (minimal) configure line

./configure macdarwin=no --with-nrnpython=$HOME/anaconda3/bin/python PYINCDIR=$HOME/anaconda3/include/python3.5m/ PYLIBDIR=$HOME/anaconda3/lib/

Setting runtime environment

when you execute, you need to make sure that DYLD_LIBRARY_PATH and PYTHONHOME are both correctly set.

export DYLD_LIBRARY_PATH=$HOME/anaconda3/lib/:$DYLD_LIBRARY_PATH
export PYTHONHOME=$HOME/anaconda3/
nrniv -python
NEURON -- VERSION 7.5 master (e0950a1+) 2017-11-14
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

loading membrane mechanisms from x86_64/.libs/libnrnmech.so
Additional mechanisms from files

>>>
sharkovsky commented 6 years ago

As I said, this issue was solved thanks to @pramodk's help.