fix: Python 3.12+ compatibility (distutils removed)#26
Conversation
|
@Mounstroya please update the |
- Split merged `ruff>=0.2.0setuptools` onto separate lines so pip can actually parse the file. - Pin `setuptools<70` — setuptools 70+ dropped the vendored distutils shim, so the Py 3.12+ fix only holds below 70. - Pin `undetected-chromedriver>=3.5.5` for reproducible installs. - Use `uc.ChromeOptions()` instead of `webdriver.ChromeOptions()` — the undetected-chromedriver docs require its own options subclass so uc's internal patching is applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Hi @Mounstroya, thanks for the PR! I pushed a small follow-up commit (9d3eb37) to address a few issues — feel free to revert if you disagree:
Let me know if anything looks off. |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Hi @Mounstroya, thanks again for the PR. I tested the branch locally (macOS, Python 3.13, Chrome 147.0.7727.56) and hit a blocker: uc spawns Chrome, but the initial window closes before Root cause: Your diagnosis (distutils removal + Google's Selenium block) was correct — uc just isn't a viable dependency anymore. I'll explore a different path (likely reusing the user's real Chrome profile via |
# Conflicts: # requirements.txt
Replaces the undetected-chromedriver approach. uc 3.5.5 (last release 2024-02-17) is unmaintained and breaks on Chrome 147+ with NoSuchWindowException. SeleniumBase's UC mode is actively maintained, auto-downloads the correct chromedriver for the installed Chrome, and uses `uc_open_with_reconnect` to clear anti-bot checks on the login page. - Drop `undetected-chromedriver` + `setuptools<70` from deps; replace `selenium` with `seleniumbase` in pyproject.toml. - Rewrite `APIKeyLeakageScanner.login_to_github` to construct `Driver(uc=True)` and open the login page via `uc_open_with_reconnect(url, reconnect_time=3)`. - All other `self.driver.*` call sites (find_elements, page_source, refresh, quit, implicitly_wait, get) are unchanged — SB's Driver is selenium-compatible. Verified: SB downloads chromedriver 147.0.7727.57, launches cleanly, navigates to a real page. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Update: I pushed two commits to this branch (8b2cae1 + merge of main) pivoting to SeleniumBase UC mode instead of raw undetected-chromedriver. Why this instead of What changed
Verified
Still needs a real interactive login test to confirm the Google block is cleared — happy to let you try that end on your side if you want. Otherwise I'll merge and close out. |
|
Tested on Linux, Python 3.14, Chrome 147. uv sync was clean, uv run main.py --help works, and the interactive login launched Chrome via SeleniumBase UC mode without issues — GitHub login page loaded correctly with no bot check triggered. LGTM, feel free to merge |
Problem
Two issues when running on Python 3.12+:
Google blocks Selenium's default Chrome driver showing:
"This browser or app may not be secure"
This prevents users from logging into GitHub.
Switching to
undetected-chromedriver(which fixes the detection)causes a secondary error:
ModuleNotFoundError: No module named 'distutils'
because
distutilswas removed in Python 3.12+.Solution
webdriver.Chrometouc.Chrome(undetected-chromedriver)to bypass Google's bot detection
setuptoolstorequirements.txtto restoredistutilsfor Python 3.12+ compatibility
Tested on