Skip to content

Commit 072b89c

Browse files
committed
Update plotly.js to explicitly defined version by downloading from plotly.js github using a setup.py command
1 parent f5a5d5a commit 072b89c

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

makefile

+2-8
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,8 @@ pull_chunked : submodules/chunked_requests
5656
cd submodules/chunked_requests; git pull origin master
5757

5858
update_plotlyjs_for_offline :
59-
@echo "Updating plotly.js for Offline Mode"
59+
@echo "Updating plotly.js"
6060
@echo "------------------"
61-
python -c "import urllib2;\
62-
cdn_url = 'https://cdn.plot.ly/plotly-latest.min.js';\
63-
response = urllib2.urlopen(cdn_url);\
64-
html = response.read();\
65-
f = open('./plotly/package_data/plotly.min.js', 'w');\
66-
f.write(html);\
67-
f.close()"
61+
python setup.py updateplotlyjs
6862
@echo "---------------------------------"
6963
@echo "Remember to update the CHANGELOG!"

setup.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,29 @@ def run(self):
167167
f.write(response.read())
168168

169169

170+
class DownloadPlotlyJsCommand(Command):
171+
description = 'Download latest version of the plot-schema JSON file'
172+
user_options = []
173+
174+
def initialize_options(self):
175+
pass
176+
177+
def finalize_options(self):
178+
pass
179+
180+
def run(self):
181+
if sys.version_info.major != 3:
182+
raise ImportError('Schema download must be executed with Python 3')
183+
184+
import urllib.request
185+
url = ('https://raw.githubusercontent.com/plotly/plotly.js/'
186+
'v%s/dist/plotly.min.js' % plotly_js_version)
187+
with urllib.request.urlopen(url) as response:
188+
189+
with open('plotly/package_data/plotly.min.js', 'wb') as f:
190+
f.write(response.read())
191+
192+
170193
setup(name='plotly',
171194
version=__version__,
172195
use_2to3=False,
@@ -938,6 +961,7 @@ def run(self):
938961
'sdist': js_prerelease(sdist, strict=True),
939962
'jsdeps': NPM,
940963
'codegen': CodegenCommand,
941-
'updateschema': DownloadSchemaCommand
964+
'updateschema': DownloadSchemaCommand,
965+
'updateplotlyjs': DownloadPlotlyJsCommand
942966
},
943967
)

0 commit comments

Comments
 (0)