Blame view

scripts/build_amdapy_doc.sh 1.68 KB
dab6ad76   Benjamin Renard   Add amdapy in inf...
1
2
3
4
5
6
#!/bin/bash

SCRIPT=$(readlink -f "$0")
export SCRIPTDIR=$(dirname "$SCRIPT")
export AMDA_IHM="$SCRIPTDIR/.."

22609c36   Myriam Bouchemit   git with https
7
GIT_REPOSITORY="https://github.com/cdppirap/amdapy.git"
dab6ad76   Benjamin Renard   Add amdapy in inf...
8
9
10
11
12

BUILD_DIR="$AMDA_IHM/scripts/amdapy_doc_build"
PYTHON_VENV="$BUILD_DIR/amdapy_venv"
AMDAPY_PATH="$BUILD_DIR/amdapy"

dab6ad76   Benjamin Renard   Add amdapy in inf...
13
14
DST_DIR="$AMDA_IHM/help"

27e9f307   Elena.Budnik   Automatically set...
15
16
17
18
19
20
21
22
HOSTNAME=`hostname`
if [ "$HOSTNAME" = "cdpp3" ]
then
    GIT_BRANCH="master"
else
    GIT_BRANCH="dev"
fi

dab6ad76   Benjamin Renard   Add amdapy in inf...
23
24
25
26
27
28
29
30
mkdir -p "$BUILD_DIR"

if [ -d "$PYTHON_VENV" ]
then
    # Activate virtual env.
    source "$PYTHON_VENV/bin/activate"
else
    # Build & activate virtual env.
27e9f307   Elena.Budnik   Automatically set...
31
    python3.6 -m venv "$PYTHON_VENV"
dab6ad76   Benjamin Renard   Add amdapy in inf...
32
33
    source "$PYTHON_VENV/bin/activate"
    pip install --upgrade pip
e8ccab45   Benjamin Renard   Update script use...
34
    pip install pandas numpy lxml matplotlib build sphinx nbsphinx ipython
dab6ad76   Benjamin Renard   Add amdapy in inf...
35
36
37
38
39
40
41
fi

if [ -d "$AMDAPY_PATH" ]
then
    # Pull repository
    cd $AMDAPY_PATH
    git checkout $GIT_BRANCH
22609c36   Myriam Bouchemit   git with https
42
    git pull -c http.sslVerify=0
dab6ad76   Benjamin Renard   Add amdapy in inf...
43
44
45
else
    # Clone repository
    cd $BUILD_DIR
22609c36   Myriam Bouchemit   git with https
46
    git clone -c http.sslVerify=0 $GIT_REPOSITORY
dab6ad76   Benjamin Renard   Add amdapy in inf...
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
    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