07th-mod / 07th-mod/python-patcher

Launch Webview on Linux/MacOS

Đang mở
#195 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
JavaScript
Star
214
Fork
12
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

So to give some history, I've mostly finished adding a webview via Rust's wry library, see https://github.com/07th-mod/python-patcher/pull/186. It is more complicated than it should be, because I need to figure out the port the python script has launched on, and pass the information from Python to Rust via a file.

In addition, this only currently works on Windows, because we only produce the rust install loader on Windows - on MacOS and Linux we just distribute the python scripts.

However, recently @andOlga mentioned that there's a much easier way to launch a webview on linux, which is essentially the same thing that wry does, which is to just directly call `msedge` to launch a webview like:

```python
subprocess.run([
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
"--app=https://www.google.com",
"--user-data-dir=c:\\temp\\webview"
])
```

Because we can call this from Python, doing it this would simplify things quite a bit, however given that I've mostly tested and finished the Windows-only Rust version, I will probably just go with that for now. Some of the changes I've made would also still exist even if we use the Rust version.

----

Coming back to the point of this issue, If we want to launch Webview on Linux/MacOS, we might be able to use something similar to the above (launched from the Python side):

- On Linux, if chromium is installed we can use that, if not we can just fallback to the web browser
- For MacOS, I'm not sure what program or arguments should be used, but as wry states it uses webkit, so I assume it's available there too

----

Another (better) alternative suggested by andOlga was to use https://github.com/r0x0r/pywebview , which behaves pretty much the same as Rust's wry library.

We need to setup using external libraries in the installer. andOlga suggested shipping venv and activating it before we run the installer. I'm not too sure how venv works, but if we can't directly include the packages in a venv in the installer, we could create a venv and install packages to that venv at runtime, assuming it doesn't make the installer take too long to start up.

Also, if it is possible to use this across all platforms, and it has no missing features from the existing Windows wry based webview, I would just use it across all platforms to keep it consistent and remove our wry webview

----

PyOxidizer (https://github.com/indygreg/PyOxidizer) was recommended as a way to deal with distributing python with included libs. Previously I had tried using pyinstaller (can't remember what happened), but I haven't tried pyoxidizer before.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Issue này mô tả việc thêm webview cho Linux và macOS vào trình cài đặt mod game dựa trên Python. Kiểm tra cách triển khai Windows hiện có sử dụng thư viện wry của Rust trong pull request #186. Nghiên cứu pywebview như một giải pháp thay thế đa nền tảng và PyOxidizer để phân phối. Mục tiêu là khởi chạy webview từ Python, xử lý các lệnh trình duyệt cụ thể cho nền tảng hoặc một thư viện, và tích hợp nó vào trình cài đặt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, python, rust
Lĩnh vực
cli, desktop, tooling
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.