Heroku buildpacks - installing executables that are used by Python packages

岁酱吖の 提交于 2019-12-07 00:15:14

问题


I am trying to install M2Crypto on Heroku. This relies on SWIG being installed.

I've created a custom compiled swig executable and a custom buildpack.

I then git push my code up to Heroku, the custom buildpack installs SWIG then tries to install M2Crypto but fails because it can't find swig.

This is the buildpack customisation:

# Install SWIG
if [ ! -d $CACHE_DIR/swig ]; then
  cd $BUILD_DIR
  echo "-----> Fetching and installing SWIG 2"
  curl -O https://s3.amazonaws.com/guybowden/swig.tar.gz >/dev/null 2>&1
  echo "-----> Installing ..."
  tar xzvf swig.tar.gz >/dev/null 2>&1
  mv swig $CACHE_DIR/swig
  rm swig.tar.gz
  echo "SWIG installed" | indent
fi

mkdir -p .paybox
cp -R $CACHE_DIR/swig .paybox

echo "updating path..." | indent
PATH=$PATH:/app/.paybox/swig/bin/
export PATH
echo $PATH | indent
echo "setting SWIG_LIB environment var"
export SWIG_LIB=/app/.paybox/swig/share/swig/2.0.5/

This happens before any pip install commands are run.

If I heroku run bash and then manually run source .heroku/venv/bin/activate && pip install M2Crypto it installs no problem and my App works inside the bash prompt for the lifetime of that instance.

I think there's a problem with the PATH setting when the initial pip install -r requirements runs... any ideas?


回答1:


And the answer is..

PATH=$PATH:$BUILD_DIR/.paybox/swig/bin/
export PATH
echo $PATH | indent
echo "setting SWIG_LIB environment var"
export SWIG_LIB=$BUILD_DIR/.paybox/swig/share/swig/2.0.5/

$BUILD_DIR is where the stuff is built when the buildpack is executed - not /app/ (which is where it lives when the app runs!



来源:https://stackoverflow.com/questions/10334920/heroku-buildpacks-installing-executables-that-are-used-by-python-packages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!