diff --git a/docs/libraries_support.rst b/docs/libraries_support.rst index bca29be0..636cc0d9 100644 --- a/docs/libraries_support.rst +++ b/docs/libraries_support.rst @@ -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 diff --git a/pywebio/platform/pyinstaller/__init__.py b/pywebio/platform/pyinstaller/__init__.py new file mode 100644 index 00000000..789a6947 --- /dev/null +++ b/pywebio/platform/pyinstaller/__init__.py @@ -0,0 +1,11 @@ +import os + + +# Tell PyInstaller where to find hooks provided by this distribution; +# this is referenced by the :ref:`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__)] diff --git a/pywebio/platform/pyinstaller/hook-pywebio.py b/pywebio/platform/pyinstaller/hook-pywebio.py new file mode 100644 index 00000000..1dbc67ba --- /dev/null +++ b/pywebio/platform/pyinstaller/hook-pywebio.py @@ -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') diff --git a/setup.py b/setup.py index d6b25cf1..74775c0b 100644 --- a/setup.py +++ b/setup.py @@ -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__)) @@ -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",