首页 > 解决方案 > 使用 conda build 时使用正确的环境变量

问题描述

我想将 c++ 包(https://github.com/modsim/cadet)作为带有 python 包装器的 anaconda 包。该软件包依赖于 hdf5、LAPACK 和 sundials 软件包。所有这些都可以作为 anaconda 包提供,这使得它非常方便。

目前我使用以下小脚本构建包(没有 conda):

#!bin/bash
export SUNDIALS_ROOT=~/anaconda3/include/sundials
cmake -DCMAKE_INSTALL_PREFIX="~/Dokumente/projects/pycadet/cadet" -DCMAKE_LIBRARY_PATH="~/anaconda3/lib" -DBLA_VENDOR=Intel10_64lp ../code/
make
make install

我被一些可能非常简单的事情困住了,但是阅读所有文档并在 youtube 上观看教程并没有帮助。如何使用 conda-build 使此代码通用?我想以适用于任何系统的方式设置日晷、mkl、hdf5 等的路径。

如果我理解正确,我会在我的系统上为 linux64 创建 conda 包。它涉及在 setup.sh 脚本中调用 cmake。但是系统如何知道所有库在另一台计算机上的位置(例如,如果有人想使用 conda install 安装我的包)?例如:

导出 SUNDIALS_ROOT=~/anaconda3/include/sundials

这条线显然只适用于我的电脑或任何其他安装了anaconda并命名为anaconda3的电脑。

任何提示都非常感谢。我在 conda 构建配方示例中四处寻找,并希望找到一个适合的示例,但我无法想象我是唯一一个尝试为带有共享库的 c++ 包提供 python 包装器的人。

编辑

使用以下步骤,我离我想要实现的目标更近了一点:

我添加了: conda config --add channels conda-forge

然后编辑了 meta.yaml:

包:名称:pycadet 版本:3.1.2

build:
    number: 0
source:
    url: https://github.com/modsim/CADET/archive/v3.1.2.zip

requirements:
    build:
    - sundials
about:
    home: https://github.com/modsim/CADET
    license: GPL
summary: A package for numerical simulation of chromatography

所有要求都会自动下载,一切正常,直到make崩溃。build.sh:

#!bin/bash
#
# The build receipy for conda 
#
#
#
#
# You can run build.sh with bash -x -e. The -x makes it echo each command that is run
# and the -e makes it exit whenever a command in the script returns nonzero exit status.
set -x -e

INCLUDE_PATH="${PREFIX}/include"
LIBRARY_PATH="${PREFIX}/lib"
CADET_PATH="${PREFIX}/cadet"

# get out of the work directory (contains downloaded cadet)
cd ..

# make the build directory (in source builds are prohibited)
mkdir build

# get into it
cd build

#export SUNDIALS_ROOT=${PREFIX}/include/sundials
cmake -DCMAKE_INSTALL_PREFIX="${CADET_PATH}" -DCMAKE_LIBRARY_PATH="${LIBRARY_PATH}"-DBLA_VENDOR=Intel10_64lp ${SRC_DIR} ../work/
make
make install

有什么提示吗?

标签: pythonanacondacondaconda-build

解决方案


推荐阅读