From a09e851dc4f6327d847c8a6a2f34e82317b534d6 Mon Sep 17 00:00:00 2001 From: Konstantin Alekseev Date: Wed, 23 Oct 2024 14:50:42 +0300 Subject: [PATCH] playwright: 1.48.1 -> 1.50.1 --- nixos/tests/playwright-python.nix | 13 +-- .../python-modules/playwright/default.nix | 18 +++-- .../playwright/driver-location.patch | 20 ----- .../python-modules/playwright/update.sh | 16 ++-- pkgs/development/web/playwright/browsers.json | 20 +++-- .../playwright/chromium-headless-shell.nix | 81 +++++++++++++++++++ pkgs/development/web/playwright/chromium.nix | 4 +- pkgs/development/web/playwright/driver.nix | 20 +++-- pkgs/development/web/playwright/ffmpeg.nix | 8 +- pkgs/development/web/playwright/firefox.nix | 8 +- pkgs/development/web/playwright/webkit.nix | 71 ++++++++++++++-- 11 files changed, 208 insertions(+), 71 deletions(-) create mode 100644 pkgs/development/web/playwright/chromium-headless-shell.nix diff --git a/nixos/tests/playwright-python.nix b/nixos/tests/playwright-python.nix index 0a5deecbb508..02d7b1cc5b9d 100644 --- a/nixos/tests/playwright-python.nix +++ b/nixos/tests/playwright-python.nix @@ -25,19 +25,20 @@ import ./make-test-python.nix ( from playwright.sync_api import expect browsers = { - "chromium": ["--headless", "--disable-gpu"], - "firefox": [], - "webkit": [] + "chromium": {'args': ["--headless", "--disable-gpu"], 'channel': 'chromium'}, + "firefox": {}, + "webkit": {} } if len(sys.argv) != 3 or sys.argv[1] not in browsers.keys(): print(f"usage: {sys.argv[0]} [{'|'.join(browsers.keys())}] ") sys.exit(1) browser_name = sys.argv[1] url = sys.argv[2] - browser_args = browsers.get(browser_name) - print(f"Running test on {browser_name} {' '.join(browser_args)}") + browser_kwargs = browsers.get(browser_name) + args = ' '.join(browser_kwargs.get('args', [])) + print(f"Running test on {browser_name} {args}") with sync_playwright() as p: - browser = getattr(p, browser_name).launch(args=browser_args) + browser = getattr(p, browser_name).launch(**browser_kwargs) context = browser.new_context() page = context.new_page() page.goto(url) diff --git a/pkgs/development/python-modules/playwright/default.nix b/pkgs/development/python-modules/playwright/default.nix index 0937fc0269c5..610e9c58b5ce 100644 --- a/pkgs/development/python-modules/playwright/default.nix +++ b/pkgs/development/python-modules/playwright/default.nix @@ -22,15 +22,15 @@ in buildPythonPackage rec { pname = "playwright"; # run ./pkgs/development/python-modules/playwright/update.sh to update - version = "1.49.1"; + version = "1.50.0"; pyproject = true; - disabled = pythonOlder "3.7"; + disabled = pythonOlder "3.9"; src = fetchFromGitHub { owner = "microsoft"; repo = "playwright-python"; tag = "v${version}"; - hash = "sha256-RwUjFofC/scwVClKncYWp3RbIUeKsWokVjcGibdrrtc="; + hash = "sha256-g32QwEA4Ofzh7gVEsC++uA/XqT1eIrUH+fQi15SRxko="; }; patches = [ @@ -52,13 +52,12 @@ buildPythonPackage rec { git commit -m "workaround setuptools-scm" substituteInPlace pyproject.toml \ - --replace 'requires = ["setuptools==75.5.0", "setuptools-scm==8.1.0", "wheel==0.45.0", "auditwheel==6.1.0"]' \ - 'requires = ["setuptools", "setuptools-scm", "wheel"]' + --replace-fail 'requires = ["setuptools==75.6.0", "setuptools-scm==8.1.0", "wheel==0.45.1", "auditwheel==6.2.0"]' \ + 'requires = ["setuptools", "setuptools-scm", "wheel"]' - # Skip trying to download and extract the driver. + # setup.py downloads and extracts the driver. # This is done manually in postInstall instead. - substituteInPlace setup.py \ - --replace "self._download_and_extract_local_driver(base_wheel_bundles)" "" + rm setup.py # Set the correct driver path with the help of a patch in patches substituteInPlace playwright/_impl/_driver.py \ @@ -101,6 +100,9 @@ buildPythonPackage rec { // lib.optionalAttrs stdenv.hostPlatform.isLinux { inherit (nixosTests) playwright-python; }; + # Package and playwright driver versions are tightly coupled. + # Use the update script to ensure synchronized updates. + skipBulkUpdate = true; updateScript = ./update.sh; }; diff --git a/pkgs/development/python-modules/playwright/driver-location.patch b/pkgs/development/python-modules/playwright/driver-location.patch index 096b9f5ba6e7..66a574e2f9fd 100644 --- a/pkgs/development/python-modules/playwright/driver-location.patch +++ b/pkgs/development/python-modules/playwright/driver-location.patch @@ -18,23 +18,3 @@ index 22b53b8..2d86626 100644 def get_driver_env() -> dict: -diff --git a/setup.py b/setup.py -index f4c93dc..15c2d06 100644 ---- a/setup.py -+++ b/setup.py -@@ -113,7 +113,6 @@ class PlaywrightBDistWheelCommand(BDistWheelCommand): - super().run() - os.makedirs("driver", exist_ok=True) - os.makedirs("playwright/driver", exist_ok=True) -- self._download_and_extract_local_driver() - - wheel = None - if os.getenv("PLAYWRIGHT_TARGET_WHEEL", None): -@@ -139,6 +138,7 @@ class PlaywrightBDistWheelCommand(BDistWheelCommand): - self, - wheel_bundle: Dict[str, str], - ) -> None: -+ return - assert self.dist_dir - base_wheel_location: str = glob.glob(os.path.join(self.dist_dir, "*.whl"))[0] - without_platform = base_wheel_location[:-7] diff --git a/pkgs/development/python-modules/playwright/update.sh b/pkgs/development/python-modules/playwright/update.sh index a8dfacdafac2..db0086b6ed46 100755 --- a/pkgs/development/python-modules/playwright/update.sh +++ b/pkgs/development/python-modules/playwright/update.sh @@ -46,7 +46,7 @@ update_browser() { suffix="mac" fi else - if [ "$name" = "ffmpeg" ]; then + if [ "$name" = "ffmpeg" ] || [ "$name" = "chromium-headless-shell" ]; then suffix="linux" elif [ "$name" = "firefox" ]; then stripRoot="true" @@ -56,12 +56,17 @@ update_browser() { fi fi aarch64_suffix="$suffix-arm64" + if [ "$name" = "chromium-headless-shell" ]; then + buildname="chromium"; + else + buildname="$name" + fi - revision="$(jq -r ".browsers.$name.revision" "$playwright_dir/browsers.json")" + revision="$(jq -r ".browsers[\"$buildname\"].revision" "$playwright_dir/browsers.json")" replace_sha "$playwright_dir/$name.nix" "x86_64-$platform" \ - "$(prefetch_browser "https://playwright.azureedge.net/builds/$name/$revision/$name-$suffix.zip" $stripRoot)" + "$(prefetch_browser "https://playwright.azureedge.net/builds/$buildname/$revision/$name-$suffix.zip" $stripRoot)" replace_sha "$playwright_dir/$name.nix" "aarch64-$platform" \ - "$(prefetch_browser "https://playwright.azureedge.net/builds/$name/$revision/$name-$aarch64_suffix.zip" $stripRoot)" + "$(prefetch_browser "https://playwright.azureedge.net/builds/$buildname/$revision/$name-$aarch64_suffix.zip" $stripRoot)" } curl -fsSl \ @@ -77,12 +82,13 @@ curl -fsSl \ ' > "$playwright_dir/browsers.json" # We currently use Chromium from nixpkgs, so we don't need to download it here -# Likewise, darwin can be ignored here atm as we are using an impure install anyway. +update_browser "chromium-headless-shell" "linux" update_browser "firefox" "linux" update_browser "webkit" "linux" update_browser "ffmpeg" "linux" update_browser "chromium" "darwin" +update_browser "chromium-headless-shell" "darwin" update_browser "firefox" "darwin" update_browser "webkit" "darwin" update_browser "ffmpeg" "darwin" diff --git a/pkgs/development/web/playwright/browsers.json b/pkgs/development/web/playwright/browsers.json index 28c44ae7bfa1..c4d69d02b7e4 100644 --- a/pkgs/development/web/playwright/browsers.json +++ b/pkgs/development/web/playwright/browsers.json @@ -2,27 +2,31 @@ "comment": "This file is kept up to date via update.sh", "browsers": { "chromium": { - "revision": "1140", - "browserVersion": "130.0.6723.31" + "revision": "1155", + "browserVersion": "133.0.6943.16" }, "firefox": { - "revision": "1465", - "browserVersion": "131.0" + "revision": "1471", + "browserVersion": "134.0" }, "webkit": { - "revision": "2083", + "revision": "2123", "revisionOverrides": { + "debian11-x64": "2105", + "debian11-arm64": "2105", "mac10.14": "1446", "mac10.15": "1616", "mac11": "1816", "mac11-arm64": "1816", "mac12": "2009", - "mac12-arm64": "2009" + "mac12-arm64": "2009", + "ubuntu20.04-x64": "2092", + "ubuntu20.04-arm64": "2092" }, - "browserVersion": "18.0" + "browserVersion": "18.2" }, "ffmpeg": { - "revision": "1010", + "revision": "1011", "revisionOverrides": { "mac12": "1010", "mac12-arm64": "1010" diff --git a/pkgs/development/web/playwright/chromium-headless-shell.nix b/pkgs/development/web/playwright/chromium-headless-shell.nix new file mode 100644 index 000000000000..6ed61534688d --- /dev/null +++ b/pkgs/development/web/playwright/chromium-headless-shell.nix @@ -0,0 +1,81 @@ +{ + fetchzip, + revision, + suffix, + system, + throwSystem, + stdenv, + autoPatchelfHook, + patchelfUnstable, + + alsa-lib, + at-spi2-atk, + glib, + libXcomposite, + libXdamage, + libXfixes, + libXrandr, + libgbm, + libgcc, + libxkbcommon, + nspr, + nss, + ... +}: +let + linux = stdenv.mkDerivation { + name = "playwright-chromium-headless-shell"; + src = fetchzip { + url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-headless-shell-${suffix}.zip"; + stripRoot = false; + hash = + { + x86_64-linux = "sha256-UNLSiI9jWLev2YwqiXuoHwJfdB4teNhEfQjQRBEo8uY="; + aarch64-linux = "sha256-aVGLcJHFER09frJdKsGW/pKPl5MXoXef2hy5WTA8rS4="; + } + .${system} or throwSystem; + }; + + nativeBuildInputs = [ + autoPatchelfHook + patchelfUnstable + ]; + + buildInputs = [ + alsa-lib + at-spi2-atk + glib + libXcomposite + libXdamage + libXfixes + libXrandr + libgbm + libgcc.lib + libxkbcommon + nspr + nss + ]; + + buildPhase = '' + cp -R . $out + ''; + }; + + darwin = fetchzip { + url = "https://playwright.azureedge.net/builds/chromium/${revision}/chromium-headless-shell-${suffix}.zip"; + stripRoot = false; + hash = + { + x86_64-darwin = "sha256-c26ubAgM9gQPaYqobQyS3Y7wvMUmmdpDlrYmZJrUgho="; + aarch64-darwin = "sha256-XRFqlhVx+GuDxz/kDP8TtyPQfR0JbFD0qu5OSywGTX8="; + } + .${system} or throwSystem; + }; +in +{ + x86_64-linux = linux; + aarch64-linux = linux; + x86_64-darwin = darwin; + aarch64-darwin = darwin; +} +.${system} or throwSystem diff --git a/pkgs/development/web/playwright/chromium.nix b/pkgs/development/web/playwright/chromium.nix index da0235272cca..2c355272b0fe 100644 --- a/pkgs/development/web/playwright/chromium.nix +++ b/pkgs/development/web/playwright/chromium.nix @@ -34,8 +34,8 @@ let stripRoot = false; hash = { - x86_64-darwin = "sha256-N/uh3Q2ivqeraAqRt80deVz1XEPyLTYI8L3DBfNQGWg="; - aarch64-darwin = "sha256-tR9PwGanPcsDQwi1BijeYJd9LhNIWgEoXs5u3gZpghU="; + x86_64-darwin = "sha256-seMHD+TmxrfgsN6sLN2Bp3WgAooDnlSxGN6CPw1Q790="; + aarch64-darwin = "sha256-SsIRzxTIuf/mwsYvRM2mv8PzWQAAflxOyoK5TuyhMAU="; } .${system} or throwSystem; }; diff --git a/pkgs/development/web/playwright/driver.nix b/pkgs/development/web/playwright/driver.nix index e63f9fcf349b..ab0638768a08 100644 --- a/pkgs/development/web/playwright/driver.nix +++ b/pkgs/development/web/playwright/driver.nix @@ -27,20 +27,20 @@ let } .${system} or throwSystem; - version = "1.48.1"; + version = "1.50.1"; src = fetchFromGitHub { owner = "Microsoft"; repo = "playwright"; rev = "v${version}"; - hash = "sha256-VMp/Tjd5w2v+IHD+CMaR/XdMJHkS/u7wFe0hNxa1TbE="; + hash = "sha256-s4lJRdsA4H+Uf9LjriZ6OimBl5A9Pf4fvhWDw2kOMkg="; }; babel-bundle = buildNpmPackage { pname = "babel-bundle"; inherit version src; sourceRoot = "${src.name}/packages/playwright/bundles/babel"; - npmDepsHash = "sha256-kHuNFgxmyIoxTmvT+cyzDRfKNy18zzeUH3T+gJopWeA="; + npmDepsHash = "sha256-HrDTkP2lHl2XKD8aGpmnf6YtSe/w9UePH5W9QfbaoMg="; dontNpmBuild = true; installPhase = '' cp -r . "$out" @@ -60,7 +60,7 @@ let pname = "utils-bundle"; inherit version src; sourceRoot = "${src.name}/packages/playwright/bundles/utils"; - npmDepsHash = "sha256-d+nE11x/493BexI70mVbnZFLQClU88sscbNwruXjx1M="; + npmDepsHash = "sha256-tyk9bv1ethQSm8PKDpLthwsmqJugLIpsUOf9G8TOKRc="; dontNpmBuild = true; installPhase = '' cp -r . "$out" @@ -70,7 +70,7 @@ let pname = "utils-bundle-core"; inherit version src; sourceRoot = "${src.name}/packages/playwright-core/bundles/utils"; - npmDepsHash = "sha256-aktxEDQKxsDcInyjDKDuIu4zwtrAH0lRda/mP1IayPA="; + npmDepsHash = "sha256-TarWFVp5JFCKZIvBUTohzzsFaLZHV79lN5+G9+rCP8Y="; dontNpmBuild = true; installPhase = '' cp -r . "$out" @@ -92,7 +92,7 @@ let inherit version src; sourceRoot = "${src.name}"; # update.sh depends on sourceRoot presence - npmDepsHash = "sha256-cmUmYuUL7zfB7WEBKft43r69f7vaZDEjku8uwR3RZ1A="; + npmDepsHash = "sha256-RoKw3Ie41/4DsjCeqkMhKFyjDPuvMgxajZYZhRdiTuY="; nativeBuildInputs = [ cacert ]; @@ -163,6 +163,7 @@ let browsers-chromium = browsers { withFirefox = false; withWebkit = false; + withChromiumHeadlessShell = false; }; }; }); @@ -198,6 +199,7 @@ let withFirefox ? true, withWebkit ? true, withFfmpeg ? true, + withChromiumHeadlessShell ? true, fontconfig_file ? makeFontsConf { fontDirectories = [ ]; }, @@ -205,6 +207,7 @@ let let browsers = lib.optionals withChromium [ "chromium" ] + ++ lib.optionals withChromiumHeadlessShell [ "chromium-headless-shell" ] ++ lib.optionals withFirefox [ "firefox" ] ++ lib.optionals withWebkit [ "webkit" ] ++ lib.optionals withFfmpeg [ "ffmpeg" ]; @@ -214,11 +217,12 @@ let map ( name: let - value = playwright-core.passthru.browsersJSON.${name}; + revName = if name == "chromium-headless-shell" then "chromium" else name; + value = playwright-core.passthru.browsersJSON.${revName}; in lib.nameValuePair # TODO check platform for revisionOverrides - "${name}-${value.revision}" + "${lib.replaceStrings [ "-" ] [ "_" ] name}-${value.revision}" ( callPackage (./. + "/${name}.nix") ( { diff --git a/pkgs/development/web/playwright/ffmpeg.nix b/pkgs/development/web/playwright/ffmpeg.nix index 108b19a29214..331541e1e405 100644 --- a/pkgs/development/web/playwright/ffmpeg.nix +++ b/pkgs/development/web/playwright/ffmpeg.nix @@ -10,10 +10,10 @@ fetchzip { stripRoot = false; hash = { - x86_64-linux = "sha256-FEm62UvMv0h6Sav93WmbPLw3CW1L1xg4nD26ca5ol38="; - aarch64-linux = "sha256-jtQ+NS++VHRiKoIV++PIxEnyVnYtVwUyNlSILKSH4A4="; - x86_64-darwin = "sha256-ED6noxSDeEUt2DkIQ4gNe/kL+zHVeb2AD5klBk93F88="; - aarch64-darwin = "sha256-3Adnvb7zvMXKFOhb8uuj5kx0wEIFicmckYx9WLlNNf0="; + x86_64-linux = "sha256-AWTiui+ccKHxsIaQSgc5gWCJT5gYwIWzAEqSuKgVqZU="; + aarch64-linux = "sha256-1mOKO2lcnlwLsC6ob//xKnKrCOp94pw8X14uBxCdj0Q="; + x86_64-darwin = "sha256-zJ8BMzdneV6LlEt4I034l5u86dwW4UmO/UazWikpKV4="; + aarch64-darwin = "sha256-ky10UQj+XPVGpaWAPvKd51C5brml0y9xQ6iKcrxAMRc="; } .${system} or throwSystem; } diff --git a/pkgs/development/web/playwright/firefox.nix b/pkgs/development/web/playwright/firefox.nix index cb23a5a48262..24da9720baa4 100644 --- a/pkgs/development/web/playwright/firefox.nix +++ b/pkgs/development/web/playwright/firefox.nix @@ -17,8 +17,8 @@ let }.zip"; hash = { - x86_64-linux = "sha256-L/CJVtj9bVXKuKSLWw0wAdNICiRTg5ek+fw4togBoSI="; - aarch64-linux = "sha256-DgCuX+6KSnoHNFoFUli6S20GGHOExARasiJY9fy3CCE="; + x86_64-linux = "sha256-53DXgD/OzGo7fEp/DBX1TiBBpFSHwiluqBji6rFKTtE="; + aarch64-linux = "sha256-CBg2PgAXU1ZWUob73riEkQmn/EmIqhvOgBPSAphkAyM="; } .${system} or throwSystem; }; @@ -41,8 +41,8 @@ let stripRoot = false; hash = { - x86_64-darwin = "sha256-HJ0jBmTW/Zz2fkmSo1gEv5P58PGyhXKnJVxJ12Q4IiM="; - aarch64-darwin = "sha256-YnnG8BX06vQlJmzZGaCKq1wKGp3yRaUQ4RF+tEWoK6U="; + x86_64-darwin = "sha256-GbrbNMFv1dT8Duo2otoZvmZk4Sgj81aRNwPAGKkRlnI="; + aarch64-darwin = "sha256-/e51eJTCqr8zEeWWJNS2UgPT9Y+a33Dj619JkCVVeRs="; } .${system} or throwSystem; }; diff --git a/pkgs/development/web/playwright/webkit.nix b/pkgs/development/web/playwright/webkit.nix index 5433a4baf821..dda53162cc59 100644 --- a/pkgs/development/web/playwright/webkit.nix +++ b/pkgs/development/web/playwright/webkit.nix @@ -6,7 +6,9 @@ makeWrapper, autoPatchelfHook, patchelfUnstable, - + fetchpatch, + libjxl, + brotli, at-spi2-atk, cairo, flite, @@ -19,6 +21,7 @@ harfbuzzFull, icu70, lcms, + libavif, libdrm, libepoxy, libevent, @@ -67,6 +70,54 @@ let }; } ); + libavif' = libavif.overrideAttrs ( + finalAttrs: previousAttrs: { + version = "0.9.3"; + src = fetchFromGitHub { + owner = "AOMediaCodec"; + repo = finalAttrs.pname; + rev = "v${finalAttrs.version}"; + hash = "sha256-ME/mkaHhFeHajTbc7zhg9vtf/8XgkgSRu9I/mlQXnds="; + }; + postPatch = ""; + } + ); + + libjxl' = libjxl.overrideAttrs ( + finalAttrs: previousAttrs: { + version = "0.8.2"; + src = fetchFromGitHub { + owner = "libjxl"; + repo = "libjxl"; + rev = "v${finalAttrs.version}"; + hash = "sha256-I3PGgh0XqRkCFz7lUZ3Q4eU0+0GwaQcVb6t4Pru1kKo="; + fetchSubmodules = true; + }; + patches = [ + # Add missing content to fix gcc compilation for RISCV architecture + # https://github.com/libjxl/libjxl/pull/2211 + (fetchpatch { + url = "https://github.com/libjxl/libjxl/commit/22d12d74e7bc56b09cfb1973aa89ec8d714fa3fc.patch"; + hash = "sha256-X4fbYTMS+kHfZRbeGzSdBW5jQKw8UN44FEyFRUtw0qo="; + }) + ]; + postPatch = ""; + postInstall = ""; + + cmakeFlags = + [ + "-DJPEGXL_FORCE_SYSTEM_BROTLI=ON" + "-DJPEGXL_FORCE_SYSTEM_HWY=ON" + "-DJPEGXL_FORCE_SYSTEM_GTEST=ON" + ] + ++ lib.optionals stdenv.hostPlatform.isStatic [ + "-DJPEGXL_STATIC=ON" + ] + ++ lib.optionals stdenv.hostPlatform.isAarch32 [ + "-DJPEGXL_FORCE_NEON=ON" + ]; + } + ); webkit-linux = stdenv.mkDerivation { name = "playwright-webkit"; src = fetchzip { @@ -74,8 +125,8 @@ let stripRoot = false; hash = { - x86_64-linux = "sha256-vz/c2Bzr1NWRZZL5hIRwnor2Wte61gS++8rRfmy9T+0="; - aarch64-linux = "sha256-dS4Hsy/lGZWgznviwkslSk5oBYdUIBxeQPfaEyLNXyc="; + x86_64-linux = "sha256-jw/wQ2Ql7KNpquz5CK+Mo6nPcCbMf8jeSQT64Vt/sLs="; + aarch64-linux = "sha256-vKAvl1kMxTE4CsDryseWF5lxf2iYOYkHHXAdPCnfnHk="; } .${system} or throwSystem; }; @@ -92,6 +143,8 @@ let fontconfig.lib freetype glib + brotli + libjxl' gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-base gst_all_1.gstreamer @@ -99,6 +152,7 @@ let harfbuzzFull icu70 lcms + libavif' libdrm libepoxy libevent @@ -131,9 +185,14 @@ let # remove unused gtk browser rm -rf $out/minibrowser-gtk + # remove bundled libs + rm -rf $out/minibrowser-wpe/sys + # TODO: still fails on ubuntu trying to find libEGL_mesa.so.0 wrapProgram $out/minibrowser-wpe/bin/MiniBrowser \ - --prefix GIO_EXTRA_MODULES ":" "${glib-networking}/lib/gio/modules/" + --prefix GIO_EXTRA_MODULES ":" "${glib-networking}/lib/gio/modules/" \ + --prefix LD_LIBRARY_PATH ":" $out/minibrowser-wpe/lib + ''; }; webkit-darwin = fetchzip { @@ -141,8 +200,8 @@ let stripRoot = false; hash = { - x86_64-darwin = "sha256-lOAHJaDXtt80RhqFNaO1JhaJH5WAu6+rpoR+IsfzGeM="; - aarch64-darwin = "sha256-GrjTnMGTPBdRI3xE5t9HbXLrvgOjCdqbJGElTKhUoA4="; + x86_64-darwin = "sha256-6GpzcA77TthcZEtAC7s3dVpnLk31atw7EPxKUZeC5i4="; + aarch64-darwin = "sha256-lDyeehVveciOsm4JZvz7CPphkl/ryRK1rz7DOcEDzYc="; } .${system} or throwSystem; };