0

I'm looking into creating a standalone Python Playwright project, but when I follow the Python Playwright installation steps mentioned here, everything gets installed in various places on my PC.

Is there a way of installing this in a preferred folder, instead of the default ones?

What I'm trying to do is have a Project Folder which contains all the installation files, dependencies and project files, which I can let's say zip and copy to another PC, unzip it and everything should still work.

Is this possible?

Thanks

  • you can use a docker container for better portability. – Gray_Rhino May 12 '21 at 07:20
  • @Gray_Rhino thanks for your comment. I'm not really familiar with Docker. How would that work? Is it something I can just copy to another PC? My issue is that the destination PC where I want this to run has no internet connection and I can't really install much stuff there. So I need something really basic, like a ZIP file which I can extract and then everything should run. Is that something Docker can do? – stereoscopique May 12 '21 at 07:29
  • I haven't used docker without an internet connection but apparently, it is possible. However, you would need an internet connection to build the image and then you save the image and export it to the machine without an internet connection. Here's the link that can be helpful [link](https://stackoverflow.com/questions/48125169/how-run-docker-images-without-connect-to-internet) – Gray_Rhino May 12 '21 at 07:39
  • This can be done, but requires some work and setting of env paths to make python and playwright aware of the new locations of your bundle. First you would need to create a standalone venv. Then copy the e.g. chromium from ~/Library/Caches/ms-playwright/chromium-854489/chrome-mac/Chromium.app/ My example ToDo is for macOs for now, but essentially it would be the same for windows. – HolgT Aug 14 '21 at 10:03

1 Answers1

0

First, you need standalone python: https://github.com/indygreg/python-build-standalone

After that you need install playwright: python -m pip install playwright

After installation, remove all unnecessary and pack it.

I also added entrypoint and browsers binaries.

Full code here: https://github.com/hemnstill/StandaloneTools/blob/master/playwright/build_gnu.sh

hemn
  • 365
  • 2
  • 9