flet
flet copied to clipboard
build command doesn't collect playwright binary files
Description
I have created a GUI for my app that uses Playwright, it works well until I have built it with the build command flet build windows it builds the app without any problem and runs it without error but when Playwright wants to launch the browser it returns an error, I investigated and found the problem. Playwright has node.js binary in this path:
C:\Users\%user%\AppData\Roaming\Python\Python312\site-packages\playwright\driver\node.exe
but felt doesn't collect it to include it in __pypackages__ in the assets of the app so it can not launch the browser, I tried adding it manually in the archive file located in:
<build directory>\build\windows\data\flutter_assets\app\app.zip
Then I removed the temp folder and relaunched the app and it worked flawlessly. I have to notice that I didn't have this problem with flet pack command.
Code example to reproduce the issue:
from playwright.async_api import async_playwright, Playwright, BrowserContext
async def create_context() -> BrowserContext:
ignore_args = [
"--enable-automation",
'--disable-extensions'
]
args = [
"--disable-blink-features=AutomationControlled",
"--webrtc-ip-handling-policy=disable_non_proxied_udp",
"--start-maximized",
"--ignore-certificate-errors",
"--disable-infobars",
]
playwright = await async_playwright().start()
chromium = playwright.chromium
context = await chromium.launch(
channel="chrome",
headless=False,
ignore_default_args=ignore_args,
args=args,
chromium_sandbox=True,
java_script_enabled=True
)
return context
Describe the results you received:
Describe the results you expected:
I expected that the felt build command would collect binary files of libraries like the pack command.
Additional information you deem important (e.g. issue happens only occasionally):
Flet version (pip show flet):
Name: flet
Version: 0.21.2
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: [email protected]
License: Apache-2.0
Location: C:\Users\Farshad\AppData\Roaming\Python\Python312\site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog
Required-by:
Give your requirements.txt file (don't pip freeze, instead give direct packages):
flet==0.21.2
playwright
Operating system: Windows 11