Nuitka / Nuitka

Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.12. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
http://nuitka.net
Apache License 2.0
12.03k stars 649 forks source link

Plotly needs to be explicitly included with --include-package when using dash #2971

Open Ivorforce opened 4 months ago

Ivorforce commented 4 months ago

I've recently created the Dash / Nuitka Standalone Boilerplate. The example contains many explicit --include-package arguments, so I tested without them. Most can be removed, but one (plotly) seems to be required right now:

❯ build/main.app/Contents/MacOS/main
Dash is running on http://127.0.0.1:8050/

 * Serving Flask app 'main'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:8050
Press CTRL+C to quit
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/deps/react@16.v2_17_1m1719940698.14.0.min.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/deps/polyfill@7.v2_17_1m1719940698.12.1.min.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/deps/prop-types@15.v2_17_1m1719940698.8.1.min.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/deps/react-dom@16.v2_17_1m1719940698.14.0.min.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/dcc/dash_core_components.v2_14_1m1719940698.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_17_1m1719940698.min.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/dcc/dash_core_components-shared.v2_14_1m1719940698.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/html/dash_html_components.v2_0_18m1719940698.min.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/dash_table/bundle.v5_2_11m1719940698.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-dependencies HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-layout HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/dcc/async-dropdown.js HTTP/1.1" 200 -
127.0.0.1 - - [02/Jul/2024 19:18:21] "GET /_dash-component-suites/dash/dcc/async-graph.js HTTP/1.1" 200 -
[2024-07-02 19:18:21,998] ERROR in app: Exception on /_dash-component-suites/plotly/package_data/plotly.min.js [GET]
Traceback (most recent call last):
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 1473, in wsgi_app
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 882, in full_dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 0, in handle_user_exception
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 880, in full_dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 865, in dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/dash/dash.py", line 998, in serve_component_suites
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/_plotly_utils/importers.py", line 36, in __getattr__
  File "importlib.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plotly.version'
127.0.0.1 - - [02/Jul/2024 19:18:22] "GET /_dash-component-suites/plotly/package_data/plotly.min.js HTTP/1.1" 500 -
[2024-07-02 19:18:22,056] ERROR in app: Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 1473, in wsgi_app
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 882, in full_dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 0, in handle_user_exception
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 880, in full_dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/flask/app.py", line 865, in dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/dash/dash.py", line 1373, in dispatch
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/dash/_callback.py", line 465, in add_context
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/dash/_callback.py", line 40, in _invoke_callback
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/dnb/server.py", line 36, in update_graph
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/express/_chart_types.py", line 264, in line
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/express/_core.py", line 2088, in make_figure
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/express/_core.py", line 940, in apply_default_cascade
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/graph_objs/layout/_template.py", line 231, in layout
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/basedatatypes.py", line 4723, in __getitem__
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/basedatatypes.py", line 4344, in _get_validator
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/plotly/validator_cache.py", line 28, in get_validator
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/_plotly_utils/importers.py", line 36, in __getattr__
  File "importlib.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plotly.validators.layout.template._layout'
127.0.0.1 - - [02/Jul/2024 19:18:22] "POST /_dash-update-component HTTP/1.1" 500 -
/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_32048_1719940698_101823/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 4 leaked semaphore objects to clean up at shutdown

To reproduce, clone and set up the repository, and run:

poetry run python -m nuitka --output-dir=build --onefile --macos-create-app-bundle --include-package-data=dash --include-package-data=dash_core_components --include-package-data=dash_html_components --include-package-data=packaging --include-package-data=plotly --include-package-data=dnb src/dnb/main.py

A working version of the command looks like this:

poetry run python -m nuitka --output-dir=build --onefile --macos-create-app-bundle --include-package-data=dash --include-package-data=dash_core_components --include-package-data=dash_html_components --include-package-data=packaging --include-package=plotly --include-package-data=plotly --include-package-data=dnb src/dnb/main.py

Versions

