From 8c25a81009ad03a17cc8707f9ff2ce8890e77fa1 Mon Sep 17 00:00:00 2001 From: c01o Date: Fri, 27 Oct 2023 05:59:25 +0900 Subject: [PATCH] Remove playwright from armv7 --- README.md | 1 + archivebox/main.py | 43 +++++++++++++++++++++++-------------------- pyproject.toml | 2 +- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 20dac770..58d58c13 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ ls ./archive/*/index.json # or browse directly via the filesyste # Quickstart **🖥  Supported OSs:** Linux/BSD, macOS, Windows (Docker/WSL)   **👾  CPUs:** amd64, x86, arm8, arm7 (raspi>=3) +Note: On arm7, the `playwright` package, provides easy `chromium` management, is not yet available. Do it manually with alternative methods.
diff --git a/archivebox/main.py b/archivebox/main.py index e56479f6..83adaba8 100755 --- a/archivebox/main.py +++ b/archivebox/main.py @@ -976,27 +976,30 @@ def setup(out_dir: Path=OUTPUT_DIR) -> None: stderr(f'[X] Failed to install python packages: {e}', color='red') raise SystemExit(1) - stderr('\n Installing CHROME_BINARY automatically using playwright...') - if CHROME_VERSION: - print(f'{CHROME_VERSION} is already installed', CHROME_BINARY) + if platform.machine() == 'armv7l': + stderr('\n Skip the automatic installation of CHROME_BINARY because playwright is not available on armv7.') else: - try: - run_shell([ - PYTHON_BINARY, '-m', 'pip', - 'install', - '--upgrade', - '--no-cache-dir', - '--no-warn-script-location', - 'playwright', - ], capture_output=False, cwd=out_dir) - run_shell([PYTHON_BINARY, '-m', 'playwright', 'install', 'chromium'], capture_output=False, cwd=out_dir) - proc = run_shell([PYTHON_BINARY, '-c', 'from playwright.sync_api import sync_playwright; print(sync_playwright().start().chromium.executable_path)'], capture_output=True, text=True, cwd=out_dir) - NEW_CHROME_BINARY = proc.stdout.decode().strip() if isinstance(proc.stdout, bytes) else proc.stdout.strip() - assert NEW_CHROME_BINARY and len(NEW_CHROME_BINARY), 'CHROME_BINARY must contain a path' - config(f'CHROME_BINARY={NEW_CHROME_BINARY}', set=True, out_dir=out_dir) - except BaseException as e: # lgtm [py/catch-base-exception] - stderr(f'[X] Failed to install chromium using playwright: {e.__class__.__name__} {e}', color='red') - raise SystemExit(1) + stderr('\n Installing CHROME_BINARY automatically using playwright...') + if CHROME_VERSION: + print(f'{CHROME_VERSION} is already installed', CHROME_BINARY) + else: + try: + run_shell([ + PYTHON_BINARY, '-m', 'pip', + 'install', + '--upgrade', + '--no-cache-dir', + '--no-warn-script-location', + 'playwright', + ], capture_output=False, cwd=out_dir) + run_shell([PYTHON_BINARY, '-m', 'playwright', 'install', 'chromium'], capture_output=False, cwd=out_dir) + proc = run_shell([PYTHON_BINARY, '-c', 'from playwright.sync_api import sync_playwright; print(sync_playwright().start().chromium.executable_path)'], capture_output=True, text=True, cwd=out_dir) + NEW_CHROME_BINARY = proc.stdout.decode().strip() if isinstance(proc.stdout, bytes) else proc.stdout.strip() + assert NEW_CHROME_BINARY and len(NEW_CHROME_BINARY), 'CHROME_BINARY must contain a path' + config(f'CHROME_BINARY={NEW_CHROME_BINARY}', set=True, out_dir=out_dir) + except BaseException as e: # lgtm [py/catch-base-exception] + stderr(f'[X] Failed to install chromium using playwright: {e.__class__.__name__} {e}', color='red') + raise SystemExit(1) stderr('\n Installing SINGLEFILE_BINARY, READABILITY_BINARY, MERCURY_BINARY automatically using npm...') if not NODE_VERSION: diff --git a/pyproject.toml b/pyproject.toml index aee8ac84..acd8571a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "w3lib>=1.22.0", # "youtube-dl>=2021.04.17", "yt-dlp>=2021.4.11", - "playwright>=1.39.0", + "playwright>=1.39.0; platform_machine != 'armv7l'", ] requires-python = ">=3.9" readme = "README.md"