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)
