From b8773178a19a0dbd1b154acb5903d33ab73bae8e Mon Sep 17 00:00:00 2001 From: thomasv Date: Thu, 10 May 2012 14:38:49 +0200 Subject: [PATCH] setup package in lib subdirectory --- MANIFEST.in | 1 + README | 21 +++++++++++++-------- blocks | 4 ++-- electrum | 10 +++++----- lib/__init__.py | 3 +++ bmp.py => lib/bmp.py | 0 gui.py => lib/gui.py | 6 +++--- gui_qt.py => lib/gui_qt.py | 8 ++++---- interface.py => lib/interface.py | 0 mnemonic.py => lib/mnemonic.py | 0 msqr.py => lib/msqr.py | 0 pyqrnative.py => lib/pyqrnative.py | 0 ripemd.py => lib/ripemd.py | 0 version.py => lib/version.py | 2 +- wallet.py => lib/wallet.py | 0 peers | 4 ++-- setup.py | 7 +++++-- watch_address | 6 ++++-- 18 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 lib/__init__.py rename bmp.py => lib/bmp.py (100%) rename gui.py => lib/gui.py (99%) rename gui_qt.py => lib/gui_qt.py (99%) rename interface.py => lib/interface.py (100%) rename mnemonic.py => lib/mnemonic.py (100%) rename msqr.py => lib/msqr.py (100%) rename pyqrnative.py => lib/pyqrnative.py (100%) rename ripemd.py => lib/ripemd.py (100%) rename version.py => lib/version.py (72%) rename wallet.py => lib/wallet.py (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 6962801c..5ff6c0be 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,7 @@ include README LICENCE RELEASE-NOTES include *.py include electrum exclude setup.py +recursive-include lib *.py recursive-include ecdsa *.py recursive-include aes *.py include icons.qrc diff --git a/README b/README index a90857e8..a1567d24 100644 --- a/README +++ b/README @@ -30,17 +30,22 @@ In order to use the gtk gui, you need pygtk and tk. * apt-get install python-tk +To install Electrum, type: + + sudo python setup.py install + + RUN -To start the Qt gui, type: - python electrum -To use the Gtk gui, type: - python electrum --gui gtk +To start Electrum in GUI mode, type: -If arguments are passed to the command line, Electrum will run in text mode. -Examples: - python electrum balance - python electrum help + electrum + + +If arguments are passed to the command line, Electrum will run in text mode: + + electrum balance + electrum help diff --git a/blocks b/blocks index baf45488..cf03340b 100755 --- a/blocks +++ b/blocks @@ -1,8 +1,8 @@ #!/usr/bin/env python -import interface +from electrum import TcpStratumInterface -i = interface.TcpStratumInterface('ecdsa.org', 50001) +i = TcpStratumInterface('ecdsa.org', 50001) i.start() i.send([('blockchain.numblocks.subscribe',[])]) diff --git a/electrum b/electrum index e7f378d6..cd937559 100755 --- a/electrum +++ b/electrum @@ -18,11 +18,11 @@ import re, sys, getpass +import electrum from optparse import OptionParser -from wallet import Wallet, SecretToASecret -from interface import WalletSynchronizer from decimal import Decimal -from wallet import format_satoshis + +from electrum import Wallet, SecretToASecret, WalletSynchronizer, format_satoshis known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'restore', 'payto', 'sendtx', 'password', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval'] offline_commands = ['password', 'mktx', 'history', 'label', 'contacts', 'help', 'validateaddress', 'signmessage', 'verifymessage', 'eval', 'create', 'addresses', 'import', 'seed'] @@ -60,9 +60,9 @@ if __name__ == '__main__': if cmd == 'gui': if options.gui=='gtk': - import gui + import electrum.gui as gui elif options.gui=='qt': - import gui_qt as gui + import electrum.gui_qt as gui else: print "unknown gui", options.gui exit(1) diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 00000000..1f76a2e1 --- /dev/null +++ b/lib/__init__.py @@ -0,0 +1,3 @@ +from wallet import Wallet, SecretToASecret, format_satoshis +from interface import WalletSynchronizer +from interface import TcpStratumInterface diff --git a/bmp.py b/lib/bmp.py similarity index 100% rename from bmp.py rename to lib/bmp.py diff --git a/gui.py b/lib/gui.py similarity index 99% rename from gui.py rename to lib/gui.py index 3b7928fb..bbd61b28 100644 --- a/gui.py +++ b/lib/gui.py @@ -22,7 +22,7 @@ import socket, traceback import pygtk pygtk.require('2.0') import gtk, gobject -import pyqrnative +from electrum import pyqrnative from decimal import Decimal gtk.gdk.threads_init() @@ -59,7 +59,7 @@ def numbify(entry, is_int = False): def show_seed_dialog(wallet, password, parent): - import mnemonic + from electrum import mnemonic try: seed = wallet.pw_decode( wallet.seed, password) except: @@ -203,7 +203,7 @@ def run_recovery_dialog(wallet): try: seed.decode('hex') except: - import mnemonic + from electrum import mnemonic print "not hex, trying decode" seed = mnemonic.mn_decode( seed.split(' ') ) if not seed: diff --git a/gui_qt.py b/lib/gui_qt.py similarity index 99% rename from gui_qt.py rename to lib/gui_qt.py index 818c6025..cd5ccd79 100644 --- a/gui_qt.py +++ b/lib/gui_qt.py @@ -101,7 +101,7 @@ class QRCodeWidget(QWidget): self.set_addr(addr) def set_addr(self, addr): - import pyqrnative + from electrum import pyqrnative self.addr = addr self.qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.L) self.qr.addData(addr) @@ -688,7 +688,7 @@ class ElectrumWindow(QMainWindow): @staticmethod def show_seed_dialog(wallet, parent=None): - import mnemonic + from electrum import mnemonic if wallet.use_encryption: password = parent.password_dialog() if not password: return @@ -796,7 +796,7 @@ class ElectrumWindow(QMainWindow): qrw.repaint() def do_save(): - import bmp + from electrum import bmp bmp.save_qrcode(qrw.qr, "qrcode.bmp") self.show_message("QR code saved to file 'qrcode.bmp'") @@ -936,7 +936,7 @@ class ElectrumWindow(QMainWindow): seed = unicode(seed_e.text()) seed.decode('hex') except: - import mnemonic + from electrum import mnemonic print "not hex, trying decode" try: seed = mnemonic.mn_decode( seed.split(' ') ) diff --git a/interface.py b/lib/interface.py similarity index 100% rename from interface.py rename to lib/interface.py diff --git a/mnemonic.py b/lib/mnemonic.py similarity index 100% rename from mnemonic.py rename to lib/mnemonic.py diff --git a/msqr.py b/lib/msqr.py similarity index 100% rename from msqr.py rename to lib/msqr.py diff --git a/pyqrnative.py b/lib/pyqrnative.py similarity index 100% rename from pyqrnative.py rename to lib/pyqrnative.py diff --git a/ripemd.py b/lib/ripemd.py similarity index 100% rename from ripemd.py rename to lib/ripemd.py diff --git a/version.py b/lib/version.py similarity index 72% rename from version.py rename to lib/version.py index e922409b..155eb334 100644 --- a/version.py +++ b/lib/version.py @@ -1,2 +1,2 @@ -ELECTRUM_VERSION = "0.47b" +ELECTRUM_VERSION = "0.48" SEED_VERSION = 4 # bump this everytime the seed generation is modified diff --git a/wallet.py b/lib/wallet.py similarity index 100% rename from wallet.py rename to lib/wallet.py diff --git a/peers b/peers index 0b5d1e08..d7bdcd33 100755 --- a/peers +++ b/peers @@ -1,8 +1,8 @@ #!/usr/bin/env python -import interface +from electrum import TcpStratumInterface -i = interface.TcpStratumInterface('ecdsa.org', 50001) +i = TcpStratumInterface('ecdsa.org', 50001) i.start() i.send([('server.peers.subscribe',[])]) diff --git a/setup.py b/setup.py index f3049fd2..0b9f66a2 100644 --- a/setup.py +++ b/setup.py @@ -3,15 +3,18 @@ # python setup.py sdist --format=zip,gztar from distutils.core import setup -from version import ELECTRUM_VERSION as version +from lib.version import ELECTRUM_VERSION as version setup(name = "Electrum", version = version, + package_dir = {'electrum': 'lib'}, + scripts= ['electrum', 'watch_address', 'blocks'], + py_modules = ['electrum.version','electrum.wallet','electrum.interface','electrum.gui','electrum.gui_qt','electrum.icons_rc','electrum.mnemonic','electrum.pyqrnative','electrum.bmp'], description = "Lightweight Bitcoin Wallet", author = "thomasv", license = "GNU GPLv3", url = "http://ecdsa/electrum", long_description = """Lightweight Bitcoin Wallet""" -) +) diff --git a/watch_address b/watch_address index 162c5a6d..41d2051c 100755 --- a/watch_address +++ b/watch_address @@ -1,12 +1,14 @@ #!/usr/bin/env python -import interface, sys +import sys +from electrum import TcpStratumInterface + try: addr = sys.argv[1] except: print "usage: watch_address " -i = interface.TcpStratumInterface('ecdsa.org', 50001) +i = TcpStratumInterface('ecdsa.org', 50001) i.start() i.send([('blockchain.address.subscribe',[addr])])