nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 119 lines 3.0 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 gitMinimal, 6 greenlet, 7 fetchFromGitHub, 8 pyee, 9 python, 10 setuptools, 11 setuptools-scm, 12 playwright-driver, 13 nixosTests, 14 nodejs, 15}: 16 17let 18 driver = playwright-driver; 19in 20buildPythonPackage rec { 21 pname = "playwright"; 22 # run ./pkgs/development/python-modules/playwright/update.sh to update 23 version = "1.57.0"; 24 pyproject = true; 25 26 src = fetchFromGitHub { 27 owner = "microsoft"; 28 repo = "playwright-python"; 29 tag = "v${version}"; 30 hash = "sha256-LXTMVC6ytjo7l0QDkNPxtoMTYjmYMjCVqHz61BgAn6A="; 31 }; 32 33 patches = [ 34 # This patches two things: 35 # - The driver location, which is now a static package in the Nix store. 36 # - The setup script, which would try to download the driver package from 37 # a CDN and patch wheels so that they include it. We don't want this 38 # we have our own driver build. 39 ./driver-location.patch 40 ]; 41 42 postPatch = '' 43 # if setuptools_scm is not listing files via git almost all python files are excluded 44 export HOME=$(mktemp -d) 45 git init . 46 git add -A . 47 git config --global user.email "nixpkgs" 48 git config --global user.name "nixpkgs" 49 git commit -m "workaround setuptools-scm" 50 51 sed -i -e 's/requires = \["setuptools==.*", "setuptools-scm==.*", "wheel==.*", "auditwheel==.*"\]/requires = ["setuptools", "setuptools-scm", "wheel"]/' pyproject.toml 52 53 # setup.py downloads and extracts the driver. 54 # This is done manually in postInstall instead. 55 rm setup.py 56 57 # Set the correct driver path with the help of a patch in patches 58 substituteInPlace playwright/_impl/_driver.py \ 59 --replace-fail "@node@" "${lib.getExe nodejs}" \ 60 --replace-fail "@driver@" "${driver}/cli.js" 61 ''; 62 63 nativeBuildInputs = [ 64 gitMinimal 65 setuptools-scm 66 setuptools 67 ]; 68 69 pythonRelaxDeps = [ 70 "greenlet" 71 "pyee" 72 ]; 73 74 propagatedBuildInputs = [ 75 greenlet 76 pyee 77 ]; 78 79 postInstall = '' 80 ln -s ${driver} $out/${python.sitePackages}/playwright/driver 81 ''; 82 83 # Skip tests because they require network access. 84 doCheck = false; 85 86 pythonImportsCheck = [ "playwright" ]; 87 88 passthru = { 89 inherit driver; 90 tests = { 91 driver = playwright-driver; 92 browsers = playwright-driver.browsers; 93 } 94 // lib.optionalAttrs stdenv.hostPlatform.isLinux { 95 inherit (nixosTests) playwright-python; 96 }; 97 # Package and playwright driver versions are tightly coupled. 98 # Use the update script to ensure synchronized updates. 99 skipBulkUpdate = true; 100 updateScript = ./update.sh; 101 }; 102 103 meta = { 104 description = "Python version of the Playwright testing and automation library"; 105 mainProgram = "playwright"; 106 homepage = "https://github.com/microsoft/playwright-python"; 107 license = lib.licenses.asl20; 108 maintainers = with lib.maintainers; [ 109 techknowlogick 110 yrd 111 ]; 112 platforms = [ 113 "x86_64-linux" 114 "aarch64-linux" 115 "x86_64-darwin" 116 "aarch64-darwin" 117 ]; 118 }; 119}