How to bundle python extensions / bindings?
ForwardFeed opened this issue · 1 comments
ForwardFeed commented
I wanted to bundle an app which contains a pywebview package for linux
pywebview relies on GTK or QT python bindings to works.
pyOxidizer doesn't seems to automatically bundle with this policy:
policy.extension_module_filter = "all"
i supposed then that i have to manually point the qtpy location and add it as a resources .
but it didn't seem to work, I'll follow my the errors and then the make_exe
[pywebview] GTK cannot be loaded
Traceback (most recent call last):
File "webview.guilib", line 25, in import_gtk
import webview.platforms.gtk as guilib
File "webview.platforms.gtk", line 20, in <module>
import gi
ModuleNotFoundError: No module named 'gi'
[pywebview] QT cannot be loaded
Traceback (most recent call last):
File "webview.guilib", line 37, in import_qt
import webview.platforms.qt as guilib
File "webview.platforms.qt", line 24, in <module>
from qtpy import QtCore
File "qtpy", line 287, in <module>
raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found
Traceback (most recent call last):
File "runpy", line 196, in _run_module_as_main
File "runpy", line 86, in _run_code
File "start", line 12, in <module>
File "start", line 9, in main
File "webview", line 155, in start
File "webview.guilib", line 109, in initialize
webview.util.WebViewException: You must have either QT or GTK with Python extensions installed in order to use pywebview.
error: cargo run failed
def make_exe():
dist = default_python_distribution()
policy = dist.make_python_packaging_policy()
policy.allow_in_memory_shared_library_loading = True
policy.allow_files = True
python_config = dist.make_python_interpreter_config()
python_config.module_search_paths = ["$ORIGIN/lib"]
python_config.run_module = "start"
exe = dist.to_python_executable(
name="server",
packaging_policy=policy,
config=python_config,
)
exe.licenses_filename = "licenses.md"
for resource in exe.pip_install(["-r", "requirements.txt"]):
if type(resource) == "File" and ".so" in resource.path:
print("Adding " + resource.path + " to bundle")
resource.add_include = True
exe.add_python_resource(resource)
exe.add_python_resources(exe.read_package_root(CWD, ["back","api", "start"]))
exe.add_python_resources(exe.read_package_root("/lib/python3.10/site-packages/", ["qtpy"]))
return exe
Hence my question, what should i try to make it work? Thanks
ForwardFeed commented
The issue is in fact deeper than i previously anticipated, as it revolves around so much things that aren't my cup of tea to learn so i'm giving up on this one.