python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

Can't build a distribution (IsADirectoryError) #298

Closed MartinThoma closed 4 years ago

MartinThoma commented 4 years ago

Eel version

$ pip freeze | grep -i eel
Eel==0.12.3

Describe the bug I wanted to build a distributable binary as described in the docs. I got TODO.

To Reproduce Steps to reproduce the behavior:

$ git clone https://github.com/MartinThoma/write-math-eel.git && cd write-math-eel
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ pip install pyinstaller
$ python -m eel main.py web --onefile --noconsole
Building executable with main script 'main.py' and web folder 'web'...

Running:
pyinstaller main.py --hidden-import bottle_websocket --add-data /home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/eel/eel.js:eel --add-data web:web --onefile --noconsole 

380 INFO: PyInstaller: 3.6
380 INFO: Python: 3.8.1
438 INFO: Platform: Linux-5.4.0-29-generic-x86_64-with-glibc2.29
439 INFO: wrote /home/moose/GitHub/MartinThoma/write-math-eel/main.spec
440 INFO: UPX is not available.
442 INFO: Extending PYTHONPATH with paths
['/home/moose/GitHub/MartinThoma/write-math-eel',
 '/home/moose/GitHub/MartinThoma/write-math-eel']
442 INFO: checking Analysis
534 INFO: Appending 'datas' from .spec
542 INFO: checking PYZ
568 INFO: checking PKG
582 INFO: Building because toc changed
582 INFO: Building PKG (CArchive) PKG-00.pkg
52410 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
52463 INFO: Bootloader /home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/bootloader/Linux-64bit/run
52463 INFO: checking EXE
52464 INFO: Building because name changed
52464 INFO: Building EXE from EXE-00.toc
Traceback (most recent call last):
  File "/home/moose/.pyenv/versions/3.8.1/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/moose/.pyenv/versions/3.8.1/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/eel/__main__.py", line 24, in <module>
    pyi.run(full_args)
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 734, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 681, in build
    exec(code, spec_namespace)
  File "/home/moose/GitHub/MartinThoma/write-math-eel/main.spec", line 20, in <module>
    exe = EXE(pyz,
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/building/api.py", line 445, in __init__
    self.__postinit__()
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__
    self.assemble()
  File "/home/moose/GitHub/MartinThoma/write-math-eel/venv/lib/python3.8/site-packages/PyInstaller/building/api.py", line 522, in assemble
    os.remove(self.name)
IsADirectoryError: [Errno 21] Is a directory: '/home/moose/GitHub/MartinThoma/write-math-eel/dist/main'

Expected behavior I thought I would either get an exe file (e.g. when this distributable is for Windows) or a .tar.gz / .deb (when it's for Linux)

Desktop (please complete the following information):

Additional context The documentation is not clear if this is OS specific and which OS it is for.

RahulBadenkal commented 4 years ago

Try onedir, instead of onefile and see if it works then

samuelhwilliams commented 4 years ago

Hi @MartinThoma - did you get to the bottom of this?

If not, try deleting the dist directory and rebuilding. I think I hit a similar thing today.

I'll close this for now to try to keep things tidy - but if you are still having the problem, just reply and we can take another look.

MartinThoma commented 4 years ago

Huh, weird. It works.

Eel==0.12.3
PyInstaller==3.6
MartinThoma commented 4 years ago

There is an issue with the executable. It seems as if not all files were included:

./main 
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._greenlet.Greenlet.run
  File "site-packages/eel/__init__.py", line 257, in _process_message
  File "main.py", line 43, in worker
  File "site-packages/hwrt/classify.py", line 92, in classify_segmented_recording
  File "site-packages/hwrt/classify.py", line 28, in __init__
  File "site-packages/hwrt/utils.py", line 451, in load_model
  File "tarfile.py", line 1599, in open
  File "tarfile.py", line 1664, in gzopen
  File "gzip.py", line 173, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/_MEIFW6rbP/hwrt/misc/model.tar'
2020-06-18T21:06:35Z <Greenlet at 0x7fac5eff6040: _process_message({'call': 1.8640561829231295, 'name': 'worker', 'ar, <geventwebsocket.websocket.WebSocket object at 0x7)> failed with FileNotFoundError
samuelhwilliams commented 4 years ago

You may need to build it without the --onefile flag and check that all the files/packages/libs that your app needs are being collected by pyinstaller correctly. Sometimes, I think, it can miss things. This feels like what's happening - it can't find model.tar.

The PyInstaller docs should help you include extra files you need. https://pyinstaller.readthedocs.io/en/stable/operating-mode.html#analysis-finding-the-files-your-program-needs

MartinThoma commented 4 years ago

Sorry, I haven't seen your answer before I posted the other issue. In between, I tried it like this but I failed - but you helped me: https://github.com/samuelhwilliams/Eel/issues/331 🎉