-
-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add python undetected chromedriver #316536
Add python undetected chromedriver #316536
Conversation
Result of 2 packages failed to build:
2 packages built:
|
The Error i get when trying to build this:
Seems like distutils is missing and therefor this cant function. This is is because Python 3.12 has removed it, after it was deprecated in 3.10
I dont know what exactly requires this, the check or the module or the nix derivation, and i dont really have time rn to get into it. But i can definitely say this doesnt work rn, and distutils missing is the cause |
Ok, i checked. Its an issue with undetected_chromedriver itself. Issues: ultrafunkamsterdam/undetected-chromedriver#1674 and ultrafunkamsterdam/undetected-chromedriver#1469 |
@liam-murphy14 I think for now, the only solution is to not provide this package for Python 3.12, at least until this is fixed upstream. So 3.11 only, or maybe some older versions as well. |
Hey @ToasterUwU, thanks for checking this out - I run 3.11 so didn't even notice the issue. For now going to see if adding As for long term fix, this PR against upstream seems to follow the PEP guidance, so hopefully it gets merged soon. Thanks again ! Either way will update this PR with a fix in the next hour or so. |
a640dbf
to
1a2037c
Compare
Update: the Thanks again to @ToasterUwU for finding the issue ! |
Result of 2 packages built:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, i tested this properly now, and i have to take the approval back.
Everytime i try to use this, i get an error. As soon as the line comes up where i create a Chrome() instance, it fails with some error code. Details in a second. Specifically it fails at the part where undetected-chromedriver executes the init method of the selenium Chrome class itself via super()
The error code i get every single time, even when using undetected chromedriver correctly with freeze_support() and everything: undetected_chromedriver unexpectedly exited. Status code was: 127
This seems to be a error coming from the chromedriver itself.
Hey @ToasterUwU, hmmm that is odd, when I tested this before submitting PR all was working fine. I have seen that 127 error before when the chromedriver and chrome/chromium instance have a version mismatch, so possibly related to that ?? I will do some testing and see if I can fix it. Thanks for all the very in depth reviews, appreciate your time and effort !! |
@liam-murphy14 I just double checked. I suspected the same at first, but now i made sure. |
Hey @ToasterUwU, I just checked on my x86-64 darwin machine, and everything appears to be in working order. I made a Github gist of the steps i took to test it, check it out and let me know if you are still running into issues. In a little while I'll dig out my old x86-64 linux machine and make sure it works on that as well, updating the gist if necessary. Thanks for the help on testing and bug fixing !!! Also note: I am force pushing to this branch to rebase on nixpkgs/master, just to make sure I am using the latest chromium/chromedriver pair EDIT: I just thought of this but I think I know why you might be having issues. If you don't pass in the chromedriver executable path, it will try to download and patch a new one, which will give you issues on NixOS. The other thing is it will try to patch in place the chromedriver path that you pass it if it has not already been patched. This will also cause an issue on NixOS since packages are read-only after build time, unless you use the chromedriver executable that this |
1a2037c
to
622901b
Compare
@liam-murphy14 Well that explains it, i dont specify the path of the chromedriver, i just do "uc.Chrome()" and it fails. And honestly, i dont think forcing everyone using this to hardcode a path in one way or another is a solution. I dont really know what the best solution for this is, but one that i can think of is patching the package to use the included chromedriver if nothing is specified by the user instead. Extend the automatic search so to say. |
@ToasterUwU Yea I agree, I definitely don't love the hardcoded path either..... I was trying to figure out a way to make the package work without patching the Python code in the package itself, since that adds some maintenance to keep it "in-sync" with the upstream. However, I think you're right in that patching the Python package would be better than forcing a certain way of using it. Let me work on it over the next couple days and see if I can edit the way it searches for the package, I know it already does something along the lines of searching in Thanks for the feedback, will work on that and hopefully have a better version of this package out in some time ! |
@liam-murphy14 Btw, if you feel like being the only maintainer of this when its done is a but much for you, and you want there to be a backup person that takes care of it in case you are very busy, feel free to add me to the maintainer list of the package. Im already in maintainers/maintainer-list.nix |
622901b
to
4481987
Compare
Hey @ToasterUwU, I just pushed an update that should fix the path issue, now Hopefully the package is working now ! I tested again on my darwin machine with and without passing the path, and looks to be working well. Will test it out on my linux machine today as well. Thanks again for the feedback and help on making this package better ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this so quickly!
Glad it works on Darwin already, but sadly it doesnt seem to work on Linux yet.
It knows which chromedriver to use, so that part works, but there is a permission problem. If i run python3 without sudo i get a permission issue, if i run it with sudo, the package seems inaccessible, python cant find it.
The second part might be a quirk of the nixpkgs-review shell, but the first part i dont think.
Here the error message for some context:
❯ python3
Python 3.11.9 (main, Apr 2 2024, 08:25:04) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import undetected_chromedriver as uc
>>> uc.Chrome()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/2fqpwa5cnyqxcj4znhc14g1nhi0z3bjk-python3.11-undetected-chromedriver-3.5.5/lib/python3.11/site-packages/undetected_chromedriver/__init__.py", line 258, in __init__
self.patcher.auto()
File "/nix/store/2fqpwa5cnyqxcj4znhc14g1nhi0z3bjk-python3.11-undetected-chromedriver-3.5.5/lib/python3.11/site-packages/undetected_chromedriver/patcher.py", line 150, in auto
return self.patch_exe()
^^^^^^^^^^^^^^^^
File "/nix/store/2fqpwa5cnyqxcj4znhc14g1nhi0z3bjk-python3.11-undetected-chromedriver-3.5.5/lib/python3.11/site-packages/undetected_chromedriver/patcher.py", line 347, in patch_exe
with io.open(self.executable_path, "r+b") as fh:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/nix/store/2fqpwa5cnyqxcj4znhc14g1nhi0z3bjk-python3.11-undetected-chromedriver-3.5.5/bin/chromedriver'
Hey @ToasterUwU, I just tried it on my Linux laptop and getting the same error :( I will take a look either later today or tomorrow and try to fix it. It appears that on Linux, uc is not recognizing the pre patched binary as patched, and is trying to patch it again. That is why we are seeing the permissions issue, since it's read only after build time. I will do some debugging and see if the patch call during build time is failing or something like that. Thanks for taking a look ! |
@liam-murphy14 Maybe it patches the binary differently on Linux compared to Darwin? And because of that it looks for the Linux patches and cant find them, so it assumes its unpatched? Just spitballing here, but at least in theory this might be an explanation. If that was the case, the only solution i can think of is to prepatch two binaries and hand out the correct one for the system in question. I cant test it sadly, since im not an Apple User at all, only thing i have from them is some ancient earpods in a drawer somewhere. |
@Titaniumtown You seem interested in this as well, dont know how actively you are following this issue, but maybe you wanna throw your hat in the ring? Cant hurt to have more brains and eyes on this. |
Unfortunately I do not have the time right now to test, if/when I get to it, I'll post my results here. |
Hey @ToasterUwU, yea honestly not sure. Have been doing a bit of testing today, I have confirmed that the A sidebar: what is the easiest way to debug something like this ?? So far I have just been using Thanks for your help ! |
@liam-murphy14 I always use nixpkgs-review.
That way is the easiest I can think of |
Hey @ToasterUwU, I am beginning to think that maybe there is an issue with the undetected-chromedriver library. I have updated this gist with more testing details, but will summarize here. Basically, the library searches for a specific point in the Testing evidence from gist: update: trying to debug the build failures on linux, it appears to be an actual issue with the library itself. In order to test this, first run
This test is what the If this is the case, I am not sure what else to do, unfortunately. I will update my nixpkgs to latest on Linux and Darwin, and check again, but if this check is failing on linux nixpkgs chromedriver, then I don't think there is anything we can do. |
@liam-murphy14 inreresting and also weird. Have you checked if there is an issue on the upstream repo? When I get the chance I will spin up a Ubuntu vm and try the library there. |
Still failing after updating nixpkgs on Nixos linux. I haven't checked upstream, will check that plus the Darwin thing later today. Thanks ! |
Hey @ToasterUwU, some more results: on darwin the nixpkgs version works fine still, and I checked, it is that line causing the issue, the check is passing on darwin but failing on linux. More curious tho: when I downloaded the linux64 binary from https://googlechromelabs.github.io/chrome-for-testing/#stable, the check passed !! So i think something from the nix derivation of chromedriver for nixpkgs is causing the issue. I suspect that it's the highlighted lines here: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/tools/selenium/chromedriver/default.nix#L55-L56, my guess is that patching the libraries is shifting some bits around, and undetected-chromedriver is not able to find the right place to inject its code. So it isn't an upstream problem. I could maybe try to rewrite this so that it downloads the binary directly, patches it with UC, then wraps it in the libraries ??? That seems kinds of hackish but not sure what else to do. Let me know if you have any other ideas. Thank you ! |
@liam-murphy14 yeah it seems very likely that this is the cause of the problem, if the bytes aren't in the "correct" location it probably doesn't wanna touch it. And I don't really see any alternative in that case sadly. Have to work around the nixpkgs chromedriver somehow. |
4481987
to
6e62dce
Compare
Result of 2 packages failed to build:
|
Seems that its distutils again.. somehow..
|
Hey @ToasterUwU, thanks for checking on that, yea I noticed it too after I On another note, there is a new library by the creator of undetected-chromedriver, called nodriver which is a UC alternative that does not rely on chromedriver binary. I will take a look this weekend, if no nix derivation already exists, I will write a quick one to support that library. That way there is at least some alternative that works. I think the library pretty fresh tho, so not sure how fully featured it will be. Thanks for your patience with the long process of getting this library into nixpkgs. Appreciate your help !! |
"nodriver is the official successor" Well that is good to know. I will also take a look today |
Ok, i just tested nodriver and.. OMG This thing flies away with how fast it can go. UC is a joke compared to this performance-wise. And it also seems to work very well. I tested it in an FHS through vscode-fhs and without FHS by just using Konsole, both worked flawlessly. How are doing for freetime that you want to spend on nodriver? If you are low on time, im happy to start and add you as maintainer alongside me. I have never made a nix package before, but nodriver seems like any other python package from how it works and what it needs, so i think this shouldnt be too hard. |
Hey @ToasterUwU, thanks for checking it out !! I actually have some free time for To answer your question, yea I think it's definitely not in scope for the python library. Just as |
Just opened a PR for nodriver: #326242. Added @ToasterUwU as a maintainer as well, let me know if you want me to take you off the maintainer list. Was able to test on darwin and everything looking great. Will test on Linux tomorrow. Let me know if you have any feedback on it !! Thank you ! |
@liam-murphy14 Thanks, im happy to be a maintainer, after all i will be using that package a lot. Since the successor of this package is in the works as a nix package, does it make sense to close this PR now? Or do you still want to add it whenever the distutils issue is fixed? |
@ToasterUwU awesome, happy to hear that ! Also I think I will leave this open and still add it whenever distutils is fixed. Currently |
Hey @ToasterUwU, @Titaniumtown, I am closing this PR. It looks like somebody recently merged a PR for undetected-chromedriver, see this derivation, and the corresponding nix python module. Thanks for the support on this. I have not gotten a chance to test the derivation, but I am hopeful that it will work ! I will keep my PR for nodriver open as well, so hopefully that will get merged. Thanks again ! |
Description of changes
Add undetected-chromedriver to python3Packages. Homepage: https://github.com/UltrafunkAmsterdam/undetected-chromedriver
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.