Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added hooks for pyinstaller #812

Merged
merged 3 commits into from
Jul 21, 2021
Merged

feat: added hooks for pyinstaller #812

merged 3 commits into from
Jul 21, 2021

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jul 19, 2021

For review instructions:

  • Create a file main.py
  • add this to the file
import os

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("http://whatsmyuseragent.org/")
    page.screenshot(path="example.png")
    browser.close()
  • If you want to bundle browsers then set PLAYWRIGHT_BROWSERS_PATH=0 to include bowser's inside the binary and then download the browsers
  • installer pyinstaller
pip install pyinstaller
  • Run pyinstaller on the file like
pyinstaller -F main.py
  • Binary would be placed in dist/ relative to current dir and test it

@mxschmitt
Copy link
Member

10+ individual users requested it, so makes sense to add support for it.

Fixes #513

Copy link
Member

@mxschmitt mxschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested with the following test case:

  1. PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium
  2. pyinstaller -F test.py
  3. clean browsers to make sure we are not using the wrong ones
  4. PLAYWRIGHT_BROWSERS_PATH=0 ./dist/test

@kumaraditya303
Copy link
Contributor Author

cc: @pavelfeldman

@mxschmitt
Copy link
Member

mxschmitt commented Jul 21, 2021

We can land if you somehow can set the env var for the driver automatically. Like detect somehow if its pyinstaller and then set it.

Had an offline discussion with him about it.

@kumaraditya303 kumaraditya303 requested a review from mxschmitt July 21, 2021 07:33
@kumaraditya303
Copy link
Contributor Author

We can land if you somehow can set the env var for the driver automatically. Like detect somehow if its pyinstaller and then set it.

Had an offline discussion with him about it.

Done!

Copy link
Member

@mxschmitt mxschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

playwright/_impl/_transport.py Show resolved Hide resolved
@mxschmitt mxschmitt merged commit bc7a802 into microsoft:master Jul 21, 2021
@kumaraditya303 kumaraditya303 deleted the pyinstaller branch July 22, 2021 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants