PreTeXtBook / pretext-codespace

A template for creating a PreTeXt project that runs in GitHub Codespaces
MIT License
10 stars 12 forks source link

devcontainer not compatible with Playwright #12

Closed StevenClontz closed 1 year ago

StevenClontz commented 1 year ago

Trying to generate assets that rely on Playwright is currently broken. See the cli.log output below:

INFO    : PreTeXt project found in `/workspaces/didactic-octo-fiesta`.
DEBUG   : CLI version 1.6.0 matches requirements.txt 1.6.0.
INFO    : Since no target was specified with the -t flag, we will generate assets for the first target in the manifest (web).
INFO    : Generating all assets in default formats for the target "web".
INFO    : Note: No webwork elements found.
INFO    : Note: No latex-image elements found.
INFO    : Note: No asymptote elements found.
INFO    : Note: No sageplot elements found.
INFO    : Attempting to install/update required playwright packages.
DEBUG   : Installed dependencies to capture interactive previews
INFO    : Now generating preview images for interactives

DEBUG   : Now working in directory .
INFO    : using playwright package to create previews for interactives from /workspaces/didactic-octo-fiesta/source/main.ptx for placement in /workspaces/didactic-octo-fiesta/generated-assets/preview
DEBUG   : Interactives id list temporarily in /tmp/tmpj4wh7dy2/interactives-ids.txt
DEBUG   : Interactives html files temporarily in /tmp/tmpj4wh7dy2
INFO    : XSL conversion of /workspaces/didactic-octo-fiesta/source/main.ptx by /root/.ptx/xsl/extract-interactive.xsl
DEBUG   : XSL conversion via /root/.ptx/xsl/extract-interactive.xsl of /workspaces/didactic-octo-fiesta/source/main.ptx to /tmp/tmpj4wh7dy2/interactives-ids.txt and/or into directory /tmp/tmpj4wh7dy2 with parameters {'publisher': '/workspaces/didactic-octo-fiesta/publication/publication.ptx'}
INFO    : comprehensive messages, warnings, and errors:
INFO    : successful application of /root/.ptx/xsl/extract-interactive.xsl
INFO    : discovering source file's directory name: /workspaces/didactic-octo-fiesta/source
INFO    : verifying and expanding input directory: /workspaces/didactic-octo-fiesta/source/../generated-assets
INFO    : input directory expanded to absolute path: /workspaces/didactic-octo-fiesta/generated-assets
INFO    : verifying and expanding input directory: /workspaces/didactic-octo-fiesta/source/../assets
INFO    : input directory expanded to absolute path: /workspaces/didactic-octo-fiesta/assets
INFO    : Opening subprocess http.server with port=8888
DEBUG   : Using http.server subprocess 1732
INFO    : Closing http.server subprocess
DEBUG   : Log data from http.server:
DEBUG   : 
ERROR   : Failed to generate interactive element previews. Check debug log for info.
DEBUG   : 
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Missing libraries:                                   ║
║     libatk-1.0.so.0                                  ║
║     libatk-bridge-2.0.so.0                           ║
║     libdrm.so.2                                      ║
║     libxkbcommon.so.0                                ║
║     libatspi.so.0                                    ║
║     libXcomposite.so.1                               ║
║     libXdamage.so.1                                  ║
║     libXfixes.so.3                                   ║
║     libXrandr.so.2                                   ║
║     libgbm.so.1                                      ║
║     libasound.so.2                                   ║
╚══════════════════════════════════════════════════════╝
DEBUG   : Exception info:
##################
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pretext/generate.py", line 211, in interactive
    core.preview_images(
  File "/usr/local/lib/python3.11/site-packages/pretext/core/pretext.py", line 2071, in preview_images
    asyncio.get_event_loop().run_until_complete(generate_previews(interactives, baseurl, dest_dir))
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pretext/core/pretext.py", line 1970, in generate_previews
    browser = await pw.chromium.launch()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/playwright/async_api/_generated.py", line 14665, in launch
    await self._impl_obj.launch(
  File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_browser_type.py", line 95, in launch
    Browser, from_channel(await self._channel.send("launch", params))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 61, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 482, in wrap_api_call
    return await cb()
           ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 97, in inner_send
    result = next(iter(done)).result()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
playwright._impl._api_types.Error: 
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Missing libraries:                                   ║
║     libatk-1.0.so.0                                  ║
║     libatk-bridge-2.0.so.0                           ║
║     libdrm.so.2                                      ║
║     libxkbcommon.so.0                                ║
║     libatspi.so.0                                    ║
║     libXcomposite.so.1                               ║
║     libXdamage.so.1                                  ║
║     libXfixes.so.3                                   ║
║     libXrandr.so.2                                   ║
║     libgbm.so.1                                      ║
║     libasound.so.2                                   ║
╚══════════════════════════════════════════════════════╝
INFO    : ##################
WARNING : Continuing...
DEBUG   : Successfully changed directory back to .
INFO    : Note: No video@youtube elements found.
INFO    : Now copying play-button image for videos

DEBUG   : Now working in directory .
INFO    : Generating generic video preview, aka "play button" into /workspaces/didactic-octo-fiesta/generated-assets/play-button
DEBUG   : Successfully changed directory back to .
INFO    : Note: No program elements using codelens found.
INFO    : Note: No elements needing datafile conversion found
INFO    : Now generating QR codes for videos and/or interactives

DEBUG   : Now working in directory .
INFO    : manufacturing QR codes from /workspaces/didactic-octo-fiesta/source/main.ptx for placement in /workspaces/didactic-octo-fiesta/generated-assets/qrcode
DEBUG   : QR code id list temporarily in /tmp/tmp2mnp1s3o/qrcode-ids.txt
INFO    : XSL conversion of /workspaces/didactic-octo-fiesta/source/main.ptx by /root/.ptx/xsl/extract-qrcode.xsl
DEBUG   : XSL conversion via /root/.ptx/xsl/extract-qrcode.xsl of /workspaces/didactic-octo-fiesta/source/main.ptx to /tmp/tmp2mnp1s3o/qrcode-ids.txt and/or into directory None with parameters {'publisher': '/workspaces/didactic-octo-fiesta/publication/publication.ptx'}
INFO    : comprehensive messages, warnings, and errors:
INFO    : successful application of /root/.ptx/xsl/extract-qrcode.xsl
INFO    : creating URL with content "interactive-infinity.html" as /workspaces/didactic-octo-fiesta/generated-assets/qrcode/interactive-infinity.png...
INFO    : QR code creation complete
DEBUG   : Successfully changed directory back to .
DEBUG   : Temporary directories left behind for inspection: ['/tmp/tmpj4wh7dy2', '/tmp/tmp2mnp1s3o']
INFO    : While running pretext, the following errors occurred:
StevenClontz commented 1 year ago

This was discovered by running the PreTeXt-CLI test suite in the oscarlevin/pretext:full container. Specifically https://github.com/PreTeXtBook/pretext-cli/blob/8fe70f91be77d4fa83f15e7a16b8d096a36be0e6/tests/test_cli.py#L160 is what fails.

oscarlevin commented 1 year ago

I think this is the reason. I am rebuilding the docker images now, so check again later and it should be fixed.

StevenClontz commented 1 year ago

Nice. I'll at least attempt a quick stab at this after dinner, modulo family activities.