Skip to content

Darklaser38/Playwright-Python-Android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

playwright-python-termux

Install and Run Playwright Python API on Termux (Android) using system-installed Chromium — no browser downloads required.


📦 Requirements

  • Termux (Android)
  • Python
  • Node.js (Will be installed automatically by the wrapper script)
  • Chromium installed from Termux’s X11 repo

⚙️ Setup

1. Enable X11 repo

pkg install x11-repo

2. Install Chromium

pkg install chromium

3. Clone playwright repo

git clone https://github.com/microsoft/playwright-python.git
git checkout 'Release branch you want'

4. Patch the code

replace base_wheel_bundles by this one:

base_wheel_bundles = [
    {
        "wheel": "macosx_10_13_x86_64.whl",
        "machine": "x86_64",
        "platform": "darwin",
        "zip_name": "mac",
    },
    {
        "wheel": "macosx_11_0_universal2.whl",
        "machine": "x86_64",
        "platform": "darwin",
        "zip_name": "mac",
    },
    {
        "wheel": "macosx_11_0_arm64.whl",
        "machine": "arm64",
        "platform": "darwin",
        "zip_name": "mac-arm64",
    },
    {
        "wheel": "manylinux1_x86_64.whl",
        "machine": "x86_64",
        "platform": "linux",
        "zip_name": "linux",
    },
    {
        "wheel": "manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
        "machine": "aarch64",
        "platform": "linux",
        "zip_name": "linux-arm64",
    },
    {
        "wheel": "android_24_x86_64.whl",
        "machine": "x86_64",
        "platform": "android",
        "zip_name": "linux",  # reuse linux driver
    },
    {
        "wheel": "android_24_arm64_v8a.whl",
        "machine": "aarch64",
        "platform": "android",
        "zip_name": "linux-arm64",  # reuse linux-arm64 driver
    },
    {
        "wheel": "win32.whl",
        "machine": "i386",
        "platform": "win32",
        "zip_name": "win32_x64",
    },
    {
        "wheel": "win_amd64.whl",
        "machine": "amd64",
        "platform": "win32",
        "zip_name": "win32_x64",
    },
    {
        "wheel": "win_arm64.whl",
        "machine": "arm64",
        "platform": "win32",
        "zip_name": "win32_arm64",
    },
]

in _build_wheel above wheel_location = without_platform + wheel_bundle["wheel"] place:

os.remove(f"driver/{wheel_bundle['zip_name']}/node")
shutil.copy('node-wrapper.sh', f"driver/{wheel_bundle['zip_name']}/node")
subprocess.check_call(["bash", "-c", "find ./ -name '*.js' -type f -exec sed -i \"s@process.platform === 'linux'@(process.platform === 'linux' || process.platform === 'android')@g\" {} \;"])

Place the node-wrapper.sh script next to the setup.py

5. Build

Now simply do:

pip install . for direct installation

OR

pip wheel . to only build the wheel without install

📁 Example code

Full script in main.py.

Env file also available in .env


Source

termux-user-repository/pypi-wheel-builder: https://github.com/termux-user-repository/pypi-wheel-builder

About

Patches to run playwright python on android (termux)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors