Skip to content

Commit

Permalink
add pyinstaller hook
Browse files Browse the repository at this point in the history
  • Loading branch information
wang0618 committed Mar 19, 2023
1 parent 1e055bb commit 26663c3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/libraries_support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can use PyInstaller to packages PyWebIO application into a stand-alone execu

You need replace ``app.py`` to your PyWebIO application file name.

2. Edit the spec file, change the ``datas`` parameter of ``Analysis``::
2. Only for PyWebIO before v1.8: Edit the spec file, change the ``datas`` parameter of ``Analysis``::

from pywebio.utils import pyinstaller_datas

Expand Down
11 changes: 11 additions & 0 deletions pywebio/platform/pyinstaller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os


# Tell PyInstaller where to find hooks provided by this distribution;
# this is referenced by the :ref:`hook registration <hook_registration>`.
# This function returns a list containing only the path to this
# directory, which is the location of these hooks.
# # https://pyinstaller.readthedocs.io/en/stable/hooks.html

def get_hook_dirs():
return [os.path.dirname(__file__)]
6 changes: 6 additions & 0 deletions pywebio/platform/pyinstaller/hook-pywebio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This is a PyInstaller hook for pywebio.
# https://pyinstaller.readthedocs.io/en/stable/hooks.html

from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files('pywebio')
45 changes: 10 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
from functools import reduce

from setuptools import setup
from setuptools import find_namespace_packages
from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -34,48 +33,24 @@
url=about['__url__'],
license=about['__license__'],
python_requires=">=3.5.2",
packages=['pywebio', 'pywebio.session', 'pywebio.platform', 'pywebio.platform.adaptor'],
packages=[p for p in find_packages() if p.startswith('pywebio')],
scripts=['tools/pywebio-path-deploy'],
package_data={
# data files need to be listed both here (which determines what gets
# installed) and in MANIFEST.in (which determines what gets included
# in the sdist tarball)
"pywebio": [
"html/codemirror/active-line.js",
"html/codemirror/matchbrackets.js",
"html/codemirror/loadmode.js",
"html/codemirror/autorefresh.js",
"html/codemirror/addons.js",
"html/codemirror/python.js",
"html/css/markdown.min.css",
"html/css/toastify.min.css",
"html/css/app.css",
"html/css/codemirror.min.css",
"html/css/bootstrap-select.min.css",
"html/css/bs-theme/default.min.css",
"html/css/bs-theme/minty.min.css",
"html/css/bs-theme/yeti.min.css",
"html/css/bs-theme/dark.min.css",
"html/css/bs-theme/sketchy.min.css",
"html/js/FileSaver.min.js",
"html/js/prism.min.js",
"html/js/purify.min.js",
"html/js/pywebio.min.js",
"html/js/pywebio.min.js.map", # only available in dev version
"html/js/mustache.min.js",
"html/js/jquery.min.js",
"html/js/bootstrap.min.js",
"html/js/bs-custom-file-input.min.js",
"html/js/popper.min.js",
"html/js/toastify.min.js",
"html/js/require.min.js",
"html/js/codemirror.min.js",
"html/js/bootstrap-select.min.js",
"html/image/favicon_open_16.png",
"html/image/favicon_closed_32.png",
"html/**",
"platform/tpl/index.html"
],
},
entry_points={
# pyinstaller hook
# https://pyinstaller.org/en/stable/hooks.html#providing-pyinstaller-hooks-with-your-package
'pyinstaller40': [
'hook-dirs = pywebio.platform.pyinstaller:get_hook_dirs',
]
},
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
Expand Down

0 comments on commit 26663c3

Please sign in to comment.