electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 16c72d286c119562a591dc06303dfeefa3ccfa01
parent d14c03b47f5da7190fd34073a136f4fa586847e2
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 26 Jan 2015 14:14:16 +0100

try to import all python dependencies from the main script

Diffstat:
Melectrum | 29+++++++++++++++++++++++++++++
Mlib/bitcoin.py | 18+++---------------
Mlib/paymentrequest.py | 8+-------
Mlib/x509.py | 18+++---------------
4 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/electrum b/electrum @@ -36,6 +36,35 @@ if is_local: import __builtin__ __builtin__.use_local_modules = is_local or is_android +# pure-python dependencies need to be imported here for pyinstaller +try: + import aes + import ecdsa + import socks + import requests + import six + import qrcode + import pyasn1 + import pyasn1_modules + import tlslite + import pbkdf2 +except ImportError as e: + sys.exit("Error: %s. Try 'sudo pip install <module-name>'"%e.message) + +# these imports must be redeclared for pyinstaller +import pyasn1.codec +import pyasn1.codec.der +from pyasn1.codec.der import encoder, decoder +from pyasn1_modules import rfc2459 + +# test that we have the correct version of ecdsa +try: + from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1 +except Exception: + print "cannot import ecdsa.curve_secp256k1. You probably need to upgrade ecdsa.\nTry: sudo pip install --upgrade ecdsa" + exit() + + # load local module as electrum if __builtin__.use_local_modules: import imp diff --git a/lib/bitcoin.py b/lib/bitcoin.py @@ -26,15 +26,8 @@ import hmac import version from util import print_error, InvalidPassword -try: - import ecdsa -except ImportError: - sys.exit("Error: python-ecdsa does not seem to be installed. Try 'sudo pip install ecdsa'") - -try: - import aes -except ImportError: - sys.exit("Error: AES does not seem to be installed. Try 'sudo pip install slowaes'") +import ecdsa +import aes ################################## transactions @@ -401,12 +394,7 @@ def is_private_key(key): ########### end pywallet functions ####################### -try: - from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1 -except Exception: - print "cannot import ecdsa.curve_secp256k1. You probably need to upgrade ecdsa.\nTry: sudo pip install --upgrade ecdsa" - exit() - +from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1 from ecdsa.curves import SECP256k1 from ecdsa.ellipticcurve import Point from ecdsa.util import string_to_number, number_to_string diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py @@ -27,19 +27,13 @@ import time import traceback import urllib2 import urlparse - +import requests try: import paymentrequest_pb2 except: sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto'") -try: - import requests -except ImportError: - sys.exit("Error: requests does not seem to be installed. Try 'sudo pip install requests'") - - import bitcoin import util import transaction diff --git a/lib/x509.py b/lib/x509.py @@ -20,21 +20,9 @@ from datetime import datetime import sys -try: - import pyasn1 -except ImportError: - sys.exit("Error: pyasn1 does not seem to be installed. Try 'sudo pip install pyasn1'") - -try: - import pyasn1_modules -except ImportError: - sys.exit("Error: pyasn1 does not seem to be installed. Try 'sudo pip install pyasn1-modules'") - -try: - import tlslite -except ImportError: - sys.exit("Error: tlslite does not seem to be installed. Try 'sudo pip install tlslite'") - +import pyasn1 +import pyasn1_modules +import tlslite # workaround https://github.com/trevp/tlslite/issues/15 tlslite.utils.cryptomath.pycryptoLoaded = False