Python package needs NEURON extensions - where to save

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
calu
Posts: 19
Joined: Fri Feb 19, 2016 10:07 am

Python package needs NEURON extensions - where to save

Post by calu » Tue Mar 15, 2016 2:29 pm

Hello!

I am building a Python package that relies on NEURON and that needs some extensions (e.g. AXNODE.mod). In order to load these extensions, I normally just compile them in my project folder via nrnivmodl and NEURON finds the x86_64 folder (or i386 etc.) when I call "import neuron" in a script in the same folder.

Now, however, I intend to enable others to use my code with minimal effort, definitely not require them to run nrnivmodl every time or copy the x86_64 folder into their project folder. I am aware of the nrn_load_dll function but then I need to know the path where the extensions were compiled to.

So, what is the best practice to integrate the extensions smoothly? Are they always local or can they be integrated into NEURON globally somehow?

Thank you very much.

ted
Site Admin
Posts: 5136
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python package needs NEURON extensions - where to save

Post by ted » Tue Mar 15, 2016 4:22 pm

IMO best practice is that which is most robust, easiest to implement and maintain, and sets no traps that will cause problems in the future. This means
1. Avoid fancy directory architectures. Use a flat directory structure--keep all py, hoc, ses, and mod files reuired by a given modeling project in the same directory.
2. Run nrnivmodl in that directory before executing any code that requires mechanisms specified by those mod files. If NEURON is started with that directory as the working directory, it will automatically find and load the compiled mechanisms.
3. After updating NEURON, delete the i686 or x86_64 directory and run nrnivmodl to compile the mod files.
4. Never assume that the contents of any i686 or x86_64 compiled on one machine (or any nrnmech.dll generated under MSWin) will work if copied to a different machine. Don't bother copying those directories (or the nrnmech.dll) in the first place, and if you find that it has been copied onto the second machine, delete it from the second machine and run nrnivmod (mknrndll for MSWin).
definitely not require them to run nrnivmodl every time or copy the x86_64 folder into their project folder.
Follow the above suggestions and they won't have to.
can they be integrated into NEURON globally somehow?
Big mistake--falls into the category of setting traps for oneself. It would complicate installation and updating of NEURON. It also complicates maintenance of your own code (suppose you find that you need to revise one of the mod files, or add a new one?).

Post Reply