2021-04-03 18:18:50 -04:00
|
|
|
# This script is sourced by CI scripts to launch httpbin.
|
|
|
|
#
|
|
|
|
# Do not run it directly.
|
|
|
|
|
|
|
|
httpbin_launch() {
|
2021-05-16 17:00:16 -04:00
|
|
|
WX_TEST_WEBREQUEST_URL=0
|
|
|
|
export WX_TEST_WEBREQUEST_URL
|
|
|
|
|
|
|
|
# We need python3 for httpbin, python2 can't be used any longer.
|
|
|
|
if ! command -v python3 > /dev/null; then
|
|
|
|
echo 'Python 3 is not available, not using httpbin.'
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2021-04-03 18:18:50 -04:00
|
|
|
echo 'Launching httpbin...'
|
|
|
|
|
|
|
|
case "$(uname -s)" in
|
|
|
|
Linux)
|
2021-06-27 09:07:23 -04:00
|
|
|
if command -v lsb_release > /dev/null; then
|
|
|
|
dist_codename=$(lsb_release --codename --short)
|
|
|
|
fi
|
2021-04-03 18:18:50 -04:00
|
|
|
;;
|
2021-04-03 18:29:27 -04:00
|
|
|
|
|
|
|
Darwin)
|
|
|
|
dist_codename='macOS'
|
|
|
|
;;
|
2021-04-03 18:18:50 -04:00
|
|
|
esac
|
|
|
|
|
|
|
|
case "$dist_codename" in
|
|
|
|
trusty)
|
2021-04-05 11:56:09 -04:00
|
|
|
# Explicitly select the versions of dependencies that are still
|
|
|
|
# compatible with Python 3.4 used here as the latest versions of
|
|
|
|
# several of them are not.
|
|
|
|
pip_explicit_deps='Flask==1.0.4 Jinja2==2.10.3 MarkupSafe==1.1.1
|
|
|
|
blinker==1.4 brotlipy==0.7.0 cffi==1.14.5 click==7.0 decorator==4.4.2
|
|
|
|
itsdangerous==1.1.0 pycparser==2.20 raven==6.10.0 werkzeug==0.16.1'
|
2021-04-03 18:18:50 -04:00
|
|
|
;;
|
Try to fix problems with running httpbin in the CI builds
Fix the last known working Flask version, the latest one results in the
errors like the following
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/home/runner/.local/lib/python3.8/site-packages/httpbin/__init__.py", line 3, in <module>
from .core import *
File "/home/runner/.local/lib/python3.8/site-packages/httpbin/core.py", line 22, in <module>
from werkzeug.wrappers import BaseResponse
ImportError: cannot import name 'BaseResponse' from 'werkzeug.wrappers' (/home/runner/.local/lib/python3.8/site-packages/werkzeug/wrappers/__init__.py)
2022-03-29 14:07:11 -04:00
|
|
|
|
|
|
|
*)
|
|
|
|
# Installing Flask 2.1.0 and its dependency Werkzeug 2.1.0 results
|
|
|
|
# in failures when trying to run httpbin, so stick to an older but
|
|
|
|
# working version.
|
|
|
|
pip_explicit_deps='Flask==2.0.3 Werkzeug==2.0.3'
|
2021-04-03 18:18:50 -04:00
|
|
|
esac
|
|
|
|
|
2021-07-10 17:45:27 -04:00
|
|
|
# Ensure that we have at least some version of pip and setuptools required
|
|
|
|
# for installing cffi.
|
|
|
|
if ! python3 -c 'import setuptools'; then
|
|
|
|
sudo apt-get -q -o=Dpkg::Use-Pty=0 install python3-setuptools
|
|
|
|
fi
|
|
|
|
|
2021-06-27 13:42:37 -04:00
|
|
|
if ! python3 -c 'import pip'; then
|
2021-05-16 17:00:16 -04:00
|
|
|
sudo apt-get -q -o=Dpkg::Use-Pty=0 install python3-pip
|
2021-04-05 09:37:50 -04:00
|
|
|
fi
|
|
|
|
|
2021-05-16 17:00:16 -04:00
|
|
|
# Running pip install fails with weird errors out of the box when
|
|
|
|
# using old pip version because it attempts to use python rather
|
|
|
|
# than python3, so upgrade it to fix this.
|
|
|
|
#
|
|
|
|
# However don't upgrade to a version which is too new because then
|
|
|
|
# it may not support Python version that we actually have (this one
|
|
|
|
# still works with 3.4, 20.0.1 is the last one to support 3.5).
|
2022-06-29 16:00:33 -04:00
|
|
|
case "$dist_codename" in
|
|
|
|
jammy)
|
|
|
|
# pip is newer than 19.1 already, don't "upgrade" it.
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
python3 -m pip install --user --upgrade pip==19.1.1
|
|
|
|
python3 -m pip install --user wheel
|
|
|
|
esac
|
2021-04-03 19:45:01 -04:00
|
|
|
|
2021-05-16 17:00:16 -04:00
|
|
|
echo "Installing using `python3 -m pip --version`"
|
2021-04-03 18:18:50 -04:00
|
|
|
|
2021-05-16 17:00:16 -04:00
|
|
|
python3 -m pip install $pip_explicit_deps httpbin --user
|
2022-04-17 12:48:12 -04:00
|
|
|
python3 -m httpbin.core --port 50500 2>&1 >httpbin.log &
|
|
|
|
WX_TEST_WEBREQUEST_URL="http://localhost:50500"
|
2021-04-03 18:18:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
httpbin_show_log() {
|
2021-05-16 17:00:16 -04:00
|
|
|
if [ "$WX_TEST_WEBREQUEST_URL" != "0" ]; then
|
|
|
|
echo '*** Tests failed, contents of httpbin.log follows: ***'
|
|
|
|
echo '-----------------------------------------------------------'
|
|
|
|
cat httpbin.log
|
|
|
|
echo '-----------------------------------------------------------'
|
|
|
|
fi
|
2021-04-03 18:18:50 -04:00
|
|
|
}
|