Install and Run Playwright Python API on Termux (Android) using system-installed Chromium — no browser downloads required.
- Termux (Android)
- Python
- Node.js (Will be installed automatically by the wrapper script)
- Chromium installed from Termux’s X11 repo
pkg install x11-repopkg install chromiumgit clone https://github.com/microsoft/playwright-python.git
git checkout 'Release branch you want'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
Now simply do:
pip install . for direct installation
OR
pip wheel . to only build the wheel without install
Full script in main.py.
Env file also available in .env
termux-user-repository/pypi-wheel-builder: https://github.com/termux-user-repository/pypi-wheel-builder