1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
Description: Replace static files path for debian specific data path.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2018-11-25
--- a/setup.py
+++ b/setup.py
@@ -274,7 +274,5 @@
'plotly/matplotlylib/mplexporter',
'plotly/matplotlylib/mplexporter/renderers',
'_plotly_utils'] + graph_objs_packages + validator_packages,
- package_data={'plotly': ['package_data/*', 'package_data/templates/*'],
- 'plotlywidget': ['static/*']},
zip_safe=False,
)
--- a/plotly/io/_orca.py
+++ b/plotly/io/_orca.py
@@ -217,19 +217,24 @@
restored in future sessions.
"""
def __init__(self):
+ def get_debian_path():
+ py_version = sys.version_info[0]
+ if py_version < 3:
+ py_version = ''
+ debian_path = '/usr/share/python{}-plotly/'.format(py_version)
+ return debian_path
# Initialize properties dict
self._props = {}
# Compute absolute path to the 'plotly/package_data/' directory
- root_dir = os.path.dirname(os.path.abspath(plotly.__file__))
- self.package_dir = os.path.join(root_dir, 'package_data')
+ self.package_dir = get_debian_path()
# Load pre-existing configuration
self.reload(warn=False)
# Compute constants
- plotlyjs = os.path.join(self.package_dir, 'plotly.min.js')
+ plotlyjs = os.path.join(self.package_dir, 'plotly.js')
self._constants = {
'plotlyjs': plotlyjs,
'config_file': os.path.join(PLOTLY_DIR, ".orca")
--- a/plotly/graph_reference.py
+++ b/plotly/graph_reference.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import
import os
+import sys
import re
import pkgutil
@@ -68,7 +69,13 @@
:return: (dict) The graph reference.
"""
- path = os.path.join('package_data', 'plot-schema.json')
+
+ py_version = sys.version_info[0]
+ if py_version < 3 :
+ py_version = ''
+ debian_path = '/usr/share/python{}-plotly'.format(py_version)
+
+ path = os.path.join(debian_path, 'plot-schema.json')
s = pkgutil.get_data('plotly', path).decode('utf-8')
graph_reference = utils.decode_unicode(_json.loads(s))
--- a/plotly/io/_templates.py
+++ b/plotly/io/_templates.py
@@ -12,6 +12,7 @@
import copy
import os
+import sys
import json
from functools import reduce
@@ -63,7 +64,11 @@
template = self._templates[item]
if template is Lazy:
# Load template from package data
- path = os.path.join('package_data', 'templates', item + '.json')
+ py_version = sys.version_info[0]
+ if py_version < 3:
+ py_version = ''
+ debian_path = '/usr/share/python{}-plotly'.format(py_version)
+ path = os.path.join(debian_path, 'templates', item + '.json')
template_str = pkgutil.get_data('plotly', path).decode('utf-8')
template_dict = json.loads(template_str)
template = Template(template_dict)
--- a/plotly/widgets/graph_widget.py
+++ b/plotly/widgets/graph_widget.py
@@ -5,6 +5,7 @@
import uuid
from collections import deque
import pkgutil
+import sys
from requests.compat import json as _json
@@ -20,8 +21,12 @@
# Load JS widget code
# No officially recommended way to do this in any other way
# http://mail.scipy.org/pipermail/ipython-dev/2014-April/013835.html
+
+py_version = sys.version_info[0]
+if py_version < 3:
+ py_version = ''
js_widget_code = pkgutil.get_data('plotly',
- 'package_data/graphWidget.js'
+ '/usr/share/python{}-plotly/graphWidget.js'.format(py_version)
).decode('utf-8')
display(Javascript(js_widget_code))
--- a/plotly/figure_factory/_county_choropleth.py
+++ b/plotly/figure_factory/_county_choropleth.py
@@ -4,6 +4,7 @@
from plotly.figure_factory import utils
import io
+import sys
import numpy as np
import os
import pandas as pd
@@ -19,6 +20,13 @@
gp = optional_imports.get_module('geopandas')
+def get_debian_path():
+ py_version = sys.version_info[0]
+ if py_version < 3:
+ py_version = ''
+ path = '/usr/share/python{}-plotly'.format(py_version)
+ return path
+
def _create_us_counties_df(st_to_state_name_dict, state_to_st_dict):
# URLS
abs_file_path = os.path.realpath(__file__)
@@ -26,8 +34,7 @@
abs_plotly_dir_path = os.path.dirname(abs_dir_path)
- abs_package_data_dir_path = os.path.join(abs_plotly_dir_path,
- 'package_data')
+ abs_package_data_dir_path = get_debian_path()
shape_pre2010 = 'gz_2010_us_050_00_500k.shp'
shape_pre2010 = os.path.join(abs_package_data_dir_path, shape_pre2010)
|