Skip to content

Commit 26663c3

Browse files
committed
add pyinstaller hook
1 parent 1e055bb commit 26663c3

File tree

4 files changed

+28
-36
lines changed

4 files changed

+28
-36
lines changed

docs/libraries_support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can use PyInstaller to packages PyWebIO application into a stand-alone execu
1515

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

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

2020
from pywebio.utils import pyinstaller_datas
2121

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
4+
# Tell PyInstaller where to find hooks provided by this distribution;
5+
# this is referenced by the :ref:`hook registration <hook_registration>`.
6+
# This function returns a list containing only the path to this
7+
# directory, which is the location of these hooks.
8+
# # https://pyinstaller.readthedocs.io/en/stable/hooks.html
9+
10+
def get_hook_dirs():
11+
return [os.path.dirname(__file__)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This is a PyInstaller hook for pywebio.
2+
# https://pyinstaller.readthedocs.io/en/stable/hooks.html
3+
4+
from PyInstaller.utils.hooks import collect_data_files
5+
6+
datas = collect_data_files('pywebio')

setup.py

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import os
22
from functools import reduce
33

4-
from setuptools import setup
5-
from setuptools import find_namespace_packages
4+
from setuptools import setup, find_packages
65

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

@@ -34,48 +33,24 @@
3433
url=about['__url__'],
3534
license=about['__license__'],
3635
python_requires=">=3.5.2",
37-
packages=['pywebio', 'pywebio.session', 'pywebio.platform', 'pywebio.platform.adaptor'],
36+
packages=[p for p in find_packages() if p.startswith('pywebio')],
3837
scripts=['tools/pywebio-path-deploy'],
3938
package_data={
4039
# data files need to be listed both here (which determines what gets
4140
# installed) and in MANIFEST.in (which determines what gets included
4241
# in the sdist tarball)
4342
"pywebio": [
44-
"html/codemirror/active-line.js",
45-
"html/codemirror/matchbrackets.js",
46-
"html/codemirror/loadmode.js",
47-
"html/codemirror/autorefresh.js",
48-
"html/codemirror/addons.js",
49-
"html/codemirror/python.js",
50-
"html/css/markdown.min.css",
51-
"html/css/toastify.min.css",
52-
"html/css/app.css",
53-
"html/css/codemirror.min.css",
54-
"html/css/bootstrap-select.min.css",
55-
"html/css/bs-theme/default.min.css",
56-
"html/css/bs-theme/minty.min.css",
57-
"html/css/bs-theme/yeti.min.css",
58-
"html/css/bs-theme/dark.min.css",
59-
"html/css/bs-theme/sketchy.min.css",
60-
"html/js/FileSaver.min.js",
61-
"html/js/prism.min.js",
62-
"html/js/purify.min.js",
63-
"html/js/pywebio.min.js",
64-
"html/js/pywebio.min.js.map", # only available in dev version
65-
"html/js/mustache.min.js",
66-
"html/js/jquery.min.js",
67-
"html/js/bootstrap.min.js",
68-
"html/js/bs-custom-file-input.min.js",
69-
"html/js/popper.min.js",
70-
"html/js/toastify.min.js",
71-
"html/js/require.min.js",
72-
"html/js/codemirror.min.js",
73-
"html/js/bootstrap-select.min.js",
74-
"html/image/favicon_open_16.png",
75-
"html/image/favicon_closed_32.png",
43+
"html/**",
7644
"platform/tpl/index.html"
7745
],
7846
},
47+
entry_points={
48+
# pyinstaller hook
49+
# https://pyinstaller.org/en/stable/hooks.html#providing-pyinstaller-hooks-with-your-package
50+
'pyinstaller40': [
51+
'hook-dirs = pywebio.platform.pyinstaller:get_hook_dirs',
52+
]
53+
},
7954
classifiers=[
8055
"Programming Language :: Python :: 3",
8156
"Programming Language :: Python :: 3.5",

0 commit comments

Comments
 (0)