Debian Codegraph @

test/integration/targets/collections_runtime_pythonpath/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux -o pipefail
4
5
6 export PIP_DISABLE_PIP_VERSION_CHECK=1
7
8
9 source virtualenv.sh
10
11
12 >&2 echo '=== Test that the module gets picked up if discoverable via PYTHONPATH env var ==='
13 PYTHONPATH="${PWD}/ansible-collection-python-dist-boo:$PYTHONPATH" \
14 ansible \
15 -m python.dist.boo \
16 -a 'name=Bob' \
17 -c local localhost \
18 "$@" | grep -E '"greeting": "Hello, Bob!",'
19
20
21 >&2 echo '=== Test that the module gets picked up if installed into site-packages ==='
22 python -m pip install build
23 ( # Build a binary Python dist (a wheel) using build:
24 cp -r ansible-collection-python-dist-boo "${OUTPUT_DIR}/"
25 cd "${OUTPUT_DIR}/ansible-collection-python-dist-boo"
26 python -m build -w -o dist .
27 )
28 # Install a pre-built dist with pip:
29 python -m pip install \
30 --no-index \
31 -f "${OUTPUT_DIR}/ansible-collection-python-dist-boo/dist/" \
32 --only-binary=ansible-collections.python.dist \
33 ansible-collections.python.dist
34 python -m pip show ansible-collections.python.dist
35 ansible \
36 -m python.dist.boo \
37 -a 'name=Frodo' \
38 -c local localhost \
39 "$@" | grep -E '"greeting": "Hello, Frodo!",'
40
41
42 >&2 echo '=== Test that ansible_collections root takes precedence over PYTHONPATH/site-packages ==='
43 # This is done by injecting a module with the same FQCN
44 # into another collection root.
45 ANSIBLE_COLLECTIONS_PATH="${PWD}/ansible-collection-python-dist-foo" \
46 PYTHONPATH="${PWD}/ansible-collection-python-dist-boo:$PYTHONPATH" \
47 ansible \
48 -m python.dist.boo \
49 -a 'name=Степан' \
50 -c local localhost \
51 "$@" | grep -E '"greeting": "Привіт, Степан!",'