1{ lib
2, stdenv
3, fetchPypi
4, fetchFromGitHub
5, buildPythonPackage
6, geckodriver
7, urllib3
8, xorg
9}:
10
11
12let
13 # Recompiling x_ignore_nofocus.so as the original one dlopen's libX11.so.6 by some
14 # absolute paths. Replaced by relative path so it is found when used in nix.
15 x_ignore_nofocus =
16 fetchFromGitHub {
17 owner = "SeleniumHQ";
18 repo = "selenium";
19 rev = "selenium-3.6.0";
20 sha256 = "13wf4hx4i7nhl4s8xkziwxl0km1j873syrj4amragj6mpip2wn8v";
21 };
22in
23
24buildPythonPackage rec {
25 pname = "selenium";
26 version = "3.141.0";
27
28 src = fetchPypi {
29 inherit pname version;
30 sha256 = "039hf9knvl4s3hp21bzwsp1g5ri9gxsh504dp48lc6nr1av35byy";
31 };
32
33 buildInputs = [xorg.libX11];
34
35 propagatedBuildInputs = [
36 geckodriver urllib3
37 ];
38
39 patchPhase = stdenv.lib.optionalString stdenv.isLinux ''
40 cp "${x_ignore_nofocus}/cpp/linux-specific/"* .
41 substituteInPlace x_ignore_nofocus.c --replace "/usr/lib/libX11.so.6" "${xorg.libX11.out}/lib/libX11.so.6"
42 cc -c -fPIC x_ignore_nofocus.c -o x_ignore_nofocus.o
43 cc -shared \
44 -Wl,${if stdenv.isDarwin then "-install_name" else "-soname"},x_ignore_nofocus.so \
45 -o x_ignore_nofocus.so \
46 x_ignore_nofocus.o
47 cp -v x_ignore_nofocus.so selenium/webdriver/firefox/${if stdenv.is64bit then "amd64" else "x86"}/
48 '';
49
50 meta = with lib; {
51 description = "The selenium package is used to automate web browser interaction from Python";
52 homepage = "http://www.seleniumhq.org";
53 license = licenses.asl20;
54 maintainers = with maintainers; [ jraygauthier ];
55 };
56}