From 3c1e92772ac0567affbcccaf380879267c9bbe4a Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Sat, 24 Sep 2016 08:02:00 +0200
Subject: [PATCH] Improve virtualenv support

---
 gitlab/before_build.sh |  3 ++-
 gitlab/functions.sh    | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gitlab/before_build.sh b/gitlab/before_build.sh
index e2a1cc5..18a5f77 100755
--- a/gitlab/before_build.sh
+++ b/gitlab/before_build.sh
@@ -11,7 +11,8 @@ check_env WHEELS_SERVER
 # Readies the virtualenv to use for installation
 if [ ! -d ${PREFIX} ]; then
   log_info "Creating virtualenv installation at ${PREFIX}..."
-  run_cmd ${BOB_PREFIX_PATH}/bin/virtualenv --system-site-packages ${PREFIX}
+  run_cmd_ld ${BOB_PREFIX_PATH}/bin/virtualenv --system-site-packages ${PREFIX}
+  fix_venv
 else
   log_warn "Prefix directory ${PREFIX} exists, not re-installing..."
 fi
diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index f66afab..0b360ac 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -104,6 +104,24 @@ EOT
 }
 
 
+# Fixes the python prompt by setting LD_LIBRARY_PATH permanently
+fix_venv() {
+
+  local py=${PREFIX}/bin/python
+
+  case ${PYVER} in
+    py3*) py=${py}3 ;;
+  esac
+
+  mv ${py} ${py}.orig
+  cat <<EOT >> ${py}
+#!/usr/bin/env bash
+LD_LIBRARY_PATH=${BOB_PREFIX_PATH}/lib ${py}.orig
+EOT
+  run_cmd chmod 755 ${py}
+}
+
+
 # Uploads a file to our intranet location via curl
 doc_upload() {
   log_info "curl: ${1} -> ${DOCSERVER}/${2}..."
-- 
GitLab