aboutsummaryrefslogtreecommitdiff
path: root/build-project.sh
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2018-12-04 11:08:16 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2018-12-04 11:08:16 -0500
commitf6eb0f96fec2a124333381c6a80ccd4f27290a7d (patch)
tree1dc20385009169baac43a31212d9dfd5ed2b6dde /build-project.sh
parent3767b4566c124f0b7ac15352b0614d8ef94f23d1 (diff)
downloadwheeblast-master.tar.gz
Semi-initial commitHEADmaster
Diffstat (limited to 'build-project.sh')
-rwxr-xr-xbuild-project.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/build-project.sh b/build-project.sh
new file mode 100755
index 0000000..569a4a0
--- /dev/null
+++ b/build-project.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+# Global config
+project="$1"
+root=/static
+logdir="${root}/logs"
+sysconfdir="${root}/etc"
+staging="${root}/staging"
+wheelhouse="${root}/wheelhouse"
+path_orig="${PATH}"
+
+# Build config
+source "${sysconfdir}/config.sh"
+source "${sysconfdir}/functions.sh"
+
+if [[ -z $project ]]; then
+ exit 255
+fi
+
+# Configure user to talk to artifactory (two-way)
+pushd "${HOME}" &>/dev/null
+ msg2 "Configuring pip and setuptools..."
+ mkdir -p $HOME/.pip
+ [[ -f ${sysconfdir}/pip.conf ]] && cp -a ${sysconfdir}/pip.conf ${HOME}/.pip
+ [[ -f ${sysconfdir}/pypirc ]] && cp -a ${sysconfdir}/pypirc .pypirc
+popd &>/dev/null
+
+# Enter build directory
+msg2 "Entering build directory"
+cd /io
+
+mkdir -p ${staging}/${project}
+
+# Install forced dependencies
+# Our packages are tend to be very inconsistent
+for build_env in "${envs[@]}"; do
+ PYBIN=/opt/python/${build_env}/bin
+ export PATH="${PYBIN}:${path_orig}"
+ hash -r
+ pip install -q -r ${sysconfdir}/dev-requirements.txt 1>/dev/null
+done
+
+# Iterate through Python environments
+msg2 "Building packages"
+for build_env in "${envs[@]}"; do
+ PYBIN=/opt/python/${build_env}/bin
+ export PATH="${PYBIN}:${path_orig}"
+ hash -r
+
+ python_version=$(python -V 2>&1 | awk '{ print $2 }')
+ project_version=$(git describe --long --tags 2>/dev/null || msg Unknown)
+ BYTE_COMPILE=$(find . -type f -iname '*.c' -o -iname '*.f')
+
+ # Setup logging
+ logroot=${logdir}/${python_version}/${project}/${project_version}
+ mkdir -p "${logroot}"
+
+ for dist in bdist_wheel sdist; do
+ msg3 "[${python_version}][${dist}][${project}-${project_version}]"
+
+ python setup.py ${dist} -d ${staging}/${project} \
+ 1>${logroot}/${dist}.stdout \
+ 2>${logroot}/${dist}.stderr
+
+ if [[ $? != 0 ]] && [[ ${dist} == bdist_wheel ]]; then
+ # Ahhhhhhhrrrrrrrgggg
+ pip wheel -w ${staging}/${project} ${dist} \
+ 1>${logroot}/${dist}.stdout \
+ 2>${logroot}/${dist}.stderr
+ fi
+
+ # On failure, write log to console
+ if [[ $? != 0 ]]; then
+ cat ${logroot}/${dist}.stderr
+ fi
+ done
+
+ # When not compiling Python extensions don't continue on
+ # to the next interpreter version
+ if [[ ! ${BYTE_COMPILE} ]]; then
+ break
+ fi
+done
+
+echo