plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

plotly/package_data/widgetbundle.js has not been included in the release

Open nextdorf opened this issue 9 months ago • 5 comments

For some reason plotly/package_data/widgetbundle.js is not being generated. I guess something goes wrong in the build script in js/package.json. Without the presence of that file, the global variable BaseFigureWidget._esm holds an invalid path, which leads to a somewhat surprising bug when using FigureWidget:

During import the function __getattr__ in graph_objects/__init__.py is being called and __init_subclass__ of AnyWidget is being invoked. Due to the missing file a FileNotFoundError is being raised (File not found: /usr/lib/python3.13/site-packages/plotly/package_data/widgetbundle.js).

inside __getattr__ there is a try block containing the import. I assume the intended usage of the try block is to catch any ImportErrors, since the except block will import a dummy-FigureWidget from missing_anywidget which just generates an error about a missing dependency.

However, the except block catches any exception, including the FileNotFoundError. This results in the user getting a misleading error message about a missing dependency (regardless whether that dependency is present or not). The actual fix would be to have the file plotly/package_data/widgetbundle.js present in the library.

nextdorf avatar Mar 26 '25 09:03 nextdorf

thanks for tracking this down @nextdorf - @emilykl @marthacryan , was this broken during the recent repository reorganization?

gvwilson avatar Mar 31 '25 14:03 gvwilson

Hi! Is this something you're seeing when you build the repo locally? Or is it in a release? If so, which release? I just downloaded the tarball of the most recent release (6.0.1) and I am seeing the file you're talking about. If you're building this locally, you'll need to run npm i && npm run build from the js directory. (See https://github.com/plotly/plotly.py/blob/main/CONTRIBUTING.md#editable-install-of-plotly-packages for more details).

marthacryan avatar Mar 31 '25 18:03 marthacryan

I installed it from the arch repositories (extra/python-plotly). They build and package it via the script here.

They build it with python -m build --wheel --no-isolation --skip-dependency-check and without npm.

I guess it's considered a down-stream issue on arch's side then?

nextdorf avatar Mar 31 '25 19:03 nextdorf

Oh ok huh. Maybe we could start committing the built JS to the package_data since we already commit files there? @emilykl @gvwilson any opinions on that?

marthacryan avatar Mar 31 '25 22:03 marthacryan

Since the package uses setuptools as its build-backend, it should be possible as well to simply adding a custom build step which runs npm i && npm run build.

nextdorf avatar Apr 01 '25 13:04 nextdorf