-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvironment.sh
executable file
·89 lines (67 loc) · 2.62 KB
/
Environment.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
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
#!/bin/bash -e
forceEnv="${1:-NoForce}"
if [[ -z "${PYTHON_ENV_1698421895}" ]] || [[ ${forceEnv} == "Force" ]] ;
then
export PYTHON_ENV_1698421895=1
#---------------------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------------------
function DoesPipConfigExist ()
{
if ! test -f "${PIP_CONFIG_FILE}"; then
echo "Error: pip.conf does not exist."
echo "Info: Create a symbolic link to the target pip.conf."
return 1
fi
return 0
}
export -f DoesPipConfigExist
#---------------------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------------------
function DoesRequirementsTxtExist ()
{
if ! test -f "requirements.txt"; then
echo "Error: requirements.txt does not exist."
echo "Info: Create a symbolic link to the target requirements.txt."
return 1
fi
return 0
}
export -f DoesRequirementsTxtExist
#---------------------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------------------
function PipDownload ()
{
packages="${1}"
# VirtEnv/bin/python -m pip download --cert=${APS_ZSCALER_CERT} --dest ${PYTHON_PACKAGES_DIR} ${packages} || return 1
VirtEnv/bin/python -m pip download --dest "${PYTHON_PACKAGES_DIR}" ${packages} || return 1
}
export -f PipDownload
#---------------------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------------------
function PipInstall ()
{
packages="${1}"
if (( ONLINE_INSTALL == 1 )) ; then
PipDownload "${packages}" || return 1
fi
VirtEnv/bin/python -m pip install --no-index --find-links "${PYTHON_PACKAGES_DIR}" ${packages} || return 1
}
export -f PipInstall
#---------------------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------------------
# Move to the script directory
scriptDir_1678483151=$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")" ; pwd -P)
pushd "${scriptDir_1678483151}" > /dev/null
# Configure the environment
export ONLINE_INSTALL=1
export PIP_CONFIG_FILE=${scriptDir_1678483151}/pip.conf
export PYTHON_PACKAGES_DIR=${scriptDir_1678483151}/Packages
mkdir -p "${PYTHON_PACKAGES_DIR}"
# Restore the original directory
popd > /dev/null
fi