Fix 1.61 build: actually download the patched driver (not vanilla)#3
Merged
Conversation
The published 1.61.0 wheel shipped a VANILLA playwright-core driver: proven by inspecting it (navigator.webdriver=true, Runtime.enable used 10x, no --disable-blink-features in chromiumSwitches, 0 patchright strings, driver version 1.61.1-beta). Patchright's core stealth lives in the DRIVER, so the wheel was detectable (Akamai bot-blocked the ray-ban crawler despite a residential proxy). This corrects the assumption that patchright-python's stealth is 'Python-layer' with a vanilla driver — it is not. Root cause: Playwright-Python 1.61 restructured setup.py — driver_version now reads from a DRIVER_VERSION file, and the bundle is assembled from the vanilla playwright-core npm package via ensure_driver_bundle() (no cdn.playwright.dev url). The existing driver_version/url AST rewrites matched neither and silently no-op'd, so the build fell back to the vanilla driver. - patch_driver_version_file(): pin DRIVER_VERSION to the patched driver version. - patch_ensure_driver_bundle(): rewrite the function to curl our patched driver ZIP from bugbasesecurity/patchright releases (stealth + networkidle baked in). - Workflow: optional patchright_driver_version input; refreshed defaults. The post-build networkidle step (patch_wheels_networkidle.mjs) is now an idempotent safety net — the downloaded driver already carries the exclusion, so it detects it and skips. Verified end-to-end: patcher runs clean on playwright-python v1.61.0; built manylinux wheel bundles the patched driver (39 patchright strings, --disable-blink-features=AutomationControlled in chromiumSwitches, networkidle present); installed wheel -> navigator.webdriver is false on a plain launch()+new_context() with no manual flag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The published
patchright==1.61.0wheel ships a vanilla playwright-core driver — proven by inspecting it:navigator.webdriver === true,Runtime.enableused 10×, no--disable-blink-features=AutomationControlledinchromiumSwitches, 0patchrightstrings, driver version1.61.1-beta-<ts>. Patchright's core stealth lives in the driver, so the wheel is detectable — the ray-ban crawler was Akamai bot-blocked despite a residential proxy.This also corrects the premise in the networkidle tooling docstrings ("patchright-python bundles a vanilla driver, stealth is Python-layer"): it does not — the driver must be the patched one.
Root cause
Playwright-Python 1.61 restructured
setup.py:driver_versionnow reads from aDRIVER_VERSIONfile, and the bundle is assembled from the vanillaplaywright-corenpm package viaensure_driver_bundle()(nocdn.playwright.devurl). The existingdriver_version/urlAST rewrites match neither and silently no-op → the build falls back to vanilla.Fix (+55 lines on current main)
patch_driver_version_file()— pinDRIVER_VERSIONto the patched driver version.patch_ensure_driver_bundle()— rewrite the function tocurlour patched driver ZIP frombugbasesecurity/patchrightreleases (stealth and networkidle already baked in).patchright_driver_versioninput; refreshed defaults.The post-build
patch_wheels_networkidle.mjsstep stays as an idempotent safety net (it detectschallenges.cloudflare.comin the already-patched driver and skips).Verification (end-to-end, local)
microsoft/playwright-python@v1.61.0; writesDRIVER_VERSION=1.61.0; rewritesensure_driver_bundle→bugbasesecurity/patchright.manylinux1_x86_64wheel: driver has 39 patchright strings, the flag inchromiumSwitches, networkidle present.navigator.webdriveris false on a plainlaunch()+new_context(), no manual flag.🤖 Generated with Claude Code