Skip to content

Commit

Permalink
Cleanup buildpack output (#10)
Browse files Browse the repository at this point in the history
* Cleanup buildpack output

* indent sphinx build
  • Loading branch information
codingjoe authored Mar 27, 2018
1 parent 9706a01 commit 5e952f5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
6 changes: 6 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3

# shellcheck source=utils.sh
source "$BIN_DIR/utils.sh"

puts-step "Change Procfile to serve Sphinx docs"
# Override Procfile from $ROOT_DIR
cp $ROOT_DIR/Procfile ${BUILD_DIR}

puts-step "Copy WSGI configuration"
# Override wsgi file from $BUILD_DIR/docs folder or use the default one
if [ -f $BUILD_DIR/docs/wsgi.py ]; then
cp $BUILD_DIR/docs/wsgi.py ${BUILD_DIR}
else
cp $ROOT_DIR/wsgi.py ${BUILD_DIR}
fi

puts-step "Copy Sphinx specific post_compile script"
# post_compile will be executed by Python buildpack
# Override post_compile file from $BUILD_DIR/docs folder or use the default one
if [ -f $BUILD_DIR/docs/post_compile ]; then
Expand Down
15 changes: 15 additions & 0 deletions bin/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# Add a little Heroku style syntax sugar.

indent() {
sed "s/^/ /"
}

puts-step() {
echo "-----> $*"
}

puts-warn() {
echo " ! $*"
}
30 changes: 23 additions & 7 deletions post_compile
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
#!/usr/bin/env bash

set -e
set -eo pipefail

indent() {
sed "s/^/ /"
}

puts-step() {
echo "-----> $*"
}

puts-warn() {
echo " ! $*"
}


# Set graphviz path
export PATH=${BUILD_DIR}/heroku-buildpack-graphviz/usr/bin:${PATH}
export GRAPHVIZ_DOT=${BUILD_DIR}/heroku-buildpack-graphviz/usr/bin/dot
export LD_LIBRARY_PATH=${BUILD_DIR}/heroku-buildpack-graphviz/usr/lib:${BUILD_DIR}/.heroku/vendor/lib/:${LD_LIBRARY_PATH}

puts-step "Setting up Sphinx environment"

# All requirements of wsgi.py
pip install static
pip install -q static | indent

# Needed to serve the application (Procfile)
pip install waitress
pip install -q waitress | indent

if [[ ! -f ${BUILD_DIR}/docs/requirements.txt ]]; then
echo "docs/requirements.txt not found"
echo "installing Sphinx"
puts-warn "docs/requirements.txt not found, installing Sphinx"
pip install -q Sphinx
else
pip install -r ${BUILD_DIR}/docs/requirements.txt
pip install -qr ${BUILD_DIR}/docs/requirements.txt
fi;

# Get sphinx build-dir
echo -e "\necho-build-dir:\n\t@echo '\$(BUILDDIR)'\n" >> ${BUILD_DIR}/docs/Makefile
(cd ${BUILD_DIR}/docs && make echo-build-dir > ${BUILD_DIR}/docs/.build-dir)

puts-step "Build Sphinx docs"

# Build Sphinx documentation
(cd ${BUILD_DIR}/docs && make html)
(cd ${BUILD_DIR}/docs && make html) | indent

0 comments on commit 5e952f5

Please sign in to comment.