diff --git a/pkgs/development/python-modules/playwright/default.nix b/pkgs/development/python-modules/playwright/default.nix index 50989eddc3e9..7e5f9082a9ed 100644 --- a/pkgs/development/python-modules/playwright/default.nix +++ b/pkgs/development/python-modules/playwright/default.nix @@ -2,33 +2,42 @@ lib, stdenv, buildPythonPackage, - gitMinimal, - greenlet, fetchFromGitHub, - pyee, - python, - pythonOlder, + + # patches + replaceVars, + nodejs, + playwright-driver, + + # build-system setuptools, setuptools-scm, - playwright-driver, + + # nativeBuildInputs + gitMinimal, + writableTmpDirAsHomeHook, + + # dependencies + greenlet, + pyee, + + python, nixosTests, - nodejs, }: let driver = playwright-driver; in -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "playwright"; # run ./pkgs/development/web/playwright/update.sh to update version = "1.58.0"; pyproject = true; - disabled = pythonOlder "3.9"; src = fetchFromGitHub { owner = "microsoft"; repo = "playwright-python"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-gK19pjB8TDy/kK+fb4pjwlGZlUyY26p+CNxunvIMrrY="; }; @@ -38,42 +47,39 @@ buildPythonPackage rec { # - The setup script, which would try to download the driver package from # a CDN and patch wheels so that they include it. We don't want this # we have our own driver build. - ./driver-location.patch + (replaceVars ./driver-location.patch { + driver = "${driver}/cli.js"; + nodejs = lib.getExe nodejs; + }) ]; postPatch = '' - # if setuptools_scm is not listing files via git almost all python files are excluded - export HOME=$(mktemp -d) - git init . - git add -A . - git config --global user.email "nixpkgs" - git config --global user.name "nixpkgs" - git commit -m "workaround setuptools-scm" - - sed -i -e 's/requires = \["setuptools==.*", "setuptools-scm==.*", "wheel==.*", "auditwheel==.*"\]/requires = ["setuptools", "setuptools-scm", "wheel"]/' pyproject.toml + substituteInPlace pyproject.toml \ + --replace-fail ', "auditwheel==6.2.0"' "" \ + --replace-fail "setuptools-scm==8.3.1" "setuptools-scm" \ + --replace-fail "setuptools==80.9.0" "setuptools" \ + --replace-fail "wheel==0.45.1" "wheel" # setup.py downloads and extracts the driver. # This is done manually in postInstall instead. rm setup.py - - # Set the correct driver path with the help of a patch in patches - substituteInPlace playwright/_impl/_driver.py \ - --replace-fail "@node@" "${lib.getExe nodejs}" \ - --replace-fail "@driver@" "${driver}/cli.js" ''; + build-system = [ + setuptools-scm + setuptools + ]; + nativeBuildInputs = [ gitMinimal - setuptools-scm - setuptools + writableTmpDirAsHomeHook ]; pythonRelaxDeps = [ "greenlet" "pyee" ]; - - propagatedBuildInputs = [ + dependencies = [ greenlet pyee ]; @@ -90,7 +96,7 @@ buildPythonPackage rec { passthru = { inherit driver; tests = { - driver = playwright-driver; + inherit driver; browsers = playwright-driver.browsers; } // lib.optionalAttrs stdenv.hostPlatform.isLinux { @@ -111,11 +117,5 @@ buildPythonPackage rec { yrd kalekseev ]; - platforms = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; }; -} +}) diff --git a/pkgs/development/python-modules/playwright/driver-location.patch b/pkgs/development/python-modules/playwright/driver-location.patch index 66a574e2f9fd..f32d16186feb 100644 --- a/pkgs/development/python-modules/playwright/driver-location.patch +++ b/pkgs/development/python-modules/playwright/driver-location.patch @@ -1,5 +1,5 @@ diff --git a/playwright/_impl/_driver.py b/playwright/_impl/_driver.py -index 22b53b8..2d86626 100644 +index 22b53b8..43fdbd5 100644 --- a/playwright/_impl/_driver.py +++ b/playwright/_impl/_driver.py @@ -23,14 +23,7 @@ from playwright._repo_version import version @@ -14,7 +14,7 @@ index 22b53b8..2d86626 100644 - cli_path, - ) - return (os.getenv("PLAYWRIGHT_NODEJS_PATH", str(driver_path / "node")), cli_path) -+ return "@node@", "@driver@" ++ return "@nodejs@", "@driver@" def get_driver_env() -> dict: