How do I write conda recipes for dynamically linked libraries?

Viewed 237

I first wrote a bash script to create a conda evironment and installs the xerus library and all of its dependencies.

From this script I then tried to create a conda package. Although it works on my machine (even after uploading to anaconda.org) it does not work for my colleagues. The bash script however does.

I assume that I made a simple mistake in the specification of the meta.yaml or build.sh. Can you tell me where I went wrong?

Install script

#!/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-build files

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
0 Answers
Related