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

[py2app] window.pywebviewready not firing #1565

Open
sardination opened this issue Jan 5, 2025 · 4 comments
Open

[py2app] window.pywebviewready not firing #1565

sardination opened this issue Jan 5, 2025 · 4 comments

Comments

@sardination
Copy link
Contributor

sardination commented Jan 5, 2025

Specification

  • pywebview version: 5.3+
  • operating system: MacOS
  • web renderer: Cocoa

Description

Starting with version 5.3, the window.pywebviewready event is not firing in a py2app packaged app. Subsequently, window.pywebview is never available.

Possibly related to #1504

Practicalities

  • YES I am willing to work on this issue myself.

  • NO I am prepared to support this issue financially.

@sardination sardination changed the title window.pywebviewready not firing [py2app] window.pywebviewready not firing Jan 5, 2025
@r0x0r
Copy link
Owner

r0x0r commented Jan 5, 2025

This is caused by the js files introduced in 5.3 and more specifically by this line, which points to a virtual path inside the zip file that does not exist in the file system.

I have tried --packages webview option, as well as this recipe inside setup.py to exclude pywebview from the zip file, but they did not help. In my case, pywebview is included both in python3.x folder, as well as python3.x.zip file and it picks the one inside the zip file.

import py2app.recipes

class webview_recipe:
    def check(self, cmd, mf):
        m = mf.findNode("webview")
        if m is None or m.filename is None:
            return None

        # Exclude from site-packages.zip
        return {"packages": ["webview"]}

py2app.recipes.webview = webview_recipe()

@r0x0r
Copy link
Owner

r0x0r commented Jan 7, 2025

I have attemped to solve this issue using recipes and cli switches, but could not figure it out. I have raised an issue with py2app ronaldoussoren/py2app#540

One solution that could work is to have a custom py2app logic that would check if the library is executed from the zip file and locate js files from the python3.x folder. This is rather hacky though, I would prefer to solve this using tools provided by py2app.

@r0x0r
Copy link
Owner

r0x0r commented Jan 7, 2025

I pushed the proposed fix to the master. Works in my setup.

@sardination
Copy link
Contributor Author

Fix on master works for me as well. Happy to leave this issue open until py2app pushes support / we find out how to use existing py2app tools to do this.

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

2 participants