generated from nix-community/nur-packages-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selenium.nix
137 lines (118 loc) · 3.9 KB
/
selenium.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{ lib
, fetchFromGitHub
, fetchPypi
, fetchurl
, buildPythonPackage
, setuptools
, wheel
, certifi
, geckodriver
, pytestCheckHook
, pythonOlder
, trio
, trio-websocket
, urllib3
, typing-extensions
, pytest-trio
, nixosTests
, stdenv
, python
}:
buildPythonPackage rec {
pname = "selenium";
version = "4.17.0";
pyproject = true;
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "SeleniumHQ";
repo = "selenium";
# check if there is a newer tag with or without -python suffix
rev = "refs/tags/selenium-${version}";
hash = "sha256-3kbg91TMEXY5qVQAM2thT65AZFnsd758rKDXisTk8x8=";
};
# also add selenium.webdriver.common.devtools.* packages
# fix: ModuleNotFoundError: No module named 'selenium.webdriver.common.devtools'
src-pypi = fetchPypi {
inherit pname version;
hash = "sha256-Wdl2tpffN+EddX3x5nmPFGfsGYFFbKf/mphJT1CPbro=";
};
# based on https://github.com/SeleniumHQ/selenium/blob/trunk/common/selenium_manager.bzl
# see also https://github.com/SeleniumHQ/selenium/blob/trunk/scripts/selenium_manager.py
# FIXME build selenium-manager from source
src-selenium-manager-bin = let version = "03637c4"; in fetchurl {
url = "https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/download/selenium-manager-${version}/selenium-manager-linux";
sha256 = "b417e4faad5ab781102f6ba83f0bfc39b60343fbc43455a2732cab82420dcd0e";
};
# relax versions
# fix: typing-extensions~=4.9 not satisfied by version 4.8.0
# https://github.com/SeleniumHQ/selenium/blob/trunk/py/setup.py
# also add selenium.webdriver.common.devtools.* packages
# fix: ModuleNotFoundError: No module named 'selenium.webdriver.common.devtools'
# https://github.com/milahu/nixpkgs/issues/20
postUnpack = ''
cd $sourceRoot/py
echo unpacking selenium/webdriver/common/devtools from ${src-pypi}
tar --strip-components=1 --wildcards -x -f ${src-pypi} 'selenium-*/selenium/webdriver/common/devtools'
cd ../..
'';
postPatch = ''
cd py
# fix typo
sed -i 's/typing_extension~=/typing_extensions~=/' setup.py
sed -i 's/[~>]=.*"/"/' setup.py
substituteInPlace setup.py \
--replace \
" 'packages': [" \
" 'packages': find_namespace_packages(where='.'), '_packages': [" \
--replace \
"from setuptools import setup" \
"from setuptools import setup, find_namespace_packages"
cd ..
'';
preConfigure = ''
cd py
'';
# FIXME _pytest.pathlib.ImportPathMismatchError
doCheck = false;
postInstall = ''
DST_PREFIX=$out/lib/${python.libPrefix}/site-packages/selenium/webdriver/
DST_REMOTE=$DST_PREFIX/remote/
DST_FF=$DST_PREFIX/firefox
cp ../rb/lib/selenium/webdriver/atoms/getAttribute.js $DST_REMOTE
cp ../rb/lib/selenium/webdriver/atoms/isDisplayed.js $DST_REMOTE
cp ../rb/lib/selenium/webdriver/atoms/findElements.js $DST_REMOTE
cp ../javascript/cdp-support/mutation-listener.js $DST_REMOTE
cp ../third_party/js/selenium/webdriver.json $DST_FF/webdriver_prefs.json
'' + lib.optionalString stdenv.isDarwin ''
mkdir -p $DST_PREFIX/common/macos
cp ../common/manager/macos/selenium-manager $DST_PREFIX/common/macos
'' + lib.optionalString stdenv.isLinux ''
mkdir -p $DST_PREFIX/common/linux/
cp -v ${src-selenium-manager-bin} $DST_PREFIX/common/linux/selenium-manager
chmod +x $DST_PREFIX/common/linux/selenium-manager
'';
nativeBuildInputs = [
setuptools
wheel
];
propagatedBuildInputs = [
certifi
trio
trio-websocket
urllib3
typing-extensions
] ++ urllib3.optional-dependencies.socks;
nativeCheckInputs = [
pytestCheckHook
pytest-trio
];
passthru.tests = {
testing-vaultwarden = nixosTests.vaultwarden;
};
meta = with lib; {
description = "Bindings for Selenium WebDriver";
homepage = "https://selenium.dev/";
license = licenses.asl20;
maintainers = with maintainers; [ jraygauthier ];
};
}