aboutsummaryrefslogtreecommitdiff
path: root/src/device_trezor/trezor/tools/pb2cpp.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/device_trezor/trezor/tools/pb2cpp.py')
-rw-r--r--src/device_trezor/trezor/tools/pb2cpp.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/device_trezor/trezor/tools/pb2cpp.py b/src/device_trezor/trezor/tools/pb2cpp.py
index 4d7cc775f..3e0318ea5 100644
--- a/src/device_trezor/trezor/tools/pb2cpp.py
+++ b/src/device_trezor/trezor/tools/pb2cpp.py
@@ -14,12 +14,18 @@ import hashlib
try:
from tempfile import TemporaryDirectory
except:
- # Py2 backward compatibility, optionally installed by user
- # pip install backports.tempfile
+ # Py2 backward compatibility, using bundled sources.
+ # Original source: pip install backports.tempfile
try:
- from backports.tempfile import TemporaryDirectory
+ # Try bundled python version
+ import sys
+ sys.path.append(os.path.dirname(__file__))
+ from py2backports.tempfile import TemporaryDirectory
+
except:
- raise EnvironmentError('TemporaryDirectory could not be imported. Try: pip install backports.tempfile')
+ raise EnvironmentError('Python 2.7+ or 3.4+ is required. '
+ 'TemporaryDirectory is not available in Python 2.'
+ 'Try to specify python to use, e.g.: "export TREZOR_PYTHON=`which python3`"')
AUTO_HEADER = "# Automatically generated by pb2cpp\n"