GeezerVison is showing github.com — Fix accidental creation of `js/` directory under `site-packages/` when installing Plotly by emilykl · Pull Request #5586 · plotly/plotly.py
Conversation
emilykl
commented
Apr 30, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Link to issue
Closes #5584
Description of change
Fixes issue since Plotly 6.7.0, introduced by #5540, where pip install plotly would unintentionally create a js/ directory under site-packages/, interfering with any other package which might use the js/ name.
Demo
N/A
Testing strategy
To reproduce the issue:
- Create a fresh Python virtual environment
- Run
pip install plotly==6.7.0 (or uv pip install ...)
- Notice that the following directory exists:
$VENV_ROOT/lib/pythonX.Y/site-packages/js
To verify that this PR fixes the issue:
- Check out this branch
- Run
python -m build from the root folder, and make sure it runs without error
- Verify that new
dist/plotly-6.7.0.tar.gz and dist/plotly-6.7.0-py3-none-any.whl files are created
- Create a fresh Python virtual environment
- Run
pip install dist/plotly-6.7.0-py3-none-any.whl
- Verify that
$VENV_ROOT/lib/pythonX.Y/site-packages/js DOES NOT exist
- Verify that
$VENV_ROOT/share/jupyter/labextensions/jupyterlab-plotly/install.json DOES exist
- To test installing the tar file, repeat steps 4-7 replacing the
.whl file path with the .tar.gz file path
Guidelines
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Three changes to the hot path hit by every fig.show(), write_html(),
to_json(), and write_image() call:
1. to_typed_array_spec: replace copy_to_readonly_numpy_array (which
copies the array, wraps through narwhals, and sets readonly flag)
with a lightweight np.asarray — the input is already a deepcopy
from to_dict(), so copying again is pure waste.
2. convert_to_base64: replace is_homogeneous_array (which checks
numpy, pandas, narwhals, and __array_interface__) with a direct
isinstance(value, np.ndarray) check. In the to_dict() context,
data is already validated and stored as numpy arrays.
3. is_skipped_key: replace list scan with frozenset lookup (O(1)).
Profile results (10 traces × 100K points, 20 calls):
to_typed_array_spec: 1811ms → 1097ms (40% faster)
copy_to_readonly_numpy_array: 226ms → 0ms (eliminated)
narwhals from_native: 68ms → 0ms (eliminated)
is_skipped_key: 41ms → ~0ms (eliminated)
In convert_to_base64, when iterating list/tuple elements, only recurse
into dicts, lists, and tuples. Strings and numbers can never contain
numpy arrays, so recursing into them wastes ~500K function calls on
figures with large text arrays.
|
Whoops, there are unrelated commits on this branch. Closing in favor of #5587.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|