From c93ca1841cad6f7dc1723b96cbeed924309c5dc1 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 27 Oct 2022 23:17:05 +0200 Subject: [PATCH] Docker & python - Use pip conditional requirements to not install playwright for ARM (unsupported on ARM) (#1067) --- Dockerfile | 6 ----- changedetectionio/run_all_tests.sh | 4 ---- requirements.txt | 37 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Dockerfile b/Dockerfile index 978a912c..373334f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,12 +21,6 @@ COPY requirements.txt /requirements.txt RUN pip install --target=/dependencies -r /requirements.txt -# Playwright is an alternative to Selenium -# Excluded this package from requirements.txt to prevent arm/v6 and arm/v7 builds from failing -RUN pip install --target=/dependencies playwright~=1.26 \ - || echo "WARN: Failed to install Playwright. The application can still run, but the Playwright option will be disabled." - - RUN pip install --target=/dependencies jq~=1.3 \ || echo "WARN: Failed to install JQ. The application can still run, but the Jq: filter option will be disabled." diff --git a/changedetectionio/run_all_tests.sh b/changedetectionio/run_all_tests.sh index 4eff9e93..79886c00 100755 --- a/changedetectionio/run_all_tests.sh +++ b/changedetectionio/run_all_tests.sh @@ -46,10 +46,6 @@ unset WEBDRIVER_URL docker kill $$-test_selenium echo "TESTING WEBDRIVER FETCH > PLAYWRIGHT/BROWSERLESS..." -# Not all platforms support playwright (not ARM/rPI), so it's not packaged in requirements.txt -PLAYWRIGHT_VERSION=$(grep -i -E "RUN pip install.+" "$SCRIPT_DIR/../Dockerfile" | grep --only-matching -i -E "playwright[=><~+]+[0-9\.]+") -echo "using $PLAYWRIGHT_VERSION" -pip3 install "$PLAYWRIGHT_VERSION" docker run -d --name $$-test_browserless -e "DEFAULT_LAUNCH_ARGS=[\"--window-size=1920,1080\"]" --rm -p 3000:3000 --shm-size="2g" browserless/chrome:1.53-chrome-stable # takes a while to spin up sleep 5 diff --git a/requirements.txt b/requirements.txt index 615ca55a..6362f9e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,36 +1,36 @@ -flask ~= 2.0 +flask~=2.0 flask_wtf -eventlet >= 0.31.0 +eventlet>=0.31.0 validators -timeago ~= 1.0 -inscriptis ~= 2.2 -feedgen ~= 0.9 -flask-login ~= 0.5 +timeago~=1.0 +inscriptis~=2.2 +feedgen~=0.9 +flask-login~=0.5 flask_restful pytz # Set these versions together to avoid a RequestsDependencyWarning # >= 2.26 also adds Brotli support if brotli is installed -brotli ~= 1.0 -requests[socks] ~= 2.28 +brotli~=1.0 +requests[socks] ~=2.28 -urllib3 > 1.26 -chardet > 2.3.0 +urllib3>1.26 +chardet>2.3.0 -wtforms ~= 3.0 -jsonpath-ng ~= 1.5.3 +wtforms~=3.0 +jsonpath-ng~=1.5.3 # jq not available on Windows so must be installed manually # Notification library -apprise ~= 1.1.0 +apprise~=1.1.0 # apprise mqtt https://github.com/dgtlmoon/changedetection.io/issues/315 paho-mqtt # Pinned version of cryptography otherwise # ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly -cryptography ~= 3.4 +cryptography~=3.4 # Used for CSS filtering bs4 @@ -39,16 +39,17 @@ bs4 lxml # 3.141 was missing socksVersion, 3.150 was not in pypi, so we try 4.1.0 -selenium ~= 4.1.0 +selenium~=4.1.0 # https://stackoverflow.com/questions/71652965/importerror-cannot-import-name-safe-str-cmp-from-werkzeug-security/71653849#71653849 # ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' # need to revisit flask login versions -werkzeug ~= 2.0.0 +werkzeug~=2.0.0 # Templating, so far just in the URLs but in the future can be for the notifications also -jinja2 ~= 3.1 +jinja2~=3.1 jinja2-time -# playwright is installed at Dockerfile build time because it's not available on all platforms +playwright~=1.26; python_version >= "3.8" and "arm" not in platform_machine and "aarch" not in platform_machine +