-
-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python3Packages.undetected-chromedriver: init at 3.5.5
- Loading branch information
1 parent
5358f7d
commit 6e62dce
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
pkgs/development/python-modules/undetected-chromedriver/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ lib | ||
, buildPythonPackage | ||
, fetchFromGitHub | ||
, pythonOlder | ||
, pythonAtLeast | ||
, selenium | ||
, requests | ||
, websockets | ||
, chromedriver | ||
, python3 | ||
}: | ||
|
||
let | ||
patchPythonPath = ./patchChromedriver.py; | ||
chromedriverPackage = chromedriver; | ||
in | ||
|
||
buildPythonPackage { | ||
pname = "undetected-chromedriver"; | ||
version = "3.5.5"; | ||
format = "setuptools"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "ultrafunkamsterdam"; | ||
repo = "undetected-chromedriver"; | ||
rev = "0aa5fbe252370b4cb2b95526add445392cad27ba"; | ||
hash = "sha256-Qe+GrsUPnhjJMDgjdUCloapjj0ggFlm/Dr42WLcmb1o="; | ||
}; | ||
|
||
disabled = pythonOlder "3.7" || pythonAtLeast "3.12"; | ||
|
||
|
||
buildInputs = [ | ||
chromedriverPackage | ||
]; | ||
|
||
propagatedBuildInputs = [ | ||
selenium | ||
requests | ||
websockets | ||
]; | ||
|
||
# remove items that cause build failures on NixOS, and add the binary driver path so that it | ||
# does not try to download and patch at runtime | ||
postConfigure = '' | ||
substituteInPlace undetected_chromedriver/patcher.py \ | ||
--replace "os.makedirs(self.data_path, exist_ok=True)" "print('test 1')" \ | ||
--replace "os.makedirs(self.zip_path, mode=0o755, exist_ok=True)" "print('test 2')" | ||
substituteInPlace undetected_chromedriver/__init__.py \ | ||
--replace "driver_executable_path=None," "driver_executable_path='$out/bin/chromedriver'," | ||
''; | ||
|
||
# run the patch script now since chromedriver won't be writeable after this | ||
# need to use glob wildcard because chromedriver is packaged with extra | ||
# libraries on darwin platforms that must be copied to $out/bin | ||
postFixup = '' | ||
mkdir mutableChromedriverBin | ||
cp ${chromedriverPackage.out}/bin/* mutableChromedriverBin | ||
chmod +w mutableChromedriverBin/chromedriver | ||
${python3.out}/bin/python3 ${patchPythonPath} mutableChromedriverBin/chromedriver | ||
mkdir $out/bin | ||
cp mutableChromedriverBin/* $out/bin | ||
''; | ||
|
||
pythonImportsCheck = [ | ||
"undetected_chromedriver" | ||
]; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/UltrafunkAmsterdam/undetected-chromedriver"; | ||
changelog = "https://github.com/ultrafunkamsterdam/undetected-chromedriver/blob/master/README.md"; | ||
license = licenses.gpl3Only; | ||
description = '' | ||
Selenium.webdriver.Chrome replacement with compatiblity for Brave, and other Chromium based browsers. | ||
''; | ||
# undetected-chromedriver will attempt to install a compatible chromedriver binary | ||
# when undetected-chromedriver.Chrome is instantiated if one is not found in | ||
# $PATH or passed explicitly as an argument to the constructor | ||
# this will fail on nixos, so we also install and add the patched version of | ||
# chromedriver to path with this library | ||
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; | ||
maintainers = with maintainers; [ liammurphy14 toasteruwu ]; | ||
}; | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
pkgs/development/python-modules/undetected-chromedriver/patchChromedriver.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import undetected_chromedriver as uc | ||
|
||
if __name__ == "__main__": | ||
uc.Patcher(executable_path=sys.argv[1]).auto(executable_path=sys.argv[1]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters