From 41865272cd80856eb466daef029a669225dbf139 Mon Sep 17 00:00:00 2001
From: Raul Infante-Sainz <infantesainz@gmail.com>
Date: Wed, 6 Mar 2019 17:12:19 +0000
Subject: Astroquery, astropy, matplotlib and numpy are now in the pipeline

Until this commit, we had some of the python packages intalled
but they did not work properly because of the `PYTHONPATH' variables.
That is, the pipeline's `python' was the `python' of the system
instead of the pipeline's `python'.

With this commit this issue has been fixed by setting the correct
`PYTHONPATH'. In this commit we also modify the installation of
`bzip2' because `CMake' was complaining about some libraries built
statically.
---
 .file-metadata                                   | Bin 16853304 -> 3721 bytes
 reproduce/config/pipeline/dependency-versions.mk |   9 +++---
 reproduce/src/make/dependencies-basic.mk         |  37 +++++++++++++++++------
 reproduce/src/make/dependencies-python.mk        |   1 +
 reproduce/src/make/dependencies.mk               |   3 +-
 reproduce/src/make/initialize.mk                 |  13 ++++++++
 6 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/.file-metadata b/.file-metadata
index 525a090..1176014 100644
Binary files a/.file-metadata and b/.file-metadata differ
diff --git a/reproduce/config/pipeline/dependency-versions.mk b/reproduce/config/pipeline/dependency-versions.mk
index 655d44e..9104852 100644
--- a/reproduce/config/pipeline/dependency-versions.mk
+++ b/reproduce/config/pipeline/dependency-versions.mk
@@ -3,7 +3,6 @@
 # Programs
 bash-version               = 5.0
 binutils-version           = 2.31.1
-bzip2-version              = 1.0.6
 cmake-version              = 3.12.4
 coreutils-version          = 8.30
 diffutils-version          = 3.7
@@ -83,9 +82,9 @@ webencodings-version       = 0.5.1
 # Special libraries
 # -----------------
 #
-# The shared library name of the following libraries is explicity mentioned
-# the software build Makefiles (`reproduce/src/make/dependencies*.mk'). If
-# you change their version, also please change the explicit shared library
-# names also.
+# When updating the version of these libraries, please look into the build
+# rule first: In one way or another, the version string becomes necessary
+# during their build and must be accounted for.
+bzip2-version              = 1.0.6
 libgit2-version            = 0.26.0
 wcslib-version             = 6.2
diff --git a/reproduce/src/make/dependencies-basic.mk b/reproduce/src/make/dependencies-basic.mk
index f02f68f..fefda6f 100644
--- a/reproduce/src/make/dependencies-basic.mk
+++ b/reproduce/src/make/dependencies-basic.mk
@@ -288,15 +288,34 @@ $(ibdir)/xz: $(tdir)/xz-$(xz-version).tar.gz
 	$(call gbuild, $<, xz-$(xz-version), static)
 
 $(ibdir)/bzip2: $(tdir)/bzip2-$(bzip2-version).tar.gz
