Skip to content

Commit c4e71aa

Browse files
committed
Use pathlib2 for ancient Python versions
1 parent b21bb4b commit c4e71aa

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/python/plotly/plotly/io/_kaleido.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
from __future__ import absolute_import
22
from six import string_types
33
import os
4-
from pathlib import Path, PurePath
4+
5+
56
import json
67
import plotly
78
from plotly.io._utils import validate_coerce_fig_to_dict
89

10+
try:
11+
from pathlib import Path, PurePath
12+
except ImportError:
13+
# For Python < 3.4 use pathlib2
14+
from pathlib2 import Path, PurePath
15+
916
try:
1017
from kaleido.scopes.plotly import PlotlyScope
1118

packages/python/plotly/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ six==1.8.0
1010

1111
## retrying requests ##
1212
retrying==1.3.3
13+
14+
## Allow pathlib2 as pathlib substitute for old Python versions ##
15+
pathlib2;python_version<"3.4"

packages/python/plotly/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def run(self):
505505
),
506506
("etc/jupyter/nbconfig/notebook.d", ["plotlywidget.json"]),
507507
],
508-
install_requires=["retrying>=1.3.3", "six"],
508+
install_requires=["retrying>=1.3.3", "six", 'pathlib2;python_version<"3.4"'],
509509
zip_safe=False,
510510
cmdclass=dict(
511511
build_py=js_prerelease(versioneer_cmds["build_py"]),

0 commit comments

Comments
 (0)