2017-02-05 14:31:17 +03:00
|
|
|
#!/usr/bin/env python3
|
2011-11-16 13:53:18 +03:00
|
|
|
|
2011-11-29 10:32:56 +01:00
|
|
|
# python setup.py sdist --format=zip,gztar
|
2011-11-16 13:53:18 +03:00
|
|
|
|
2013-11-12 19:33:47 -08:00
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import platform
|
2018-09-28 02:47:36 +02:00
|
|
|
import importlib.util
|
2016-02-29 13:21:54 +01:00
|
|
|
import argparse
|
2018-08-30 16:16:14 +02:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
from setuptools import setup, find_packages
|
|
|
|
|
from setuptools.command.install import install
|
2013-11-12 19:33:47 -08:00
|
|
|
|
2018-11-03 17:19:51 +01:00
|
|
|
MIN_PYTHON_VERSION = "3.6.1"
|
2018-09-28 02:47:36 +02:00
|
|
|
_min_python_version_tuple = tuple(map(int, (MIN_PYTHON_VERSION.split("."))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[:3] < _min_python_version_tuple:
|
|
|
|
|
sys.exit("Error: Electrum requires Python version >= {}...".format(MIN_PYTHON_VERSION))
|
|
|
|
|
|
2018-02-11 16:27:01 +01:00
|
|
|
with open('contrib/requirements/requirements.txt') as f:
|
2017-12-17 15:22:10 -04:00
|
|
|
requirements = f.read().splitlines()
|
|
|
|
|
|
2018-02-11 16:27:01 +01:00
|
|
|
with open('contrib/requirements/requirements-hw.txt') as f:
|
2017-12-26 01:27:44 +01:00
|
|
|
requirements_hw = f.read().splitlines()
|
|
|
|
|
|
2018-09-28 02:47:36 +02:00
|
|
|
# load version.py; needlessly complicated alternative to "imp.load_source":
|
|
|
|
|
version_spec = importlib.util.spec_from_file_location('version', 'electrum/version.py')
|
|
|
|
|
version_module = version = importlib.util.module_from_spec(version_spec)
|
|
|
|
|
version_spec.loader.exec_module(version_module)
|
2014-11-22 14:03:21 +01:00
|
|
|
|
2018-03-07 15:15:54 -05:00
|
|
|
data_files = []
|
2015-10-18 12:43:20 +02:00
|
|
|
|
|
|
|
|
if platform.system() in ['Linux', 'FreeBSD', 'DragonFly']:
|
2016-02-29 13:21:54 +01:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
parser.add_argument('--root=', dest='root_path', metavar='dir', default='/')
|
|
|
|
|
opts, _ = parser.parse_known_args(sys.argv[1:])
|
2015-02-18 17:13:41 +01:00
|
|
|
usr_share = os.path.join(sys.prefix, "share")
|
2018-03-20 12:25:04 +01:00
|
|
|
icons_dirname = 'pixmaps'
|
2016-02-29 13:21:54 +01:00
|
|
|
if not os.access(opts.root_path + usr_share, os.W_OK) and \
|
|
|
|
|
not os.access(opts.root_path, os.W_OK):
|
2018-03-20 12:25:04 +01:00
|
|
|
icons_dirname = 'icons'
|
2016-01-05 12:13:15 +01:00
|
|
|
if 'XDG_DATA_HOME' in os.environ.keys():
|
2016-06-18 17:41:24 +02:00
|
|
|
usr_share = os.environ['XDG_DATA_HOME']
|
2016-01-05 12:13:15 +01:00
|
|
|
else:
|
|
|
|
|
usr_share = os.path.expanduser('~/.local/share')
|
2012-06-10 15:43:10 +02:00
|
|
|
data_files += [
|
2013-11-12 19:33:47 -08:00
|
|
|
(os.path.join(usr_share, 'applications/'), ['electrum.desktop']),
|
2018-03-20 12:25:04 +01:00
|
|
|
(os.path.join(usr_share, icons_dirname), ['icons/electrum.png'])
|
2012-07-05 01:41:07 +02:00
|
|
|
]
|
2014-09-13 09:58:11 +02:00
|
|
|
|
2018-05-24 18:57:13 +02:00
|
|
|
extras_require = {
|
|
|
|
|
'hardware': requirements_hw,
|
|
|
|
|
'fast': ['pycryptodomex'],
|
2018-08-30 16:16:14 +02:00
|
|
|
'gui': ['pyqt5'],
|
2018-05-24 18:57:13 +02:00
|
|
|
}
|
2018-08-30 16:16:14 +02:00
|
|
|
extras_require['full'] = [pkg for sublist in list(extras_require.values()) for pkg in sublist]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomInstallCommand(install):
|
|
|
|
|
def run(self):
|
|
|
|
|
install.run(self)
|
|
|
|
|
# potentially build Qt icons file
|
|
|
|
|
try:
|
|
|
|
|
import PyQt5
|
|
|
|
|
except ImportError:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
path = os.path.join(self.install_lib, "electrum/gui/qt/icons_rc.py")
|
|
|
|
|
if not os.path.exists(path):
|
|
|
|
|
subprocess.call(["pyrcc5", "icons.qrc", "-o", path])
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print('Warning: building icons file failed with {}'.format(e))
|
2018-05-24 18:57:13 +02:00
|
|
|
|
|
|
|
|
|
2013-11-12 19:33:47 -08:00
|
|
|
setup(
|
|
|
|
|
name="Electrum",
|
|
|
|
|
version=version.ELECTRUM_VERSION,
|
2018-09-28 02:47:36 +02:00
|
|
|
python_requires='>={}'.format(MIN_PYTHON_VERSION),
|
2017-12-17 15:22:10 -04:00
|
|
|
install_requires=requirements,
|
2018-05-24 18:57:13 +02:00
|
|
|
extras_require=extras_require,
|
2015-11-23 19:38:48 +01:00
|
|
|
packages=[
|
|
|
|
|
'electrum',
|
2018-07-11 17:38:47 +02:00
|
|
|
'electrum.gui',
|
|
|
|
|
'electrum.gui.qt',
|
|
|
|
|
'electrum.plugins',
|
2018-07-24 16:13:49 +02:00
|
|
|
] + [('electrum.plugins.'+pkg) for pkg in find_packages('electrum/plugins')],
|
2013-11-12 19:33:47 -08:00
|
|
|
package_dir={
|
2018-07-11 17:38:47 +02:00
|
|
|
'electrum': 'electrum'
|
2013-11-12 19:33:47 -08:00
|
|
|
},
|
2015-02-18 17:13:41 +01:00
|
|
|
package_data={
|
2018-06-10 22:12:23 +02:00
|
|
|
'': ['*.txt', '*.json', '*.ttf', '*.otf'],
|
2015-02-18 17:13:41 +01:00
|
|
|
'electrum': [
|
2018-07-24 16:13:49 +02:00
|
|
|
'wordlist/*.txt',
|
|
|
|
|
'locale/*/LC_MESSAGES/electrum.mo',
|
2018-06-10 22:12:23 +02:00
|
|
|
],
|
2015-02-18 17:13:41 +01:00
|
|
|
},
|
2018-07-11 17:38:47 +02:00
|
|
|
scripts=['electrum/electrum'],
|
2013-11-12 19:33:47 -08:00
|
|
|
data_files=data_files,
|
|
|
|
|
description="Lightweight Bitcoin Wallet",
|
2014-06-07 13:30:40 +02:00
|
|
|
author="Thomas Voegtlin",
|
2015-02-17 17:24:40 +01:00
|
|
|
author_email="thomasv@electrum.org",
|
2016-02-23 11:36:42 +01:00
|
|
|
license="MIT Licence",
|
2014-06-07 13:30:40 +02:00
|
|
|
url="https://electrum.org",
|
2018-08-30 16:16:14 +02:00
|
|
|
long_description="""Lightweight Bitcoin Wallet""",
|
|
|
|
|
cmdclass={
|
|
|
|
|
'install': CustomInstallCommand,
|
|
|
|
|
},
|
2012-05-10 14:38:49 +02:00
|
|
|
)
|