-	 tdir=bzip2-$(bzip2-version);                                  \
-	 if [ $(static_build) = yes ]; then                            \
-	   makecommand="make LDFLAGS=-static";                         \
-	 else                                                          \
-	   makecommand="make";                                         \
-	 fi;                                                           \
-	 cd $(ddir) && rm -rf $$tdir && tar xf $< && cd $$tdir &&      \
-	 $$makecommand && make install PREFIX=$(idir) &&               \
-	 cd .. && rm -rf $$tdir
+        # Bzip2 doesn't have a `./configure' script, and its Makefile
+        # doesn't build a shared library. So we can't use the `gbuild'
+        # function here and we need to take some extra steps (inspired
+        # from the "Linux from Scratch" guide for Bzip2):
+        #   1) The `sed' call is for relative installed symbolic links.
+        #   2) The special Makefile-libbz2_so builds the shared library.
+        #
+        # NOTE: the major version number appears in the final symbolic
+        # link.
+	tdir=bzip2-$(bzip2-version);                                  \
+	if [ $(static_build) = yes ]; then                            \
+	  makecommand="make LDFLAGS=-static";                         \
+	  makeshared="echo no-shared";                                \
+	else                                                          \
+	  makecommand="make";                                         \
+	  makeshared="make -f Makefile-libbz2_so";                    \
+	fi;                                                           \
+	cd $(ddir) && rm -rf $$tdir && tar xf $< && cd $$tdir         \
+	&& sed -i 's@\(ln -s -f \)$$(PREFIX)/bin/@\1@' Makefile       \
+	&& $$makeshared                                               \
+	&& cp -a libbz2* $(ildir)/                                    \
+	&& make clean                                                 \
+	&& $$makecommand                                              \
+	&& make install PREFIX=$(idir)                                \
+	&& cd ..                                                      \
+	&& rm -rf $$tdir                                              \
+	&& cd $(ildir)                                                \
+	&& ln -fs libbz2.so.1.0 libbz2.so
 
 # GNU Tar: When built statically, tar gives a segmentation fault on
 # unpacking Bash. So we'll build it dynamically.
diff --git a/reproduce/src/make/dependencies-python.mk b/reproduce/src/make/dependencies-python.mk
index c45cc13..1e4f611 100644
--- a/reproduce/src/make/dependencies-python.mk
+++ b/reproduce/src/make/dependencies-python.mk
@@ -302,6 +302,7 @@ $(ipydir)/kiwisolver: $(tdir)/kiwisolver-$(kiwisolver-version).tar.gz    \
 $(ipydir)/matplotlib: $(tdir)/matplotlib-$(matplotlib-version).tar.gz   \
                       $(ipydir)/cycler                                  \
                       $(ilidir)/freetype                                \
+                      $(ipydir)/numpy                                   \
                       $(ipydir)/pyparsing                               \
                       $(ipydir)/python-dateutil                         \
                       $(ipydir)/kiwisolver
diff --git a/reproduce/src/make/dependencies.mk b/reproduce/src/make/dependencies.mk
index e1b409e..deb9f39 100644
--- a/reproduce/src/make/dependencies.mk
+++ b/reproduce/src/make/dependencies.mk
@@ -242,7 +242,8 @@ $(ilidir)/libjpeg: $(tdir)/jpegsrc.$(libjpeg-version).tar.gz
 	$(call gbuild, $<, jpeg-9b, static) && echo "Libjpeg is built" > $@
 
 $(ilidir)/libpng: $(tdir)/libpng-$(libpng-version).tar.xz
-	$(call gbuild, $<, libpng, static) && echo "Libpng is built" > $@
+	$(call gbuild, $<, libpng-$(libpng-version), static) \
+	&& echo "Libpng is built" > $@
 
 $(ilidir)/libtiff: $(tdir)/tiff-$(libtiff-version).tar.gz \
                    $(ilidir)/libjpeg
diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk
index 71cdbb8..638338b 100644
--- a/reproduce/src/make/initialize.mk
+++ b/reproduce/src/make/initialize.mk
@@ -116,6 +116,19 @@ export LDFLAGS         := -L$(installdir)/lib
 export SHELL           := $(installdir)/bin/bash
 export CPPFLAGS        := -I$(installdir)/include
 
+# Python enviroment
+# So far we have found several other Python-related environment
+# variables which might interfere. So we are just removing all
+# of their values within the pipeline.
+export PYTHONPATH             := $(installdir)/lib/python/site-packages
+export PYTHONPATH3            := $(PYTHONPATH)
+export _LMFILES_              :=
+export PYTHONPATH2            :=
+export LOADEDMODULES          :=
+export MPI_PYTHON_SITEARCH    :=
+export MPI_PYTHON2_SITEARCH   :=
+export MPI_PYTHON3_SITEARCH   :=
+
 
 
 
-- 
cgit v1.2.1