❯ poetry run python -m nuitka --version
The currently activated Python version 3.10.2 is not supported by the project (~3.9).
Trying to find and use a compatible version.
Using python3.9 (3.9.17)
2.3.10
Commercial: None
Python: 3.9.17 (main, Jun 20 2023, 17:20:08)
Flavor: Homebrew Python
Executable: /Users/lukas/Library/Caches/pypoetry/virtualenvs/dash-nuitka-boilerplate-AT3R1IMP-py3.9/bin/python
OS: Darwin
Arch: x86_64
macOSRelease: 14.5
Version C compiler: /usr/bin/clang (clang 15.0.0).
❯ poetry run python -m pip list -v
Package                   Version
------------------------- -----------
blinker                   1.8.2
bottle                    0.12.25
certifi                   2024.6.2
charset-normalizer        3.3.2
click                     8.1.7
dash                      2.17.1
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-nuitka-boilerplate   0.1.0
dash-table                5.0.0
Flask                     3.0.3
idna                      3.7
importlib_metadata        8.0.0
itsdangerous              2.2.0
Jinja2                    3.1.4
MarkupSafe                2.1.5
nest-asyncio              1.6.0
Nuitka                    2.3.10
numpy                     2.0.0
ordered-set               4.1.0
packaging                 24.1
pandas                    2.2.2
pip                       23.3.1
plotly                    5.22.0
proxy_tools               0.1.0
pyobjc-core               10.3.1
pyobjc-framework-Cocoa    10.3.1
pyobjc-framework-Security 10.3.1
pyobjc-framework-WebKit   10.3.1
python-dateutil           2.9.0.post0
pytz                      2024.1
pywebview                 5.1
requests                  2.32.3
retrying                  1.3.4
setproctitle              1.3.3
setuptools                70.1.1
six                       1.16.0
tenacity                  8.4.2
typing_extensions         4.12.2
tzdata                    2024.1
urllib3                   2.2.2
Werkzeug                  3.0.3
zipp                      3.19.2
zstandard                 0.22.0
Ivorforce commented 4 months ago

As of rev 75e24f60bd7c6ab54b10cbf701621f76f229f40e, which includes the merges from #2972, an explicit --include-package=plotly is still required. The error I'm getting right now is similar, but not equal, to last time (tested on a different app):

❯ ./build/main.app/Contents/MacOS/main
Dash is running on http://127.0.0.1:8050/

 * Serving Flask app 'ecgviewer.server'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:8050
Press CTRL+C to quit
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/deps/react@16.v2_17_1m1720702281.14.0.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_17_1m1720702281.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/deps/polyfill@7.v2_17_1m1720702281.12.1.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/deps/react-dom@16.v2_17_1m1720702281.14.0.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/deps/prop-types@15.v2_17_1m1720702281.8.1.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/dcc/dash_core_components.v2_14_1m1720702281.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/dcc/dash_core_components-shared.v2_14_1m1720702281.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/html/dash_html_components.v2_0_18m1720702281.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:25] "GET /_dash-component-suites/dash/dash_table/bundle.v5_2_11m1720702281.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-layout HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-dependencies HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-component-suites/dash/dcc/async-upload.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-component-suites/dash/dcc/async-dropdown.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-component-suites/dash/dcc/async-graph.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-component-suites/dash/dcc/async-slider.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "GET /_dash-component-suites/plotly/package_data/plotly.min.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "POST /_dash-update-component HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:26] "POST /_dash-update-component HTTP/1.1" 200 -
127.0.0.1 - - [11/Jul/2024 14:51:32] "POST /_dash-update-component HTTP/1.1" 200 -
[2024-07-11 14:51:32,626] ERROR in app: Exception on /_dash-update-component [POST]
Traceback (most recent call last):
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/flask/app.py", line 1473, in wsgi_app
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/flask/app.py", line 882, in full_dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/flask/app.py", line 0, in handle_user_exception
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/flask/app.py", line 880, in full_dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/flask/app.py", line 865, in dispatch_request
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/dash/dash.py", line 1373, in dispatch
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/dash/_callback.py", line 465, in add_context
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/dash/_callback.py", line 40, in _invoke_callback
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/ecgviewer/server.py", line 220, in update_graph
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/plotly/graph_objs/layout/_yaxis.py", line 3963, in __init__
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/plotly/basedatatypes.py", line 4862, in __setitem__
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/plotly/basedatatypes.py", line 4344, in _get_validator
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/plotly/validator_cache.py", line 28, in get_validator
  File "/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/_plotly_utils/importers.py", line 36, in __getattr__
  File "importlib.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plotly.validators.layout.yaxis._automargin'
127.0.0.1 - - [11/Jul/2024 14:51:32] "POST /_dash-update-component HTTP/1.1" 500 -
/private/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/onefile_87222_1720702281_173994/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 4 leaked semaphore objects to clean up at shutdown