如何为动态链接库编写 conda 配方? meta.yamlbuild.shtest.sh

问题描述

我首先编写了一个 bash 脚本来创建一个 conda 环境并安装 xerus 库及其所有依赖项。

然后我尝试从这个脚本创建一个 conda 包。 尽管它在我的机器上工作(即使上传anaconda.org 之后),但对我的同事却不起作用。 但是 bash 脚本可以。

我假设我在 Meta.yamlbuild.sh 的规范中犯了一个简单的错误。 你能告诉我我哪里出错了吗?

安装脚本

#!/bin/bash
ENVNAME="${1}"
set -e

if [ -z "${ENVNAME}" ];
then
    echo "Usage: bash install.sh <env_name>"
    exit 0
fi

read -p "Create new conda environment '${ENVNAME}' (y/n)? " answer
case ${answer:0:1} in
    y|Y )
    ;;
    * )
        exit
    ;;
esac

conda create -n ${ENVNAME} -c conda-forge 'python=3.8' python_abi gxx_linux-64 make 'pip>=18.1' numpy openblas suitesparse lapack liblapacke boost-cpp libgomp scipy matplotlib rich
eval "$(conda shell.bash hook)"
conda activate ${ENVNAME}
NUMPY=${CONDA_PREFIX}/lib/python3.8/site-packages/numpy
CXX=${CONDA_PREFIX}/bin/x86_64-conda-linux-gnu-c++

git clone --recurse-submodules https://github.com/libxerus/xerus.git --branch SALSA
cd xerus

cat <<EOF >config.mk
CXX = ${CXX}
COMPATIBILITY = -std=c++17
COMPILE_THREADS = 8
HIGH_OPTIMIZATION = TRUE
OTHER += -fopenmp

python3_CONfig = \`python3-config --cflags --ldflags\`

LOGGING += -D XERUS_LOG_INFO
LOGGING += -D XERUS_LOGFILE
LOGGING += -D XERUS_LOG_ABSOLUTE_TIME
XERUS_NO_FANCY_CALLSTACK = TRUE

BLAS_LIBRARIES = -lopenblas -lgfortran
LAPACK_LIBRARIES = -llapacke -llapack
suitesparse = -lcholmod -lspqr
BOOST_LIBS = -lboost_filesystem

OTHER += -I${CONDA_PREFIX}/include -I${NUMPY}/core/include/
OTHER += -L${CONDA_PREFIX}/lib
EOF

ln -s ${CONDA_PREFIX}/include/ ${CONDA_PREFIX}/include/suitesparse
make python
python -m pip install . --no-deps -vv

cd ..
rm -rf xerus

conda 构建文件

Meta.yaml

{% set name = "Xerus" %}
{% set version = "4.0.1" %}
{% set branch = "SALSA" %}

package:
  name: {{ name|lower + '_' + branch|lower }}
  version: {{ version }}

source:
  - git_url: https://github.com/libxerus/xerus.git
    git_tag: {{ branch }}
    folder: xerus

build:
  number: 1
  skip: true       # [py<34 or win]
  run_exports:
    - python_abi
    - numpy
    - openblas
    - suitesparse
    - lapack
    - liblapacke
    - boost-cpp
    - libgomp

requirements:
  build:
    - {{ compiler('cxx') }}
    - make
    - python {{ python }}
    - pip >=18.1
  host:
    - python_abi
    - numpy
    - openblas
    - suitesparse
    - lapack
    - liblapacke
    - boost-cpp
    - libgomp
  run:
    - python_abi
    - numpy
    - openblas
    - suitesparse
    - lapack
    - liblapacke
    - boost-cpp
    - libgomp

test:
  files:
    - VERSION

about:
  home: https://libxerus.org
  license: "AGPL 3.0"
  license_file: LICENSE
  summary: "A c++ library for numerical calculations with higher order tensors"
  description: |
    The Xerus library is a general purpose library for numerical calculations with higher order tensors,Tensor-Train Decompositions / Matrix Product States and other Tensor Networks.
    The focus of development was the simple usability and adaptibility to any setting that requires higher order tensors or decompositions thereof.
  doc_url: https://libxerus.org/doxygen
  dev_url: https://github.com/libxerus/xerus

build.sh

#!/bin/bash
set -x -e

cd xerus

cat <<EOF >config.mk
CXX = ${CXX}
COMPATIBILITY = -std=c++17
COMPILE_THREADS = 8
HIGH_OPTIMIZATION = TRUE
OTHER += -fopenmp

python3_CONfig = \`python3-config --cflags --ldflags\`

LOGGING += -D XERUS_LOG_INFO
LOGGING += -D XERUS_LOGFILE
LOGGING += -D XERUS_LOG_ABSOLUTE_TIME
XERUS_NO_FANCY_CALLSTACK = TRUE

BLAS_LIBRARIES = -lopenblas -lgfortran
LAPACK_LIBRARIES = -llapacke -llapack
suitesparse = -lcholmod -lspqr
BOOST_LIBS = -lboost_filesystem

OTHER += -I${PREFIX}/include -I${PREFIX}/lib/python${PY_VER}/site-packages/numpy/core/include/
OTHER += -L${PREFIX}/lib
EOF

ln -s ${PREFIX}/include/ ${PREFIX}/include/suitesparse
make python
${PYTHON} -m pip install . --no-deps -vv

test.sh

#!/bin/bash
set -e

VERSION=$(cat VERSION)

export PYTHONPATH=''

${PYTHON} <<EOF
print("="*80)
print("\trun_test.sh for Xerus ${VERSION}")
print("="*80)
import xerus
assert xerus.__version__ == '${VERSION}',xerus.__version__+" != ${VERSION}"
EOF

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...