-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·126 lines (113 loc) · 3.89 KB
/
install.sh
File metadata and controls
executable file
·126 lines (113 loc) · 3.89 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="${ROOT_DIR}/.venv"
PYTHON_BIN="${PYTHON_BIN:-python3}"
OS_MODE="windows"
VENV_PYTHON=""
VENV_PIP=""
usage() {
cat <<'USAGE'
Bootstrap the local Python environment and print repo workflow commands.
Usage:
./install.sh [--os-windows|--os-window|--os-linux]
Options:
--os-windows Print Windows (PowerShell) command examples. Default.
--os-window Alias for --os-windows.
--os-linux Print Linux/macOS shell command examples.
-h, --help Show this help.
Examples:
./install.sh
./install.sh --os-windows
./install.sh --os-linux
USAGE
}
while [[ $# -gt 0 ]]; do
case "$1" in
--os-windows|--os-window)
OS_MODE="windows"
shift
;;
--os-linux)
OS_MODE="linux"
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "ERROR: Unknown argument: $1" >&2
usage
exit 1
;;
esac
done
if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then
echo "ERROR: ${PYTHON_BIN} not found on PATH" >&2
exit 1
fi
if [ ! -d "${VENV_DIR}" ]; then
"${PYTHON_BIN}" -m venv "${VENV_DIR}"
fi
if [ -x "${VENV_DIR}/bin/python" ]; then
VENV_PYTHON="${VENV_DIR}/bin/python"
VENV_PIP="${VENV_DIR}/bin/pip"
elif [ -x "${VENV_DIR}/Scripts/python.exe" ]; then
VENV_PYTHON="${VENV_DIR}/Scripts/python.exe"
VENV_PIP="${VENV_DIR}/Scripts/pip.exe"
else
echo "ERROR: Could not find venv Python in ${VENV_DIR}/bin or ${VENV_DIR}/Scripts" >&2
exit 1
fi
"${VENV_PYTHON}" -m pip install --upgrade pip setuptools wheel
"${VENV_PIP}" install -e "${ROOT_DIR}[dev]"
print_windows_examples() {
echo "Windows (PowerShell) commands (default examples):"
echo " .\\.venv\\Scripts\\Activate.ps1"
echo " python .\\tools\\postman\\sync_visualizers.py --check"
echo " python .\\tools\\postman\\sync_visualizers.py --update"
echo " python .\\tools\\postman\\sync_visualizers.py --check --collection postman/collections/PyPNM-CMTS --visual-root visual/PyPNM-CMTS"
echo " python .\\tools\\postman\\sync_visualizers.py --update --collection postman/collections/PyPNM-CMTS --visual-root visual/PyPNM-CMTS"
echo " python .\\tools\\sanitize.py --check"
echo " python .\\tools\\sanitize.py --fix"
echo " python .\\tools\\docs\\build_visual_docs.py"
echo " pytest -q"
echo " mkdocs serve -a 127.0.0.1:8030"
}
print_linux_examples() {
echo "Linux/macOS shell commands:"
echo " source .venv/bin/activate"
echo " tools/postman/sync_visualizers.py --check"
echo " tools/postman/sync_visualizers.py --update"
echo " tools/postman/sync_visualizers.py --check --collection postman/collections/PyPNM-CMTS --visual-root visual/PyPNM-CMTS"
echo " tools/postman/sync_visualizers.py --update --collection postman/collections/PyPNM-CMTS --visual-root visual/PyPNM-CMTS"
echo " tools/sanitize.py --check"
echo " tools/sanitize.py --fix"
echo " tools/docs/build_visual_docs.py"
echo " pytest -q"
echo " mkdocs serve -a 127.0.0.1:8030"
}
echo "Python virtual environment ready at: ${VENV_DIR}"
echo "Activate it with:"
echo " source ${VENV_DIR}/bin/activate"
echo "OS mode for printed examples: ${OS_MODE}"
if [[ "${OS_MODE}" == "windows" ]]; then
print_windows_examples
echo "Linux/macOS equivalent (optional):"
echo " source .venv/bin/activate"
else
print_linux_examples
fi
echo "Version / release tools:"
echo " tools/support/bump_version.py --version X.Y.Z --check"
echo " tools/support/bump_version.py --version X.Y.Z"
echo " tools/release/release.py --version-info"
echo "Recommended visual workflow:"
echo " 1) Sync visualizer scripts"
echo " tools/postman/sync_visualizers.py --update"
echo " tools/postman/sync_visualizers.py --update --collection postman/collections/PyPNM-CMTS --visual-root visual/PyPNM-CMTS"
echo " 2) Regenerate visual docs"
echo " tools/docs/build_visual_docs.py"
echo " 3) Run tests"
echo " pytest -q"