r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.64k stars 539 forks source link

Problem with app froze at github actions #609

Closed igormaraujo closed 3 years ago

igormaraujo commented 3 years ago

Specification

Description

I create a workflow to freeze the hello world pywebview aplication using pyinstaller at github actions. The executable don't work at my machine. I try the same executable at five machines (include my own) and the app run only at two. Also, the app runs at my machine if I freeze it at my own machine.

main.py
import webview 
webview.create_window('Hello world', 'https://pywebview.flowrl.com/')
webview.start()
python-app.yml
name: Python application
on:
  push:
    branches: [ test ]
  pull_request:
    branches: [ test ]
jobs:
  build:
    runs-on: windows-2019
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.7.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.7.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install pywebview==3.3.3 pyinstaller==4.0
    - name: Build with pyinstaller
      run: |
        pyinstaller main.py
    - name: Upload a Build Artifact
      uses: actions/upload-artifact@v2.1.4
      with:
        name: windows
        path: ./dist/
Runtime error message
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'file:///<apath>\Python.Runtime.dll' or one of its dependencies.
Operation is not supported. (Exception from HRESULT: 0x80131515) ---> System.NotSupportedException: An attempt was made to load an assembly
from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework.
This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous.
If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
   --- End of inner exception stack trace ---
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at clrModule.PyInit_clr()
r0x0r commented 3 years ago

Judging by the error report, it cannot find Python.Runtime.dll (as required by pythonnet). Try copying this file to your frozen folder and see if it makes a difference. The dll is located in the package directory. Normally the pythonnet hook should take care of this, but it may be that Pyinstaller 4.0 broke something.

igormaraujo commented 3 years ago

There is the Python.Runtime.dll at my frozen folder. If I use the the Python.Runtime.dll from The GitHub Action workflow hosted visual environment, it don't work. However, if I use the dll in the package directory from my own machine, it is work. I am think that there is some compatibility problem with the dll compiled at GitHub Actions.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

r0x0r commented 3 years ago

The error message says


If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch.```

Have you tried to enable the loadFromRemoteSources switch? 
github-actions[bot] commented 3 years ago

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.