-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrp-installer.sh
executable file
·59 lines (44 loc) · 1.62 KB
/
nrp-installer.sh
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
#!/bin/bash
# This script installs the NRP repository tools
# Environment variables
# PYTHON:
# python executable to use for installation and running the NRP tools
# NRP_GIT_URL:
# URL of the NRP git repository
# NRP_GIT_BRANCH:
# branch of the NRP git repository to use
# LOCAL_NRP_DEVTOOLS_LOCATION:
# location of the local NRP repository.
# If set, do not clone the NRP repository but use the local one.
set -e
NRP_GIT_URL=${NRP_GIT_URL:-https://github.com/oarepo/nrp-devtools.git}
NRP_GIT_BRANCH=${NRP_GIT_BRANCH:-main}
SUPPORTED_PYTHON_VERSIONS=(3.10 3.9)
if [ -z "$PYTHON" ] ; then
# find a supported python
for version in "${SUPPORTED_PYTHON_VERSIONS[@]}"; do
if command -v python$version >/dev/null 2>&1; then
PYTHON=python$version
break
fi
done
if [ -z "$PYTHON" ] ; then
echo "No supported python version found. Please install python 3.9 or higher
or set the PYTHON environment variable to the python executable."
exit 1
fi
fi
# clone nrp tool to a temporary directory
ACTUAL_DIR="$(pwd)"
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
echo "Installing temporary NRP CLI to $TMP_DIR, will clean it up on exit."
$PYTHON -m venv "$TMP_DIR/.venv"
source "$TMP_DIR/.venv/bin/activate"
pip install -U setuptools pip wheel
if [ -z "$LOCAL_NRP_DEVTOOLS_LOCATION" ] ; then
LOCAL_NRP_DEVTOOLS_LOCATION="$TMP_DIR/nrp-devtools"
git clone "$NRP_GIT_URL" --branch "$NRP_GIT_BRANCH" --depth 1 "$LOCAL_NRP_DEVTOOLS_LOCATION"
fi
pip install -e "$LOCAL_NRP_DEVTOOLS_LOCATION"
"$TMP_DIR"/.venv/bin/nrp-devtools initialize "$@"