From b901d2fbef03abb5edd83473444a98ed2d74ad06 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Fri, 9 Feb 2018 13:37:16 +0000
Subject: [PATCH] Test that conda/pypi builds are installable

---
 .ci/build_conda_dist.sh |  9 +++++++++
 .ci/build_pypi_dist.sh  | 26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/.ci/build_conda_dist.sh b/.ci/build_conda_dist.sh
index 0cd2bd455..0080377c5 100644
--- a/.ci/build_conda_dist.sh
+++ b/.ci/build_conda_dist.sh
@@ -27,3 +27,12 @@ conda build --output-folder=dist .conda
 # tar it up
 cd dist
 tar czf "$name"-"$version"-conda.tar.gz *
+cd ..
+
+# Make sure package is installable
+for pyver in 2.7 3.4 3.5 3.6; do
+    conda create -y --name "test$pyver" python=$pyver
+    source activate test$pyver
+    conda install -y -c file://`pwd`/dist fslpy
+    source deactivate
+done
diff --git a/.ci/build_pypi_dist.sh b/.ci/build_pypi_dist.sh
index 3a840cb2d..99410dbe6 100644
--- a/.ci/build_pypi_dist.sh
+++ b/.ci/build_pypi_dist.sh
@@ -5,3 +5,29 @@ set -e
 pip install wheel
 python setup.py sdist
 python setup.py bdist_wheel
+
+# do a test install from both source and wheel
+sdist=`find dist -maxdepth 1 -name *.tar.gz`
+wheel=`find dist -maxdepth 1 -name *.whl`
+
+# pip < 10 will not install wheels
+# with an invalid name. So we can
+# generate builds from non-releases
+# (e.g. master master branch),
+# we hack the wheel file name here
+# so that pip will accept it.
+#
+# This will no longer be necessary
+# when pip 10 is available.
+nwheel=`echo -n $wheel | sed -e 's/fslpy-/fslpy-0/g'`
+mv $wheel $nwheel
+wheel=$nwheel
+
+for target in $sdist $wheel; do
+    python -m venv test.venv
+    . test.venv/bin/activate
+    pip install --upgrade pip setuptools
+    pip install $target
+    deactivate
+    rm -r test.venv
+done
-- 
GitLab