Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, buildPythonPackage 3, git 4, greenlet 5, fetchFromGitHub 6, pyee 7, python 8, pythonOlder 9, setuptools-scm 10, playwright-driver 11}: 12 13let 14 driver = playwright-driver; 15in 16buildPythonPackage rec { 17 pname = "playwright"; 18 version = "1.32.1"; 19 format = "setuptools"; 20 disabled = pythonOlder "3.7"; 21 22 src = fetchFromGitHub { 23 owner = "microsoft"; 24 repo = "playwright-python"; 25 rev = "v${version}"; 26 hash = "sha256-rguobFaepTOL2duHRdFV5o2JSsBlYiA7rY3/RyHvoMc="; 27 }; 28 29 patches = [ 30 # This patches two things: 31 # - The driver location, which is now a static package in the Nix store. 32 # - The setup script, which would try to download the driver package from 33 # a CDN and patch wheels so that they include it. We don't want this 34 # we have our own driver build. 35 ./driver-location.patch 36 ]; 37 38 postPatch = '' 39 # if setuptools_scm is not listing files via git almost all python files are excluded 40 export HOME=$(mktemp -d) 41 git init . 42 git add -A . 43 git config --global user.email "nixpkgs" 44 git config --global user.name "nixpkgs" 45 git commit -m "workaround setuptools-scm" 46 47 substituteInPlace setup.py \ 48 --replace "greenlet==2.0.1" "greenlet>=2.0.1" \ 49 --replace "pyee==8.1.0" "pyee>=8.1.0" \ 50 --replace "setuptools-scm==7.0.5" "setuptools-scm>=7.0.5" \ 51 --replace "wheel==0.38.1" "wheel>=0.37.1" 52 53 # Skip trying to download and extract the driver. 54 # This is done manually in postInstall instead. 55 substituteInPlace setup.py \ 56 --replace "self._download_and_extract_local_driver(base_wheel_bundles)" "" 57 58 # Set the correct driver path with the help of a patch in patches 59 substituteInPlace playwright/_impl/_driver.py \ 60 --replace "@driver@" "${driver}/bin/playwright" 61 ''; 62 63 64 nativeBuildInputs = [ git setuptools-scm ]; 65 66 propagatedBuildInputs = [ 67 greenlet 68 pyee 69 ]; 70 71 postInstall = '' 72 ln -s ${driver} $out/${python.sitePackages}/playwright/driver 73 ''; 74 75 SETUPTOOLS_SCM_PRETEND_VERSION = version; 76 77 # Skip tests because they require network access. 78 doCheck = false; 79 80 pythonImportsCheck = [ 81 "playwright" 82 ]; 83 84 passthru = { 85 inherit driver; 86 tests = { 87 driver = playwright-driver; 88 browsers = playwright-driver.browsers; 89 }; 90 }; 91 92 meta = with lib; { 93 description = "Python version of the Playwright testing and automation library"; 94 homepage = "https://github.com/microsoft/playwright-python"; 95 license = licenses.asl20; 96 maintainers = with maintainers; [ techknowlogick yrd SuperSandro2000 ]; 97 platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 98 }; 99}