Skip to content

Commit 583303a

Browse files
authored
Replace pkg_resources.resource_string with pkgutil.get_data (#1201)
for improved compatibility with cx_Freeze
1 parent 92b6cee commit 583303a

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Diff for: plotly/graph_reference.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import os
88
import re
9-
from pkg_resources import resource_string
9+
import pkgutil
1010

1111
import six
1212
from requests.compat import json as _json
@@ -69,7 +69,7 @@ def get_graph_reference():
6969
7070
"""
7171
path = os.path.join('package_data', 'plot-schema.json')
72-
s = resource_string('plotly', path).decode('utf-8')
72+
s = pkgutil.get_data('plotly', path).decode('utf-8')
7373
graph_reference = utils.decode_unicode(_json.loads(s))
7474

7575
# TODO: Patch in frames info until it hits streambed. See #659

Diff for: plotly/offline/offline.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import uuid
1010
import warnings
11-
from pkg_resources import resource_string
11+
import pkgutil
1212
import time
1313
import webbrowser
1414

@@ -38,7 +38,7 @@ def download_plotlyjs(download_url):
3838

3939
def get_plotlyjs():
4040
path = os.path.join('package_data', 'plotly.min.js')
41-
plotlyjs = resource_string('plotly', path).decode('utf-8')
41+
plotlyjs = pkgutil.get_data('plotly', path).decode('utf-8')
4242
return plotlyjs
4343

4444
def get_image_download_script(caller):

Diff for: plotly/tests/test_core/test_graph_reference/test_graph_reference.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from __future__ import absolute_import
66

77
import os
8-
from pkg_resources import resource_string
98
from unittest import TestCase
109

1110
from nose.plugins.attrib import attr

Diff for: plotly/widgets/graph_widget.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55
import uuid
66
from collections import deque
7-
from pkg_resources import resource_string
7+
import pkgutil
88

99
from requests.compat import json as _json
1010

@@ -20,8 +20,9 @@
2020
# Load JS widget code
2121
# No officially recommended way to do this in any other way
2222
# http://mail.scipy.org/pipermail/ipython-dev/2014-April/013835.html
23-
js_widget_code = resource_string('plotly',
24-
'package_data/graphWidget.js').decode('utf-8')
23+
js_widget_code = pkgutil.get_data('plotly',
24+
'package_data/graphWidget.js'
25+
).decode('utf-8')
2526

2627
display(Javascript(js_widget_code))
2728

0 commit comments

Comments
 (0)