Cross-platform PWA launcher using Chromium
Project description
py-pwa-launcher
Launch Progressive Web Apps from Python
A Python library for launching Progressive Web Apps (PWAs) using Chromium-based browsers. Automatically finds or downloads a Chromium browser and launches PWAs in app mode with all necessary flags.
Features
- 🚀 Launch PWAs with a single function call
- 🔍 Auto-detect system Chrome/Edge browsers
- 📥 Auto-download portable Chromium if needed
- ⚙️ PWA-optimized flags for installation and features
- 🔒 Custom profiles for isolated PWA data
- ✅ Check PWA support before launching
- 🧪 Fully tested with comprehensive test suite
Installation
pip install py-pwa-launcher
Quick Start
Launch a PWA
from pwa_launcher import open_pwa
# Launch a PWA - that's it!
open_pwa("https://weatherlite.app")
Check PWA Support
from pwa_launcher import check_pwa_support
# Check if a URL supports PWA
result = check_pwa_support("https://weatherlite.app")
if result.is_pwa_supported:
print(f"✓ {result.url} is PWA-ready!")
print(f" Manifest: {result.manifest_url}")
print(f" Service Worker: {result.service_worker_url}")
else:
print(f"✗ Not a PWA")
for error in result.errors:
print(f" - {error}")
Launch with Custom Options
from pwa_launcher import open_pwa
from pathlib import Path
# Launch with custom profile and flags
process = open_pwa(
"https://excalidraw.com",
user_data_dir=Path("./my_pwa_profile"),
additional_flags=["--start-maximized"]
)
print(f"Launched PWA (PID: {process.pid})")
Keep Process Alive
By default, each PWA runs in an isolated profile to keep the process alive:
from pwa_launcher import open_pwa
# Auto-generates isolated profile - process stays alive!
process = open_pwa("https://example.com")
print(f"PID: {process.pid}") # Process won't exit immediately
# To disable auto-profile (may cause process to exit if Chrome is already running):
process = open_pwa("https://example.com", auto_profile=False)
Why this matters: When Chrome reuses an existing profile, it hands off to an already-running Chrome instance and the new process exits immediately. With auto_profile=True (default), each PWA gets its own isolated profile, keeping the process running.
API Reference
open_pwa(url, **kwargs)
Launch a PWA using Chromium browser.
Parameters:
url(str): URL to open as PWA (required)chromium_path(Path, optional): Path to Chromium executableallow_system(bool, default=True): Allow using system Chrome/Edgeallow_download(bool, default=True): Allow downloading portable Chromiuminstall_dir(Path, optional): Directory for portable Chromiumuser_data_dir(Path, optional): Custom browser profile directoryadditional_flags(List[str], optional): Extra Chromium flagswait(bool, default=False): Wait for browser to exitauto_profile(bool, default=True): Auto-generate isolated profile (keeps process alive)
Returns: subprocess.Popen - Browser process
Raises:
ChromiumNotFoundError: No browser foundValueError: Invalid URL
Note: When auto_profile=True, each PWA gets its own isolated profile based on the URL hostname. This prevents Chrome from handing off to an existing instance and keeps your process alive.
check_pwa_support(url, timeout=10)
Check if a URL supports PWA features.
Parameters:
url(str): URL to checktimeout(int): Request timeout in seconds
Returns: PWACheckResult with:
is_pwa_supported(bool): Whether PWA is supportedhas_manifest(bool): Has web manifestmanifest_url(str): URL of manifest filemanifest_data(dict): Parsed manifest datahas_service_worker(bool): Has service workerservice_worker_url(str): URL of service workerhas_https(bool): Uses HTTPSerrors(list): List of error messageswarnings(list): List of warnings
get_chromium_install(**options)
Get a single Chromium browser executable path (tries system → portable → download).
Parameters:
allow_system(bool, default=True): Search for system Chrome/Edgeallow_download(bool, default=True): Allow downloading portable Chromeinstall_dir(Path, optional): Directory for portable Chromeforce_reinstall(bool, default=False): Force download even if exists
Returns: Path - Path to Chromium executable
Raises: ChromiumNotFoundError - No browser found
get_chromium_installs(**options)
Get all available Chromium browser executable paths.
Parameters:
allow_system(bool, default=True): Search for system Chrome/Edgeallow_download(bool, default=True): Allow downloading portable Chromeinstall_dir(Path, optional): Directory for portable Chrome
Returns: List[Path] - List of paths to Chromium executables
Examples
See the examples/ directory for more examples:
examples/check_pwa.py- Check PWA support
Command Line Usage
Launch a PWA
python -m pwa_launcher.open_pwa https://weatherlite.app
Check PWA Support
python -m pwa_launcher.pwa_support https://weatherlite.app
How It Works
- Get Chromium: Finds system Chrome/Edge or downloads portable Chromium
- Build Command: Creates command with
--app={url}and PWA flags - Launch: Starts browser in app mode with PWA features enabled
PWA Flags Included
--app={url}: Launch in app mode (no browser UI)--enable-features=WebAppInstallation: Enable PWA installation--enable-features=DesktopPWAsTabStrip: Enable tab strip in PWAs--enable-features=FileSystemAccessAPI: Enable file system access--enable-features=NotificationTriggers: Enable notifications--no-default-browser-check: Skip default browser check--no-first-run: Skip first run experience
Development
Setup
# Clone the repository
git clone https://github.com/yourusername/py-pwa-launcher.git
cd py-pwa-launcher
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements-dev.txt
Run Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=pwa_launcher
# Run specific test file
pytest tests/test_open_pwa.py -v
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pwa_launcher-0.2.0.tar.gz.
File metadata
- Download URL: pwa_launcher-0.2.0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0affe6d2c2457dd6fa8030571bfa41de184822a998f0a48108036bee5ce46f5f
|
|
| MD5 |
6781e9c3bee5cea9a9be12cbbcca9ff3
|
|
| BLAKE2b-256 |
08f62022992b24f91a865bd4b45dab6c4c7cafc3473d66bf2f1193bb1e7bce25
|
File details
Details for the file pwa_launcher-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pwa_launcher-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1474175ac101a8638c5b4e77140ec1fc30219da6eb9b1a88cfb0248f29dcef3
|
|
| MD5 |
d7da711fe4f02e47867b9951aa808c8f
|
|
| BLAKE2b-256 |
dbd2a392547204b25cd3e3d1dc2ae16e9d0261640a524cb89447d7841cde8457
|