From 8593c85f9934f3cb2be8fbf71d4eae92873f9b2b Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Mon, 10 Aug 2020 17:29:30 +0200 Subject: [PATCH] Fix versions in requirements.txt for python 3.5 and 3.9 (#20507) Packages listed in current requirements.txt file cannot be installed in python 3.5 and 3.9: * Pillow doesn't have a candidate for 3.9, it was already removed in #20407, but added again by mistake in #16883. * zipp package needed by pytest works with different versions depending on the version of python, version that works with python 3.5 doesn't work with other versions. --- libbeat/tests/system/requirements.txt | 3 +- script/check_python_requirements.sh | 46 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100755 script/check_python_requirements.sh diff --git a/libbeat/tests/system/requirements.txt b/libbeat/tests/system/requirements.txt index 9bd40616f8f..00eff11c5d9 100644 --- a/libbeat/tests/system/requirements.txt +++ b/libbeat/tests/system/requirements.txt @@ -25,7 +25,6 @@ more-itertools==8.4.0 ordered-set==3.1.1 packaging==20.4 parameterized==0.7.0 -Pillow==7.2.0 pluggy==0.13.1 py==1.9.0 pycodestyle==2.4.0 @@ -45,4 +44,4 @@ toml==0.10.1 urllib3==1.24.2 wcwidth==0.2.5 websocket-client==0.47.0 -zipp==3.1.0 +zipp>=1.2.0,<=3.1.0 diff --git a/script/check_python_requirements.sh b/script/check_python_requirements.sh new file mode 100755 index 00000000000..3ba5924a4c6 --- /dev/null +++ b/script/check_python_requirements.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# Helper script to check that packages defined in a requirements.txt +# file can be installed in different Python versions, it checks by +# default the requirements.txt file for libbeat tests. +# +# Usage: check_python_requirements.sh /path/to/requirements.txt +# +# VERSIONS environment variable can be set to a space-separated list +# of versions of python to test with. +# + +set -e + +function abspath() { + local path=$1 + if [ -d "$path" ]; then + cd "$path"; pwd; cd - > /dev/null + else + echo $(abspath "$(dirname "$path")")/$(basename "$path") + fi +} + +BEATS_PATH=$(abspath "$(dirname "${BASH_SOURCE[0]}")"/..) + +VERSIONS=${VERSIONS:-3.5 3.6 3.7 3.8 3.9-rc} +REQUIREMENTS=${1:-${BEATS_PATH}/libbeat/tests/system/requirements.txt} + +if [ ! -f "$REQUIREMENTS" ]; then + echo "Requirements file doesn't exist: $REQUIREMENTS" + exit -1 +fi + +REQUIREMENTS=$(abspath "$REQUIREMENTS") + +echo "Versions: $VERSIONS" +echo "Requirements file: $REQUIREMENTS" + +for version in $VERSIONS; do + echo "==== Version: $version" + + docker run -it --rm -v "$REQUIREMENTS":/requirements.txt python:$version \ + python -m pip install -q -r /requirements.txt + + echo "==== OK" +done