pipnest-simulator

How to install NEST's Python module into a specific site-packages directory?


The specific question at hand is:

How could I install the nest module of a NEST simulator installation into a specific site-packages directory of for example a pyenv/virtualenv?

But a broader explanation on how the Python module is generated and installed during the NEST CMake itself is certainly welcome. For example, where's the setup.py file that's used to install the Python files, I notice some egg-info files typical for pip? I suppose that if I knew that I could use pip to install the module anywhere I wanted. Another side-question is whether the Python module install target is configurable from CMake?


Solution

  • NEST is not a Python package and the Python modules rely on libraries of the compiled modules being available in known locations. When using for example a Conda flavor, you can install NEST with cmake -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX (when inside the target environment) to have everything installed into the environments directory tree.

    For the self-built modules, the same requirements hold and in addition to the .py files being in a directory where the corresponding Python looks for its modules (e.g. .../site-packages), the created .so files need to be in a place where the dynamic loader can find them.

    Try to copy the .so file into the NEST install directory path/to/installed/lib/nest/ and the python files into the site-packages for your environment. pynest itself also has a setup.py that you find in your build directory in pynest/setup.py. The python package is however not meant to be distributed separately, because of the aforementioned binary dependencies.

    Be aware that you have to take care about consistency. You can not use a module compiled for one Python version with another Python, etc. Generally, the dependencies are a tricky thing and using e.g. libGSL in your module should also be the same one as used when compiling NEST, etc. This goes down to basically also using the same compiler.