commit b5ac7f2a7c5b674613e5ee9b6164cece1511db07
parent 619ee02df80d1a695079559375f2886a905c8539
Author: ThomasV <thomasv@gitorious>
Date: Wed, 18 Feb 2015 17:13:41 +0100
simplify setup.py using package_data
Diffstat:
16 files changed, 22 insertions(+), 109 deletions(-)
diff --git a/gui/qt/lite_window.py b/gui/qt/lite_window.py
@@ -76,7 +76,8 @@ def theme_dirs_from_prefix(prefix):
def load_theme_paths():
theme_paths = {}
- theme_paths.update(theme_dirs_from_prefix(util.data_dir()))
+ theme_dir = os.path.join(os.path.dirname(__file__), 'themes')
+ theme_paths.update(theme_dirs_from_prefix(theme_dir))
return theme_paths
diff --git a/data/README b/gui/qt/themes/README
diff --git a/data/cleanlook/name.cfg b/gui/qt/themes/cleanlook/name.cfg
diff --git a/data/cleanlook/style.css b/gui/qt/themes/cleanlook/style.css
diff --git a/data/dark/name.cfg b/gui/qt/themes/dark/name.cfg
diff --git a/data/dark/style.css b/gui/qt/themes/dark/style.css
diff --git a/data/sahara/name.cfg b/gui/qt/themes/sahara/name.cfg
diff --git a/data/sahara/style.css b/gui/qt/themes/sahara/style.css
diff --git a/lib/i18n.py b/lib/i18n.py
@@ -18,11 +18,7 @@
import gettext, os
-if os.path.exists('./locale'):
- LOCALE_DIR = './locale'
-else:
- LOCALE_DIR = '/usr/share/locale'
-
+LOCALE_DIR = os.path.join(os.path.dirname(__file__), 'locale')
language = gettext.translation('electrum', LOCALE_DIR, fallback = True)
diff --git a/mki18n.py b/lib/mki18n.py
diff --git a/lib/mnemonic.py b/lib/mnemonic.py
@@ -26,7 +26,6 @@ import string
import ecdsa
import pbkdf2
-import util
from util import print_error
from bitcoin import is_old_seed, is_new_seed
import version
@@ -104,7 +103,7 @@ class Mnemonic(object):
lang = i18n.language.info().get('language', 'en')
print_error('language', lang)
filename = filenames.get(lang[0:2], 'english.txt')
- path = os.path.join(util.data_dir(), 'wordlist', filename)
+ path = os.path.join(os.path.dirname(__file__), 'wordlist', filename)
s = open(path,'r').read().strip()
s = unicodedata.normalize('NFKD', s.decode('utf8'))
lines = s.split('\n')
diff --git a/data/wordlist/english.txt b/lib/wordlist/english.txt
diff --git a/data/wordlist/japanese.txt b/lib/wordlist/japanese.txt
diff --git a/data/wordlist/portuguese.txt b/lib/wordlist/portuguese.txt
diff --git a/data/wordlist/spanish.txt b/lib/wordlist/spanish.txt
diff --git a/setup.py b/setup.py
@@ -10,56 +10,20 @@ import imp
version = imp.load_source('version', 'lib/version.py')
-util = imp.load_source('util', 'lib/util.py')
if sys.version_info[:3] < (2, 7, 0):
sys.exit("Error: Electrum requires Python version >= 2.7.0...")
-if (len(sys.argv) > 1) and (sys.argv[1] == "install"):
- # or (platform.system() != 'Windows' and platform.system() != 'Darwin'):
- print "Including all files"
- data_files = []
- usr_share = util.usr_share_dir()
- if not os.access(usr_share, os.W_OK):
- try:
- os.mkdir(usr_share)
- except:
- sys.exit("Error: cannot write to %s.\nIf you do not have root permissions, you may install Electrum in a virtualenv.\nAlso, please note that you can run Electrum without installing it on your system."%usr_share)
-
+data_files = []
+if platform.system() == 'Linux':
+ usr_share = os.path.join(sys.prefix, "share")
data_files += [
(os.path.join(usr_share, 'applications/'), ['electrum.desktop']),
(os.path.join(usr_share, 'app-install', 'icons/'), ['icons/electrum.png'])
]
- if not os.path.exists('locale'):
- os.mkdir('locale')
- for lang in os.listdir('locale'):
- if os.path.exists('locale/%s/LC_MESSAGES/electrum.mo' % lang):
- data_files.append((os.path.join(usr_share, 'locale/%s/LC_MESSAGES' % lang), ['locale/%s/LC_MESSAGES/electrum.mo' % lang]))
-
-
- appdata_dir = os.path.join(usr_share, "electrum")
- data_files += [
- (appdata_dir, ["data/README"]),
- (os.path.join(appdata_dir, "cleanlook"), [
- "data/cleanlook/name.cfg",
- "data/cleanlook/style.css"
- ]),
- (os.path.join(appdata_dir, "sahara"), [
- "data/sahara/name.cfg",
- "data/sahara/style.css"
- ]),
- (os.path.join(appdata_dir, "dark"), [
- "data/dark/name.cfg",
- "data/dark/style.css"
- ])
- ]
- for lang in os.listdir('data/wordlist'):
- data_files.append((os.path.join(appdata_dir, 'wordlist'), ['data/wordlist/%s' % lang]))
-else:
- data_files = []
setup(
name="Electrum",
@@ -82,70 +46,23 @@ setup(
'electrum_gui': 'gui',
'electrum_plugins': 'plugins',
},
+ packages=['electrum','electrum_gui','electrum_gui.qt','electrum_plugins'],
+ package_data={
+ 'electrum': [
+ 'wordlist/*.txt',
+ 'locale/*/LC_MESSAGES/electrum.mo',
+ ],
+ 'electrum_gui': [
+ "qt/themes/cleanlook/name.cfg",
+ "qt/themes/cleanlook/style.css",
+ "qt/themes/sahara/name.cfg",
+ "qt/themes/sahara/style.css",
+ "qt/themes/dark/name.cfg",
+ "qt/themes/dark/style.css",
+ ]
+ },
scripts=['electrum'],
data_files=data_files,
- py_modules=[
- 'electrum.account',
- 'electrum.bitcoin',
- 'electrum.blockchain',
- 'electrum.bmp',
- 'electrum.commands',
- 'electrum.daemon',
- 'electrum.i18n',
- 'electrum.interface',
- 'electrum.mnemonic',
- 'electrum.msqr',
- 'electrum.network',
- 'electrum.network_proxy',
- 'electrum.old_mnemonic',
- 'electrum.paymentrequest',
- 'electrum.paymentrequest_pb2',
- 'electrum.plugins',
- 'electrum.qrscanner',
- 'electrum.simple_config',
- 'electrum.synchronizer',
- 'electrum.transaction',
- 'electrum.util',
- 'electrum.verifier',
- 'electrum.version',
- 'electrum.wallet',
- 'electrum.x509',
- 'electrum_gui.gtk',
- 'electrum_gui.qt.__init__',
- 'electrum_gui.qt.amountedit',
- 'electrum_gui.qt.console',
- 'electrum_gui.qt.history_widget',
- 'electrum_gui.qt.icons_rc',
- 'electrum_gui.qt.installwizard',
- 'electrum_gui.qt.lite_window',
- 'electrum_gui.qt.main_window',
- 'electrum_gui.qt.network_dialog',
- 'electrum_gui.qt.password_dialog',
- 'electrum_gui.qt.paytoedit',
- 'electrum_gui.qt.qrcodewidget',
- 'electrum_gui.qt.qrtextedit',
- 'electrum_gui.qt.qrwindow',
- 'electrum_gui.qt.receiving_widget',
- 'electrum_gui.qt.seed_dialog',
- 'electrum_gui.qt.transaction_dialog',
- 'electrum_gui.qt.util',
- 'electrum_gui.qt.version_getter',
- 'electrum_gui.stdio',
- 'electrum_gui.text',
- 'electrum_plugins.audio_modem',
- 'electrum_plugins.btchipwallet',
- 'electrum_plugins.coinbase_buyback',
- 'electrum_plugins.cosigner_pool',
- 'electrum_plugins.exchange_rate',
- 'electrum_plugins.greenaddress_instant',
- 'electrum_plugins.labels',
- 'electrum_plugins.openalias',
- 'electrum_plugins.plot',
- 'electrum_plugins.trezor',
- 'electrum_plugins.trustedcoin',
- 'electrum_plugins.virtualkeyboard',
-
- ],
description="Lightweight Bitcoin Wallet",
author="Thomas Voegtlin",
author_email="thomasv@electrum.org",