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?
How Heroku Buildpacks work. Heroku Buildpacks are responsible for compiling your deployed code and creating a slug, which is a compressed and pre-packaged copy of your app and runtime that is optimized for distribution to the dyno manager.
This is the official Heroku buildpack for Python apps, powered by Pipenv, pip and other excellent software. Recommended web frameworks include Django and Flask. The recommended webserver is Gunicorn. There are no restrictions around what software can be used (as long as it's pip-installable).
What is a buildpack? A buildpack is a set of executables that inspects your app source code and creates a plan to build and run your application. Typical buildpacks consist of at least three files: buildpack. toml – provides metadata about your buildpack.
Resolution. This error message means that Heroku was unable to automatically detect the type of app you're trying to deploy: Ruby, Node, Python, PHP, Java, etc. We look for signatures for each language we support (like a pom. xml file or package.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With