build_amdapy_doc.sh
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
SCRIPT=$(readlink -f "$0")
export SCRIPTDIR=$(dirname "$SCRIPT")
export AMDA_IHM="$SCRIPTDIR/.."
GIT_REPOSITORY="https://github.com/cdppirap/amdapy.git"
BUILD_DIR="$AMDA_IHM/scripts/amdapy_doc_build"
PYTHON_VENV="$BUILD_DIR/amdapy_venv"
AMDAPY_PATH="$BUILD_DIR/amdapy"
DST_DIR="$AMDA_IHM/help"
HOSTNAME=`hostname`
if [ "$HOSTNAME" = "cdpp3" ]
then
GIT_BRANCH="master"
else
GIT_BRANCH="dev"
fi
mkdir -p "$BUILD_DIR"
if [ -d "$PYTHON_VENV" ]
then
# Activate virtual env.
source "$PYTHON_VENV/bin/activate"
else
# Build & activate virtual env.
python3.6 -m venv "$PYTHON_VENV"
source "$PYTHON_VENV/bin/activate"
pip install --upgrade pip
pip install pandas numpy lxml matplotlib build sphinx nbsphinx ipython
fi
if [ -d "$AMDAPY_PATH" ]
then
# Pull repository
cd $AMDAPY_PATH
git checkout $GIT_BRANCH
git pull -c http.sslVerify=0
else
# Clone repository
cd $BUILD_DIR
git clone -c http.sslVerify=0 $GIT_REPOSITORY
cd $AMDAPY_PATH
git checkout $GIT_BRANCH
fi
# Package generation
cd $AMDAPY_PATH
python -m build
# Docs generation
cd $AMDAPY_PATH/amdapy/docs
make clean
make html
if [ ! -z "$DST_DIR" ]
then
# Export docs only if DST_DIR is not empty
if [ -d "$DST_DIR" ]
then
# Does not automatically create DST_DIR to prevent any improper handling
if [ -d "$DST_DIR/amdapy" ]
then
# Cleanup existing HTML dir
rm -Rf "$DST_DIR/amdapy"
fi
cp -R "$AMDAPY_PATH/amdapy/docs/_build/html" "$DST_DIR/amdapy"
else
echo "[WARNING] Destination directory not exists ($DST_DIR). Cannot export documentation\n"
fi
fi
# Deactivate virtual env.
deactivate