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

Install browsers upon pip install, not the first launch #21

Closed
pavelfeldman opened this issue Jul 8, 2020 · 5 comments
Closed

Install browsers upon pip install, not the first launch #21

pavelfeldman opened this issue Jul 8, 2020 · 5 comments

Comments

@pavelfeldman
Copy link
Member

That improves user experience

@mxschmitt
Copy link
Member

mxschmitt commented Jul 8, 2020

I made some research. There is no good native way of having a postinstall script. It could be implemented like that with egg_info which is super hacky, not sure how it performs: https://stackoverflow.com/a/45021666/6512681

@pavelfeldman
Copy link
Member Author

pavelfeldman commented Jul 9, 2020

I actually made it work as described here: https://stackoverflow.com/questions/20288711/post-install-script-with-python-setuptools

But pip is suppressing the I/O, so there are no progress bars visible, which defeats the purpose of this UX improvement.

@mxschmitt
Copy link
Member

I thought about the following design when we compare it with other tools like .

  • They have a command line interface which they use to download files. In their case language models spacy download en_core_web_sm
  • It can be exposed via setup.py like package.json>bin in the Node.js world
  • If no browsers are persistent, I would download the used browser on launch() instead of all browsers

So the user can decide, either use the CLI to download the browser or the used browser get's downloaded on launch.

@pavelfeldman
Copy link
Member Author

That's probably it, we'll have the plagwright install for now

@ColdHeat
Copy link

ColdHeat commented Aug 13, 2020

Thanks for working on playwright, it's much needed for automated tests!

I personally think that I would rather have browsers installed during the pip install step even if it didn't have progress bars.

I looked around for a way to automatically install browsers on first test run perhaps and it looks like you would have to modify sys.argv to use the existing main() install.

def main() -> None:
if "install" not in sys.argv:
print('Run "python -m playwright install" to complete installation')
return
package_path = get_file_dirname()
driver_name = compute_driver_name()
driver_executable = package_path / "drivers" / driver_name
print("Installing the browsers...")
subprocess.check_call(f"{driver_executable} install", shell=True)
print("Playwright is now ready for use")

Could the install function perhaps be extracted this into a separate function that can be called without modifying sys.argv?

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

No branches or pull requests

3 participants