Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ansible-cmdb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,21 @@ dbg () {

# Find suitable python binary
find_py_bin () {
which -a python | while read -r TRY_PY_BIN
# An interpreter sitting next to this script wins. When installed into a
# virtualenv, that is the interpreter the package was installed for, and
# it is the only one that can import ansiblecmdb. Searching $PATH first
# would pick the system python whenever the venv isn't activated.
SELF_DIR=$(dirname "$0")
for SIBLING in "$SELF_DIR/python3" "$SELF_DIR/python"
do
if [ -x "$SIBLING" ]; then
dbg "Using interpreter next to wrapper: $SIBLING"
echo "$SIBLING"
return 0
fi
done

which -a python3 python2 python | while read -r TRY_PY_BIN
do
dbg "Trying python bin: $TRY_PY_BIN"

Expand Down