aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichal Arbet <michal.arbet@ultimum.io>2021-04-08 00:36:14 +0200
committerMichal Arbet <michal.arbet@ultimum.io>2021-04-08 12:31:00 +0000
commit22a6765f5e0ddae1527faaaeeff0260f5996a9e7 (patch)
treeb55c0c58455542e09ca22cf92cf7d4fb4ffa879f /tools
parentf49f9909cac8c4da214e71fa13d2174f1ae3f18b (diff)
downloadkolla-ansible-22a6765f5e0ddae1527faaaeeff0260f5996a9e7.tar.gz
kolla-ansible-22a6765f5e0ddae1527faaaeeff0260f5996a9e7.zip
Support editable installation in all cases
An editable installation allows changes to be made to the source code directly, and have those changes applied immediately without having to reinstall. pip install -e /path/to/kolla-ansible Above is currently working only in virtualenv, but there is no reason to not allow in all cases. This is usefull for example when user is building his own docker container with editable kolla-ansible installed from git without virtualenv. Change-Id: I185f7c09c3f026fd6926a26001393f066ff1860d
Diffstat (limited to 'tools')
-rwxr-xr-xtools/kolla-ansible28
1 files changed, 23 insertions, 5 deletions
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index 215bcf0ee..014e19003 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -22,6 +22,7 @@ function check_environment_coherence {
local ansible_python_cmdline
# NOTE(yoctozepto): may have multiple parts
ansible_python_cmdline=${ansible_shebang_line#\#\!}
+ ansible_python_version=$($ansible_python_cmdline -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
if ! $ansible_python_cmdline --version &>/dev/null; then
echo "ERROR: Ansible Python is not functional." >&2
@@ -66,21 +67,38 @@ function check_environment_coherence {
function find_base_dir {
local dir_name
+ local python_dir
dir_name=$(dirname "$0")
# NOTE(yoctozepto): Fix the case where dir_name is a symlink and VIRTUAL_ENV might not be. This
# happens with pyenv-virtualenv, see https://bugs.launchpad.net/kolla-ansible/+bug/1903887
dir_name=$(readlink -e "$dir_name")
+ python_dir="python${ansible_python_version}"
if [ -z "$SNAP" ]; then
if [[ ${dir_name} == "/usr/bin" ]]; then
- BASEDIR=/usr/share/kolla-ansible
+ if test -f /usr/lib/${python_dir}/*-packages/kolla-ansible.egg-link; then
+ # Editable install.
+ BASEDIR="$(head -n1 /usr/lib/${python_dir}/*-packages/kolla-ansible.egg-link)"
+ else
+ BASEDIR=/usr/share/kolla-ansible
+ fi
elif [[ ${dir_name} == "/usr/local/bin" ]]; then
- BASEDIR=/usr/local/share/kolla-ansible
+ if test -f /usr/local/lib/${python_dir}/*-packages/kolla-ansible.egg-link; then
+ # Editable install.
+ BASEDIR="$(head -n1 /usr/local/lib/${python_dir}/*-packages/kolla-ansible.egg-link)"
+ else
+ BASEDIR=/usr/local/share/kolla-ansible
+ fi
elif [[ ${dir_name} == ~/.local/bin ]]; then
- BASEDIR=~/.local/share/kolla-ansible
+ if test -f ~/.local/lib/${python_dir}/*-packages/kolla-ansible.egg-link; then
+ # Editable install.
+ BASEDIR="$(head -n1 ~/.local/lib/${python_dir}/*-packages/kolla-ansible.egg-link)"
+ else
+ BASEDIR=~/.local/share/kolla-ansible
+ fi
elif [[ -n ${VIRTUAL_ENV} ]] && [[ ${dir_name} == "$(readlink -e "${VIRTUAL_ENV}/bin")" ]]; then
- if test -f ${VIRTUAL_ENV}/lib/python*/site-packages/kolla-ansible.egg-link; then
+ if test -f ${VIRTUAL_ENV}/lib/${python_dir}/site-packages/kolla-ansible.egg-link; then
# Editable install.
- BASEDIR="$(head -n1 ${VIRTUAL_ENV}/lib/python*/site-packages/kolla-ansible.egg-link)"
+ BASEDIR="$(head -n1 ${VIRTUAL_ENV}/lib/${python_dir}/*-packages/kolla-ansible.egg-link)"
else
BASEDIR="${VIRTUAL_ENV}/share/kolla-ansible"
fi