Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / python-modules / selenium / default.nix
blob664f84933ed79adcf2c16cda32a5445c1e09433b
1 { lib
2 , stdenv
3 , fetchPypi
4 , fetchFromGitHub
5 , buildPythonPackage
6 , geckodriver
7 , urllib3
8 , xorg
9 }:
12 let
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     };
24 buildPythonPackage rec {
25   pname = "selenium";
26   version = "3.141.0";
28   src = fetchPypi {
29     inherit pname version;
30     sha256 = "039hf9knvl4s3hp21bzwsp1g5ri9gxsh504dp48lc6nr1av35byy";
31   };
33   buildInputs = [xorg.libX11];
35   propagatedBuildInputs = [
36     geckodriver urllib3
37   ];
39   patchPhase = 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   '';
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   };