#!/bin/bash


#########
# mpich #
#########
# Download
cd /tmp
rm -f mpich-3.3.2.tar.gz
wget http://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2.tar.gz
rm -rf mpich-3.3.2
tar zxf mpich-3.3.2.tar.gz

# Install
cd /tmp/mpich-3.3.2
./configure --prefix=/home/miniconda3
make -j8
make install -j8


##########
# mpi4py #
##########
export PATH=/home/miniconda3/bin:$PATH
export CC=mpicc
pip install mpi4py


########
# hdf5 #
########
# Download
cd /tmp
rm -f hdf5-1.12.0.tar.gz
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/src/hdf5-1.12.0.tar.gz
rm -rf hdf5-1.12.0
tar zxf hdf5-1.12.0.tar.gz

# Install
cd /tmp/hdf5-1.12.0
export CFLAGS=-fPIC
./configure --enable-parallel --prefix=/home/miniconda3 --build=arm
make -j8
make install -j8


########
# h5py #
########
# Download
cd /tmp
rm -f h5py-2.10.0.tar.gz
wget https://files.pythonhosted.org/packages/5f/97/a58afbcf40e8abecededd9512978b4e4915374e5b80049af082f49cebe9a/h5py-2.10.0.tar.gz
rm -rf h5py-2.10.0
tar zxf h5py-2.10.0.tar.gz

#pip install Cython

# Install
cd /tmp/h5py-2.10.0
export PATH=/home/miniconda3/bin:$PATH
export CC=mpicc
python setup.py configure --mpi --hdf5=/home/miniconda3
python setup.py build


##############
# tensorflow #
##############
pip install https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.2.0/tensorflow-2.2.0-cp37-none-linux_aarch64.whl

# Fixed pip depency
pip install https://tools.mindspore.cn/pypi/aarch64/ubuntu18_04_2/numpy-1.18.5-cp37-cp37m-linux_aarch64.whl
pip install https://tools.mindspore.cn/pypi/aarch64/ubuntu18_04_2/scipy-1.4.1-cp37-cp37m-linux_aarch64.whl
pip install https://tools.mindspore.cn/pypi/aarch64/ubuntu18_04_2/scipy-1.3.3-cp37-cp37m-linux_aarch64.whl

pip install https://tools.mindspore.cn/pypi/aarch64/euleros2_8/numpy-1.18.5-cp37-cp37m-linux_aarch64.whl
pip install https://tools.mindspore.cn/pypi/aarch64/euleros2_8/scipy-1.4.1-cp37-cp37m-linux_aarch64.whl
pip install https://tools.mindspore.cn/pypi/aarch64/euleros2_8/scipy-1.3.3-cp37-cp37m-linux_aarch64.whl

