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

[Feature] Playwright should be able to install browser binaries from poetry install (Python) #1322

Open
dil-gfischhof opened this issue May 23, 2022 · 8 comments

Comments

@dil-gfischhof
Copy link

Playwright should be able to install browser binaries from poetry install (Python)
(Specially related to CI systems)

Hi Folks,

Two things to start my feature request with:
1.)
Poetry is practically the new way of Python package management
2.)
Installing project dependencies is practically the responsibility of the project (yes, the borders are flexible...)

So I have the following situation:
we have a project which needs in-browser testing, and API testing, perhaps someone will need other (performance etc) testing, which does not require browser.

Right now we use Poetry (Python) to install dependencies, it installs Playwright, but is not able to tell Playwright to install browsers binaries.

So now we have to setup our CI to install browser binaries, but the other CI jobs do not need that, so installing is just waste of time and space.
But it would be good to have only one type of test job in CI: install project dependencies, and start testing. And if the project needs browser then it should install it automatically.

BR,
George

@yury-s yury-s transferred this issue from microsoft/playwright May 24, 2022
@yury-s
Copy link
Member

yury-s commented May 24, 2022

Can you explain how you see this working with poetry (what commands the user would have to run to install playwright with browsers vs. without them)? Or do you want it to essentially run playwright install as part of playwright installation?

@dil-gfischhof
Copy link
Author

dil-gfischhof commented May 24, 2022

Hi,

as playwright's strength is browser automation, so I think it should install browser as default.

Installing all would be time and space consuming, so I think installing the one with the largest market share -which is chromium- would be a good choice for default.

The adding method / syntax for browsers should follow optional dependencies:
poetry add playwright - would install chromium
poetry add playwright[chromium] - would install chromium
poetry add playwright[all]- would install all
poetry add playwright[chrome, firefox] - would install chrome and firefox
poetry add playwright[no-browser] - would not install any browser

and I think it would be good to add browser dependencies automatically too, specially because the user may not know what are the dependencies and what kind of dependencies are there, what will not work without them

BR,
George

@codejedi-ai
Copy link

As of right now poetry add playwright does not work instead it throws and error. I am currently using poetry 1.1.13. How should I structure the commands to add playwright?

@dil-gfischhof
Copy link
Author

@codejedi-ai What error do you have?

@FredHappyface
Copy link

FredHappyface commented Jan 8, 2023

Currently I use https://github.com/pyppeteer/pyppeteer within a python library to launch a headless chrome instance, do some "stuff"

https://github.com/pyppeteer/pyppeteer currently will install a chrome instance on the first run. For example when testing a poetry project with 'tox'. As this is intended for a library and poetry will not provide the means to add a post install script to my lib is it possible to install a browser at runtime as with pyppeteer?

Potential solutions to this problem are:

  1. Continue using an out of support tool [less than ideal]
  2. Use a different packaging tool that supports post-install
  3. Ask "playwright" devs if they'd consider installing a browser binary with pip install [seems compatible with the 'happy path' for an end user too rather than running playwright install
  4. Ask "playwright" devs if they'd consider exposing some function call to do a playwright install eg
    from playwright import install
    install("chrome")
    There is already a project that acheived this by calling pyright install with the subprocess module https://pypi.org/project/install-playwright/

Thank you for your time :)

@umang94
Copy link

umang94 commented Apr 20, 2024

Hi,
I ran into this problem while setting up langchain for webscraping. Looks like Poetry as a tool will never support post-install scripts.
@mxschmitt How long is the feedback collection process ? The 7 likes on @dil-gfischhof 's approach makes it seem like there is consensus.

@DanteOz
Copy link

DanteOz commented Jun 12, 2024

+1 for @dil-gfischhof 's suggestion

Using optional dependencies to install browsers would simplify CI, and help the dev workflow, for the project I'm currently working on. Would be great to see a resolution on this issue, either way, given the original creation date.

@nmzabith
Copy link

nmzabith commented Jun 13, 2024

+1 for the suggestion

came across the issue while deploying a web scraping service, its clean if we can do this within poetry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants