-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchebsite-setup.sh
More file actions
112 lines (94 loc) · 3.55 KB
/
chebsite-setup.sh
File metadata and controls
112 lines (94 loc) · 3.55 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# chebsite-setup.sh: Set up workspace for Chebfun website development.
# Based on/ported from Hrothgar's chebsite_setup.m.
# Written By: Anthony P. Austin, May 4, 2016.
die()
{
if [ $# -gt 0 ] ; then
echo "${1}"
fi
echo "Aborting."
exit 1
}
get_permission_to_continue()
{
local REPLY=""
while read -ep "> " REPLY ; do
case "${REPLY}" in
[Yy]) break ;;
[Nn]) die ;;
esac
done
}
################################################################################
cat <<EOF
First navigate to where you want the Chebfun website's folder to be located.
Then run this script from there. For example, to set up the site at
~/my_folder/chebsite, copy this script into "my_folder". Note that this script
will also clone the examples and guide repos.
Your current location is ${PWD}.
Do you wish to set up the site here? [Y/N]
EOF
get_permission_to_continue
# Check for a few needed utilities. Of these, only the check for pip is likely
# to fail on Linux and/or OS X. On Cygwin, the likelihood of missing Git or
# Python is higher.
if ! command -v git &> /dev/null ; then
cat <<EOF
Could not find Git. Please install Git before proceeding with setup.
EOF
exit 1
elif ! command -v python &> /dev/null ; then
cat <<EOF
Could not find Python. The website scripts require Python to run. Please
install Python before proceeding with setup.
EOF
exit 1
elif ! command -v pip &> /dev/null ; then
cat <<EOF
Could not find the 'pip' package manager for Python. Please install pip before
proceeding with setup.
(Hint: On OS X, 'sudo easy_install pip' should do the trick.)
EOF
exit 1
fi
# Clone the various repositories.
mkdir chebsite || die "Could not make directory chebsite/."
git clone https://github.com/chebfun/chebsite.git chebsite \
|| die "Could not clone chebsite repository."
mkdir 'chebsite/_build' || die "Could not make directory chebsite/_build/."
git clone https://github.com/chebfun/chebfun.github.io.git "chebsite/_build" \
|| die "Could not clone chebfun.github.io repository."
mkdir examples || die "Could not make directory examples/."
git clone https://github.com/chebfun/examples.git examples \
|| die "Could not clone examples repository."
mkdir guide || die "Could not make directory guide/."
git clone https://github.com/chebfun/guide.git guide \
|| die "Could not clone guide repository."
# Install the needed Python modules.
#
# NB: The "wheel" package needs to be installed/upgraded first.
pip install --user --upgrade wheel
pip install --user MarkupSafe Jinja2 PyYAML Markdown
# Need to handle the python_dateutil module a little differently, as it's
# typically installed with the system Python distribution. We need to install
# it if it's not present and upgrade it if it's present but out-of-date.
if ! python -c "import dateutil" &> /dev/null ; then
pip install --user python_dateutil
else
DU_VER=$(python -c "import dateutil; print(dateutil.__version__)")
if [ $(echo "${DU_VER}" | cut -d '.' -f 1) -le 1 ] ; then
cat <<EOF
The installed version of the 'python_dateutil' Python module is ${DU_VER}. The
website build scripts require this module to be v2.0 or later.
If this module comes packaged with your Python installation, it is best to
upgrade it by upgrading Python. This may not be possible if you are running on
a system on which you do not have administrative privileges. In this case, or
if you would prefer, we can install an upgraded version in your home directory
instead.
Install upgraded python_dateutil module in home directory? [Y/N]
EOF
get_permission_to_continue
pip install --upgrade --user python_dateutil
fi
fi