简体   繁体   English

如何将 NEST 的 Python 模块安装到特定的 site-packages 目录中?

[英]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.

相关问题 如何在特定 python 安装的站点包中通过 pip 安装 python 包? - How to Install a python package via pip in site-packages of specific python installation? 使用setuptools将模块安装到站点包 - Install module to site-packages with setuptools 如何将 yaml 安装到站点包 - How to install yaml to site-packages pip3 install [module] 创建新的“/.local/.../site-packages”目录? - pip3 install [module] creating new "/.local/.../site-packages" directory? 在python模块安装过程中会发生什么? 我可以将模块源复制到site-packages吗? - What happens during a python module install? Can I just copy the module source to site-packages? 为什么我的 Python 分发版将每个 package 安装在站点包中它自己的目录中? - Why does my Python distribution install each package in its own directory in site-packages? Python | 如何修复错误“NotADirectoryError: [Errno 20] Not a directory: '/usr/bin/python3/site-packages'” - Python | How to fix the error “NotADirectoryError: [Errno 20] Not a directory: '/usr/bin/python3/site-packages'” 指向要安装到指定站点包位置的python模块 - Pointing python modules to install to a specified site-packages location 如何在Linux下的/usr/local/lib/python2.7/site-packages下安装Pip - how to Install Pip under /usr/local/lib/python2.7/site-packages in Linux Python pip站点包 - Python pip site-packages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM