6 target="${dir}/python_modules"
20 target="${dir}/python_modules"
21 echo >&2 "Will install python modules in: '${target}'"
27 echo >&2 "Will install python modules system-wide"
32 echo "${0} [--dir netdata-python.d-path] [--system]"
37 echo >&2 "Cannot understand parameter: ${1}"
44 if [ ! -z "${target}" -a ! -d "${target}" ]
46 echo >&2 "Cannot find directory: '${target}'"
50 if [[ "${pv}" =~ ^Python\ 2.* ]]
53 pip="$(which pip2 2>/dev/null)"
54 elif [[ "${pv}" =~ ^Python\ 3.* ]]
57 pip="$(which pip3 2>/dev/null)"
59 echo >&2 "Cannot detect python version"
63 [ -z "${pip}" ] && pip="$(which pip 2>/dev/null)"
66 echo >&2 "pip command is required to install python v${pv} modules"
70 echo >&2 "Working for python version ${pv} (pip command: '${pip}')"
71 echo >&2 "Installing netdata python modules in: '${target}'"
74 printf "Running command:\n# "
80 # try to install all the python modules given as parameters
81 # until the first that succeeds
90 echo >&2 "Installing one of: ${*}"
95 echo >&2 "attempting to install: ${x}"
96 if [ ! -z "${target}" ]
98 run "${pip}" install --target "${target}" "${x}"
101 run "${pip}" install "${x}"
104 [ ${ret} -eq 0 ] && break
105 echo >&2 "failed to install: ${x}"
110 echo >&2 "ERROR: could not install any of: ${*}"
111 errors=$(( errors + 1 ))
112 failed="${failed}|${*}"
114 echo >&2 "SUCCESS: we have: ${x}"
115 installed="${installed} ${x}"
122 pip_install pyyaml yaml
123 pip_install mysqlclient mysql-python pymysql
125 pip_install yaml pyyaml
126 pip_install mysql-python mysqlclient pymysql
131 if [ ${errors} -ne 0 ]
133 echo >&2 "Failed to install ${errors} modules: ${failed}"
136 echo >&2 "All done. We have: ${installed}"