[英]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?
如何将 NEST 模拟器安装的 nest 模块安装到特定的站点包目录中,例如 pyenv/virtualenv?
But a broader explanation on how the Python module is generated and installed during the NEST CMake itself is certainly welcome.但是,当然欢迎在 NEST CMake 本身期间更广泛地解释 Python 模块是如何生成和安装的。 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?例如,用于安装 Python 文件的
setup.py
文件在哪里,我注意到一些典型的 pip 的egg-info
文件? I suppose that if I knew that I could use pip to install the module anywhere I wanted.我想,如果我知道我可以使用 pip 在任何我想要的地方安装模块。 Another side-question is whether the Python module install target is configurable from CMake?
另一个附带问题是 Python 模块安装目标是否可以从 CMake 配置?
NEST is not a Python package and the Python modules rely on libraries of the compiled modules being available in known locations. NEST 不是 Python 包,Python 模块依赖于已知位置可用的已编译模块库。 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.例如,当使用 Conda 风格时,您可以使用
cmake -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
(在目标环境中)安装 NEST,以便将所有内容安装到环境目录树中。
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 (eg .../site-packages
), the created .so
files need to be in a place where the dynamic loader can find them.对于自建模块,同样的要求成立,除了
.py
文件位于相应 Python 查找其模块的目录中(例如.../site-packages
),创建的.so
文件需要在动态加载程序可以找到它们的地方。
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.尝试将
.so
文件复制到 NEST 安装目录path/to/installed/lib/nest/
,并将 python 文件复制到您的环境的site-packages
中。 pynest
itself also has a setup.py
that you find in your build directory in pynest/setup.py
. pynest
本身也有一个setup.py
,您可以在pynest/setup.py
构建目录中找到它。 The python package is however not meant to be distributed separately, because of the aforementioned binary dependencies.然而,由于上述二进制依赖关系,python 包并不打算单独分发。
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 eg 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.
您不能将为一个 Python 版本编译的模块与另一个 Python 等一起使用。通常,依赖项是一件棘手的事情,并且在您的模块中使用例如 libGSL 也应该与编译 NEST 等时使用的相同。这归结为基本上也使用相同的编译器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.