-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmkdocs_installation.sh
More file actions
71 lines (55 loc) · 1.63 KB
/
mkdocs_installation.sh
File metadata and controls
71 lines (55 loc) · 1.63 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
#!/bin/bash
# This script sets up MkDocs for the geOrchestra documentation template
# Exit on error
set -e
echo "Checking Python and Python version"
# Try to find a suitable Python executable
PYTHON_BIN=""
# Function to compare Python versions
version_ge() {
# Compare two versions, returns 0 if $1 >= $2
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
}
# Check for python or python3
for cmd in python python3; do
if command -v $cmd >/dev/null 2>&1; then
VERSION=$($cmd -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
if version_ge "$VERSION" "3.11"; then
PYTHON_BIN=$cmd
break
fi
fi
done
if [ -z "$PYTHON_BIN" ]; then
echo "Python 3.11+ not found. Please install a suitable version."
exit 1
fi
# Python found !
echo "Using $PYTHON_BIN (version $VERSION)"
# Create the virtual environment
$PYTHON_BIN -m venv venv_mkdocs
echo "Virtual environment created in ./venv_mkdocs/"
# Activate the venv
if [ -n "$WINDIR" ] || [ -n "$MSYSTEM" ]; then
echo "Sorry : you are on Windows"
source venv_mkdocs/Scripts/activate
else
source venv_mkdocs/bin/activate
fi
# Install MkDocs and required plugins
echo "Installing MkDocs and plugins..."
python -m pip install -r mkdocs_requirements.txt
python -m pip list
echo ""
echo "======================================================================="
echo ""
echo ""
# Check if MkDocs was installed successfully
if ! mkdocs --version &> /dev/null; then
echo "Error: MkDocs installation failed"
exit 1
fi
# Desactivate the venv
deactivate
echo "MkDocs setup complete. "
echo "Please now run 'mkdocs_run.sh' to serve the documentation"