Package: plotly / 5.4.1+dfsg-1

00-fix-static-files-installation.patch Patch series | download
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
Description: Replace static files path for debian specific data path.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2020-05-17
Forwarded: not-needed

--- a/plotly/io/_orca.py
+++ b/plotly/io/_orca.py
@@ -223,15 +223,14 @@
         # 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")
+        # Compute absolute path to the '/usr/share/python3-plotly/' directory
+        self.package_dir = '/usr/share/python3-plotly'
 
         # 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/data/__init__.py
+++ b/plotly/data/__init__.py
@@ -214,8 +214,7 @@
 
     return pandas.read_csv(
         os.path.join(
-            os.path.dirname(os.path.dirname(__file__)),
-            "package_data",
+            "/usr/share/python3-plotly",
             "datasets",
             d + ".csv.gz",
         )
--- a/plotly/io/_templates.py
+++ b/plotly/io/_templates.py
@@ -84,10 +84,13 @@
                 else:
                     # Load template from package data
                     path = os.path.join(
-                        "package_data", "templates", template_name + ".json"
+                        "/usr/share/python3-plotly", "templates", f'{template_name}.json'
                     )
-                    template_str = pkgutil.get_data("plotly", path).decode("utf-8")
-                    template_dict = json.loads(template_str)
+                    template_str = ''
+                    with open(path, 'r') as f:
+                        template_str = f.read()
+                    template_dict = json.loads(template_str.encode('utf-8').decode('utf-8'))
+
                     template = Template(template_dict, _validate=False)
 
                     self._templates[template_name] = template
--- a/setup.py
+++ b/setup.py
@@ -536,18 +536,6 @@
     ]
     + graph_objs_packages
     + validator_packages,
-    package_data={
-        "plotly": [
-            "package_data/*",
-            "package_data/templates/*",
-            "package_data/datasets/*",
-        ],
-        "jupyterlab_plotly": [
-            "nbextension/*",
-            "labextension/*",
-            "labextension/static/*",
-        ],
-    },
     data_files=[("etc/jupyter/nbconfig/notebook.d", ["jupyterlab-plotly.json"]),],
     install_requires=["tenacity>=6.2.0", "six"],
     zip_safe=False,