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
|
#!/usr/bin/env bash
set -eux -o pipefail
export PIP_DISABLE_PIP_VERSION_CHECK=1
source virtualenv.sh
>&2 echo '=== Test that the module gets picked up if discoverable via PYTHONPATH env var ==='
PYTHONPATH="${PWD}/ansible-collection-python-dist-boo:$PYTHONPATH" \
ansible \
-m python.dist.boo \
-a 'name=Bob' \
-c local localhost \
"$@" | grep -E '"greeting": "Hello, Bob!",'
>&2 echo '=== Test that the module gets picked up if installed into site-packages ==='
python -m pip install build
( # Build a binary Python dist (a wheel) using build:
cp -r ansible-collection-python-dist-boo "${OUTPUT_DIR}/"
cd "${OUTPUT_DIR}/ansible-collection-python-dist-boo"
python -m build -w -o dist .
)
# Install a pre-built dist with pip:
python -m pip install \
--no-index \
-f "${OUTPUT_DIR}/ansible-collection-python-dist-boo/dist/" \
--only-binary=ansible-collections.python.dist \
ansible-collections.python.dist
python -m pip show ansible-collections.python.dist
ansible \
-m python.dist.boo \
-a 'name=Frodo' \
-c local localhost \
"$@" | grep -E '"greeting": "Hello, Frodo!",'
>&2 echo '=== Test that ansible_collections root takes precedence over PYTHONPATH/site-packages ==='
# This is done by injecting a module with the same FQCN
# into another collection root.
ANSIBLE_COLLECTIONS_PATH="${PWD}/ansible-collection-python-dist-foo" \
PYTHONPATH="${PWD}/ansible-collection-python-dist-boo:$PYTHONPATH" \
ansible \
-m python.dist.boo \
-a 'name=Степан' \
-c local localhost \
"$@" | grep -E '"greeting": "Привіт, Степан!",'
|