1{ lib
2, stdenv
3, fetchurl
4, fetchFromGitHub
5, buildPythonPackage
6, geckodriver
7, xorg
8}:
9
10
11let
12 # Recompiling x_ignore_nofocus.so as the original one dlopen's libX11.so.6 by some
13 # absolute paths. Replaced by relative path so it is found when used in nix.
14 x_ignore_nofocus =
15 fetchFromGitHub {
16 owner = "SeleniumHQ";
17 repo = "selenium";
18 rev = "selenium-3.6.0";
19 sha256 = "13wf4hx4i7nhl4s8xkziwxl0km1j873syrj4amragj6mpip2wn8v";
20 };
21in
22
23buildPythonPackage rec {
24 pname = "selenium";
25 version = "3.6.0";
26 name = pname + "-" + version;
27
28 src = fetchurl {
29 url = "mirror://pypi/s/selenium/${name}.tar.gz";
30 sha256 = "15qpvz0bdwjvpcj11fm0rw6r5inr66sqw89ww50l025sbhf04qwm";
31 };
32
33 buildInputs = [xorg.libX11];
34
35 propagatedBuildInputs = [
36 geckodriver
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}