microsoft / playwright-python

Python version of the Playwright testing and automation library.

Home Page:https://playwright.dev/python/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyInstaller can't package chromium driver on x86_64[Bug]:

timrichardson opened this issue · comments

Version

1.42.0

Steps to reproduce

Create a python script using the Chromium driver, installed as
PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium

I invoke as such:

def show_browser_for_login(playwright_instance, org_id) -> Tuple[Page, BrowserContext, Browser]:
   """ called by fetch_cookied_from_dear"""
   browser = playwright_instance.chromium.launch(headless=False)
   context = browser.new_context()
   saved_cookies = load_saved_cookies()
   if saved_cookies:
       context.add_cookies(saved_cookies)
   page = context.new_page()
   login_url = f"""https://inventory.dearsystems.com/Home/Organisation?ID={org_id}"""  # login for TOQ
   page.goto(login_url)
   return page, context, browser

the code runs on linux, mac, windows.
It packages fine on windows users in

pyinstaller --onefile -w dear_auth.py

but on the mac, (intel) I get:

Traceback (most recent call last):
  File "/Users/tim/PycharmProjects/dearAuth/.venv/lib/python3.11/site-packages/PyInstaller/building/utils.py", line 315, in process_collected_binary
    osxutils.sign_binary(cached_name, codesign_identity, entitlements_file)
  File "/Users/tim/PycharmProjects/dearAuth/.venv/lib/python3.11/site-packages/PyInstaller/utils/osx.py", line 387, in sign_binary
    raise SystemError(f"codesign command ({cmd_args}) failed with error code {p.returncode}!\noutput: {p.stdout}")
SystemError: codesign command (['codesign', '-s', '-', '--force', '--all-architectures', '--timestamp', '/Users/tim/Library/Application Support/pyinstaller/bincache00py31164bit/x86_64/adhoc/no-entitlements/playwright/driver/package/.local-browsers/chromium-1105/chrome-mac/Chromium.app/Contents/MacOS/Chromium']) failed with error code 1!
output: /Users/tim/Library/Application Support/pyinstaller/bincache00py31164bit/x86_64/adhoc/no-entitlements/playwright/driver/package/.local-browsers/chromium-1105/chrome-mac/Chromium.app/Contents/MacOS/Chromium: bundle format unrecognized, invalid, or unsuitable

I am using the "ad-hoc" signing method.

Expected behavior

the bundle should be signable

Actual behavior

error as logged above

Additional context

No response

Environment

- Operating System: Ventura 13.6.5 running in kvm/qemu
- CPU: [intel]
- Browser: [Chromium]
- Python Version: [3.11.8]
- Other info:

Note that removing the chromium binary

PLAYWRIGHT_BROWSERS_PATH=0 playwright uninstall chromium

allows the build to succeed. Although of course it won't run.

the webkit binary does not cause the same problem. The build succeeds.