diff --git a/plotly/offline/__init__.py b/plotly/offline/__init__.py index f4a5fc2d2b6..085e8c7e7c4 100644 --- a/plotly/offline/__init__.py +++ b/plotly/offline/__init__.py @@ -10,5 +10,6 @@ iplot, iplot_mpl, plot, - plot_mpl + plot_mpl, + serve_plotlyjs_from_directory ) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 5a8634b3285..4551e03e82b 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -6,6 +6,7 @@ from __future__ import absolute_import import os +import shutil import uuid import warnings from pkg_resources import resource_string @@ -23,6 +24,7 @@ matplotlib = optional_imports.get_module('matplotlib') __PLOTLY_OFFLINE_INITIALIZED = False +__SERVE_PLOTLYJS_FROM_DIRECTORY = False __IMAGE_FORMATS = ['jpeg', 'png', 'webp', 'svg'] @@ -37,8 +39,12 @@ def download_plotlyjs(download_url): def get_plotlyjs(): - path = os.path.join('package_data', 'plotly.min.js') - plotlyjs = resource_string('plotly', path).decode('utf-8') + global __SERVE_PLOTLYJS_FROM_DIRECTORY + if __SERVE_PLOTLYJS_FROM_DIRECTORY: + plotlyjs = '