2022-10-21 18:38:19 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, git
|
|
|
|
, greenlet
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pyee
|
|
|
|
, python
|
|
|
|
, pythonOlder
|
|
|
|
, setuptools-scm
|
2023-04-29 16:46:19 +00:00
|
|
|
, playwright-driver
|
2022-10-21 18:38:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-04-29 16:46:19 +00:00
|
|
|
driver = playwright-driver;
|
2022-10-21 18:38:19 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "playwright";
|
2023-07-15 17:15:38 +00:00
|
|
|
# run ./pkgs/development/python-modules/playwright/update.sh to update
|
|
|
|
version = "1.34.0";
|
2022-10-21 18:38:19 +00:00
|
|
|
format = "setuptools";
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "microsoft";
|
|
|
|
repo = "playwright-python";
|
|
|
|
rev = "v${version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-GIxMVuSSJsRDsHDOPnJsDsTcghGYtIFpRS5u7HJd+zY=";
|
2022-10-21 18:38:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# This patches two things:
|
|
|
|
# - The driver location, which is now a static package in the Nix store.
|
|
|
|
# - 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
|
|
|
|
];
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
substituteInPlace setup.py \
|
2023-04-29 16:46:19 +00:00
|
|
|
--replace "greenlet==2.0.1" "greenlet>=2.0.1" \
|
2022-10-21 18:38:19 +00:00
|
|
|
--replace "pyee==8.1.0" "pyee>=8.1.0" \
|
|
|
|
--replace "setuptools-scm==7.0.5" "setuptools-scm>=7.0.5" \
|
2023-04-29 16:46:19 +00:00
|
|
|
--replace "wheel==0.38.1" "wheel>=0.37.1"
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
# Skip trying to download and extract the driver.
|
|
|
|
# This is done manually in postInstall instead.
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "self._download_and_extract_local_driver(base_wheel_bundles)" ""
|
|
|
|
|
|
|
|
# Set the correct driver path with the help of a patch in patches
|
|
|
|
substituteInPlace playwright/_impl/_driver.py \
|
|
|
|
--replace "@driver@" "${driver}/bin/playwright"
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
nativeBuildInputs = [ git setuptools-scm ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
greenlet
|
|
|
|
pyee
|
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
ln -s ${driver} $out/${python.sitePackages}/playwright/driver
|
|
|
|
'';
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
SETUPTOOLS_SCM_PRETEND_VERSION = version;
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
# Skip tests because they require network access.
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"playwright"
|
|
|
|
];
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
passthru = {
|
2022-10-21 18:38:19 +00:00
|
|
|
inherit driver;
|
2022-10-30 15:09:59 +00:00
|
|
|
tests = {
|
2023-04-29 16:46:19 +00:00
|
|
|
driver = playwright-driver;
|
|
|
|
browsers = playwright-driver.browsers;
|
2022-10-30 15:09:59 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Python version of the Playwright testing and automation library";
|
|
|
|
homepage = "https://github.com/microsoft/playwright-python";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ techknowlogick yrd SuperSandro2000 ];
|
2023-02-22 10:55:15 +00:00
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2022-10-21 18:38:19 +00:00
|
|
|
};
|
|
|
|
}
|