1{ lib 2, stdenv 3, fetchPypi 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.8.1"; 26 27 src = fetchPypi { 28 inherit pname version; 29 sha256 = "1lqm2md84g11g7lqi94xqb5lydm93vgmlznfhf27g6sy9ayjvgcs"; 30 }; 31 32 buildInputs = [xorg.libX11]; 33 34 propagatedBuildInputs = [ 35 geckodriver 36 ]; 37 38 patchPhase = stdenv.lib.optionalString stdenv.isLinux '' 39 cp "${x_ignore_nofocus}/cpp/linux-specific/"* . 40 substituteInPlace x_ignore_nofocus.c --replace "/usr/lib/libX11.so.6" "${xorg.libX11.out}/lib/libX11.so.6" 41 cc -c -fPIC x_ignore_nofocus.c -o x_ignore_nofocus.o 42 cc -shared \ 43 -Wl,${if stdenv.isDarwin then "-install_name" else "-soname"},x_ignore_nofocus.so \ 44 -o x_ignore_nofocus.so \ 45 x_ignore_nofocus.o 46 cp -v x_ignore_nofocus.so selenium/webdriver/firefox/${if stdenv.is64bit then "amd64" else "x86"}/ 47 ''; 48 49 meta = with lib; { 50 description = "The selenium package is used to automate web browser interaction from Python"; 51 homepage = http://www.seleniumhq.org; 52 license = licenses.asl20; 53 maintainers = with maintainers; [ jraygauthier ]; 54 }; 55}