Skip to content

Commit

Permalink
Off-load pyinstaller config to its hook
Browse files Browse the repository at this point in the history
PyInstaller now has a custom hook for Eel
(pyinstaller/pyinstaller-hooks-contrib#6) that
tells it how to collect eel.js and our hidden imports
(bottle-websocket), so we don't need our own code to enable this.

We can also define a 'distribution' extra for Eel to additionally
install PyInstaller for the user.
  • Loading branch information
samuelhwilliams committed Feb 6, 2023
1 parent 5051761 commit 3f8d06c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

### v0.15.3
* Adds a `distribution` extra to install PyInstaller automatically.
* Updates the main Eel script to build using PyInstaller's Eel hook (https://github.com/pyinstaller/pyinstaller-hooks-contrib/pull/6).

### v0.15.2
* Adds `register_eel_routes` to handle applying Eel routes to non-Bottle custom app instances.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ while True:
If you want to package your app into a program that can be run on a computer without a Python interpreter installed, you should use **PyInstaller**.

1. Configure a virtualenv with desired Python version and minimum necessary Python packages
2. Install PyInstaller `pip install PyInstaller`
2. Install Eel with extra packages to simplify distribution `pip install eel[distribution]`. Eel currently uses [PyInstaller](https://www.pyinstaller.org/) to do the hard work.
3. In your app's folder, run `python -m eel [your_main_script] [your_web_folder]` (for example, you might run `python -m eel hello.py web`)
4. This will create a new folder `dist/`
5. Valid PyInstaller flags can be passed through, such as excluding modules with the flag: `--exclude module_name`. For example, you might run `python -m eel file_access.py web --exclude win32com --exclude numpy --exclude cryptography`
Expand Down
6 changes: 1 addition & 5 deletions eel/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkg_resources as pkg
import PyInstaller.__main__ as pyi
import os
from argparse import ArgumentParser
Expand All @@ -24,12 +23,9 @@
print("Building executable with main script '%s' and web folder '%s'...\n" %
(main_script, web_folder))

eel_js_file = pkg.resource_filename('eel', 'eel.js')
js_file_arg = '%s%seel' % (eel_js_file, os.pathsep)
web_folder_arg = '%s%s%s' % (web_folder, os.pathsep, web_folder)

needed_args = ['--hidden-import', 'bottle_websocket',
'--add-data', js_file_arg, '--add-data', web_folder_arg]
needed_args = ['--add-data', web_folder_arg]
full_args = [main_script] + needed_args + unknown_args
print('Running:\npyinstaller', ' '.join(full_args), '\n')

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
install_requires=['bottle', 'bottle-websocket', 'future', 'pyparsing', 'whichcraft'],
extras_require={
"distribution": ['pyinstaller>=4.0.0,<6.0.0'],
"jinja2": ['jinja2>=2.10']
},
python_requires='>=3.6',
Expand Down

0 comments on commit 3f8d06c

Please sign in to comment.