Description: Replace static files path for debian specific data path and remove generation
 of JS files.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2023-07-02
Forwarded: not-needed


--- a/plotly/io/_orca.py
+++ b/plotly/io/_orca.py
@@ -128,15 +128,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/setup.py
+++ b/setup.py
@@ -240,7 +240,7 @@
 
     req = requests.get(url)
     assert req.status_code == 200
-    path = os.path.join(here, "plotly", "package_data", "plotly.min.js")
+    path = os.path.join(here, "plotly", "package_data", "plotly.js")
     with open(path, "wb") as f:
         f.write(req.content)
 
@@ -539,35 +539,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", "packaging"],
     zip_safe=False,
-    cmdclass=dict(
-        build_py=js_prerelease(versioneer_cmds["build_py"]),
-        egg_info=js_prerelease(egg_info),
-        sdist=js_prerelease(versioneer_cmds["sdist"], strict=True),
-        jsdeps=NPM,
-        codegen=CodegenCommand,
-        updateschema=UpdateSchemaCommand,
-        updatebundle=UpdateBundleCommand,
-        updateplotlyjs=js_prerelease(UpdatePlotlyJsCommand),
-        updatebundleschemadev=UpdateBundleSchemaDevCommand,
-        updateplotlyjsdev=UpdatePlotlyJsDevCommand,
-        updateplotlywidgetversion=UpdatePlotlywidgetVersionCommand,
-        version=versioneer_cmds["version"],
-    ),
 )
--- a/plotly/data/__init__.py
+++ b/plotly/data/__init__.py
@@ -215,7 +215,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
@@ -80,10 +80,14 @@
                 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/plotly/offline/offline.py
+++ b/plotly/offline/offline.py
@@ -81,9 +81,13 @@
     >>> with open('multi_plot.html', 'w') as f:
     ...      f.write(html) # doctest: +SKIP
     """
-    path = os.path.join("package_data", "plotly.min.js")
-    plotlyjs = pkgutil.get_data("plotly", path).decode("utf-8")
-    return plotlyjs
+    def get_debian_plotlyjs():
+        debian_path = '/usr/share/python3-plotly/plotly.js'
+        plotly_js_data = None
+        with open(debian_path, 'r') as file_:
+            plotly_js_data = file_.read()
+        return plotly_js_data.encode('utf-8').decode('utf-8')
+    return get_debian_plotlyjs()
 
 
 def _build_resize_script(plotdivid, plotly_root="Plotly"):
