2017-02-28 14:51:49 +01:00
|
|
|
#!/usr/bin/env python2.7
|
|
|
|
|
2017-02-24 16:49:53 +01:00
|
|
|
import os
|
2017-02-28 14:51:49 +01:00
|
|
|
import sys
|
2017-02-24 16:49:53 +01:00
|
|
|
try:
|
2017-02-28 14:51:49 +01:00
|
|
|
from setuptools import setup, Extension
|
2017-03-25 10:48:45 +01:00
|
|
|
from setuptools.command.install import install
|
2017-02-24 16:49:53 +01:00
|
|
|
haveSetuptools = True
|
|
|
|
except ImportError:
|
2017-03-25 10:48:45 +01:00
|
|
|
install = object
|
2017-02-24 16:49:53 +01:00
|
|
|
haveSetuptools = False
|
2017-02-28 14:51:49 +01:00
|
|
|
|
|
|
|
from importlib import import_module
|
2017-02-24 16:49:53 +01:00
|
|
|
|
|
|
|
from src.version import softwareVersion
|
|
|
|
|
|
|
|
packageManager = {
|
|
|
|
"OpenBSD": "pkg_add",
|
2017-02-28 22:22:36 +01:00
|
|
|
"FreeBSD": "pkg install",
|
2017-02-24 16:49:53 +01:00
|
|
|
"Debian": "apt-get install",
|
|
|
|
"Ubuntu": "apt-get install",
|
2017-03-17 19:25:19 +01:00
|
|
|
"Ubuntu 12": "apt-get install",
|
2017-02-24 16:49:53 +01:00
|
|
|
"openSUSE": "zypper install",
|
|
|
|
"Fedora": "dnf install",
|
|
|
|
"Guix": "guix package -i",
|
2017-02-28 14:51:49 +01:00
|
|
|
"Gentoo": "emerge"
|
2017-02-24 16:49:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
packageName = {
|
2017-03-01 11:29:38 +01:00
|
|
|
"PyQt4": {
|
2017-02-24 16:49:53 +01:00
|
|
|
"OpenBSD": "py-qt4",
|
|
|
|
"FreeBSD": "py27-qt4",
|
|
|
|
"Debian": "python-qt4",
|
|
|
|
"Ubuntu": "python-qt4",
|
2017-03-17 19:25:19 +01:00
|
|
|
"Ubuntu 12": "python-qt4",
|
2017-02-24 16:49:53 +01:00
|
|
|
"openSUSE": "python-qt",
|
|
|
|
"Fedora": "PyQt4",
|
|
|
|
"Guix": "python2-pyqt@4.11.4",
|
2017-03-01 11:29:38 +01:00
|
|
|
"Gentoo": "dev-python/PyQt4",
|
|
|
|
'optional': True,
|
|
|
|
'description': "You only need PyQt if you want to use the GUI. " \
|
|
|
|
"When only running as a daemon, this can be skipped.\n" \
|
|
|
|
"However, you would have to install it manually " \
|
|
|
|
"because setuptools does not support PyQt."
|
2017-02-24 16:49:53 +01:00
|
|
|
},
|
|
|
|
"msgpack": {
|
|
|
|
"OpenBSD": "py-msgpack",
|
|
|
|
"FreeBSD": "py27-msgpack-python",
|
|
|
|
"Debian": "python-msgpack",
|
|
|
|
"Ubuntu": "python-msgpack",
|
2017-03-17 19:25:19 +01:00
|
|
|
"Ubuntu 12": "msgpack-python",
|
2017-02-24 16:49:53 +01:00
|
|
|
"openSUSE": "python-msgpack-python",
|
|
|
|
"Fedora": "python2-msgpack",
|
|
|
|
"Guix": "python2-msgpack",
|
2017-02-28 14:51:49 +01:00
|
|
|
"Gentoo": "dev-python/msgpack"
|
2017-02-28 22:22:36 +01:00
|
|
|
},
|
|
|
|
"pyopencl": {
|
|
|
|
"FreeBSD": "py27-pyopencl",
|
|
|
|
"Debian": "python-pyopencl",
|
|
|
|
"Ubuntu": "python-pyopencl",
|
2017-03-17 19:25:19 +01:00
|
|
|
"Ubuntu 12": "python-pyopencl",
|
2017-02-28 22:22:36 +01:00
|
|
|
"Fedora": "python2-pyopencl",
|
2017-03-01 11:29:38 +01:00
|
|
|
"openSUSE": "",
|
|
|
|
"OpenBSD": "",
|
|
|
|
"Guix": "",
|
|
|
|
"Gentoo": "dev-python/pyopencl",
|
|
|
|
"optional": True,
|
|
|
|
'description': "If you install pyopencl, you will be able to use " \
|
|
|
|
"GPU acceleration for proof of work. \n" \
|
|
|
|
"You also need a compatible GPU and drivers."
|
|
|
|
},
|
|
|
|
"setuptools": {
|
|
|
|
"OpenBSD": "py-setuptools",
|
|
|
|
"FreeBSD": "py27-setuptools",
|
|
|
|
"Debian": "python-setuptools",
|
|
|
|
"Ubuntu": "python-setuptools",
|
2017-03-17 19:25:19 +01:00
|
|
|
"Ubuntu 12": "python-setuptools",
|
2017-03-01 11:29:38 +01:00
|
|
|
"Fedora": "python2-setuptools",
|
|
|
|
"openSUSE": "python-setuptools",
|
|
|
|
"Guix": "python2-setuptools",
|
|
|
|
"Gentoo": "",
|
2017-02-24 16:49:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-01 11:29:38 +01:00
|
|
|
compiling = {
|
|
|
|
"Debian": "build-essential libssl-dev",
|
|
|
|
"Ubuntu": "build-essential libssl-dev",
|
2017-03-01 11:44:58 +01:00
|
|
|
"Fedora": "gcc-c++ redhat-rpm-config python-devel openssl-devel",
|
2017-03-01 11:29:38 +01:00
|
|
|
"openSUSE": "gcc-c++ libopenssl-devel python-devel",
|
|
|
|
}
|
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
|
2017-02-24 16:49:53 +01:00
|
|
|
def detectOS():
|
|
|
|
if detectOS.result is not None:
|
|
|
|
return detectOS.result
|
|
|
|
if sys.platform.startswith('openbsd'):
|
|
|
|
detectOS.result = "OpenBSD"
|
|
|
|
elif sys.platform.startswith('freebsd'):
|
|
|
|
detectOS.result = "FreeBSD"
|
|
|
|
elif sys.platform.startswith('win'):
|
|
|
|
detectOS.result = "Windows"
|
|
|
|
elif os.path.isfile("/etc/os-release"):
|
2017-05-12 14:39:25 +02:00
|
|
|
with open("/etc/os-release", 'r') as osRelease:
|
2017-03-17 19:25:19 +01:00
|
|
|
version = None
|
2017-02-24 16:49:53 +01:00
|
|
|
for line in osRelease:
|
|
|
|
if line.startswith("NAME="):
|
2017-02-28 14:51:49 +01:00
|
|
|
line = line.lower()
|
|
|
|
if "fedora" in line:
|
2017-02-24 16:49:53 +01:00
|
|
|
detectOS.result = "Fedora"
|
2017-02-28 14:51:49 +01:00
|
|
|
elif "opensuse" in line:
|
2017-02-24 16:49:53 +01:00
|
|
|
detectOS.result = "openSUSE"
|
2017-02-28 14:51:49 +01:00
|
|
|
elif "ubuntu" in line:
|
2017-02-24 16:49:53 +01:00
|
|
|
detectOS.result = "Ubuntu"
|
2017-02-28 14:51:49 +01:00
|
|
|
elif "debian" in line:
|
2017-02-24 16:49:53 +01:00
|
|
|
detectOS.result = "Debian"
|
2017-02-28 14:51:49 +01:00
|
|
|
elif "gentoo" in line or "calculate" in line:
|
|
|
|
detectOS.result = "Gentoo"
|
2017-02-24 16:49:53 +01:00
|
|
|
else:
|
|
|
|
detectOS.result = None
|
2017-03-17 19:25:19 +01:00
|
|
|
if line.startswith("VERSION_ID="):
|
|
|
|
try:
|
|
|
|
version = float(line.split("\"")[1])
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
if detectOS.result == "Ubuntu" and version < 14:
|
|
|
|
detectOS.result = "Ubuntu 12"
|
2017-02-28 22:22:36 +01:00
|
|
|
elif os.path.isfile("/etc/config.scm"):
|
|
|
|
detectOS.result = "Guix"
|
2017-02-24 16:49:53 +01:00
|
|
|
return detectOS.result
|
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
|
2017-03-25 10:48:45 +01:00
|
|
|
def detectPrereqs(missing=True):
|
2017-02-24 16:49:53 +01:00
|
|
|
available = []
|
2017-03-01 11:29:38 +01:00
|
|
|
for module in packageName.keys():
|
|
|
|
try:
|
|
|
|
import_module(module)
|
|
|
|
if not missing:
|
|
|
|
available.append(module)
|
|
|
|
except ImportError:
|
|
|
|
if missing:
|
|
|
|
available.append(module)
|
2017-02-24 16:49:53 +01:00
|
|
|
return available
|
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
|
2017-02-24 16:49:53 +01:00
|
|
|
def prereqToPackages():
|
|
|
|
print "You can install the requirements by running, as root:"
|
2017-02-28 14:51:49 +01:00
|
|
|
print "%s %s" % (
|
|
|
|
packageManager[detectOS()], " ".join(
|
2017-03-25 10:48:45 +01:00
|
|
|
packageName[x][detectOS()] for x in detectPrereqs()))
|
|
|
|
for package in detectPrereqs():
|
|
|
|
if packageName[package].get('optional'):
|
|
|
|
print packageName[package].get('description')
|
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
|
2017-03-01 11:29:38 +01:00
|
|
|
def compilerToPackages():
|
|
|
|
if not detectOS() in compiling:
|
|
|
|
return
|
|
|
|
print "You can install the requirements by running, as root:"
|
|
|
|
print "%s %s" % (
|
2017-03-25 10:48:45 +01:00
|
|
|
packageManager[detectOS.result], compiling[detectOS.result])
|
2017-02-24 16:49:53 +01:00
|
|
|
|
2017-03-25 10:48:45 +01:00
|
|
|
|
|
|
|
class InstallCmd(install):
|
|
|
|
def run(self):
|
|
|
|
detectOS.result = None
|
|
|
|
prereqs = detectPrereqs()
|
|
|
|
if prereqs and detectOS() in packageManager:
|
2017-02-28 14:51:49 +01:00
|
|
|
print "It looks like you're using %s. " \
|
|
|
|
"It is highly recommended to use the package manager " \
|
2017-03-25 10:48:45 +01:00
|
|
|
"instead of setuptools." % (detectOS.result)
|
2017-02-24 16:49:53 +01:00
|
|
|
prereqToPackages()
|
2017-03-20 00:27:11 +01:00
|
|
|
try:
|
2017-03-25 10:48:45 +01:00
|
|
|
for module in prereqs:
|
2017-03-20 00:27:11 +01:00
|
|
|
if not packageName[module]['optional']:
|
|
|
|
sys.exit()
|
|
|
|
except KeyError:
|
|
|
|
sys.exit()
|
2017-02-24 16:49:53 +01:00
|
|
|
|
2017-03-25 10:48:45 +01:00
|
|
|
if not haveSetuptools:
|
|
|
|
print "It looks like you're missing setuptools."
|
|
|
|
sys.exit()
|
2017-03-01 11:29:38 +01:00
|
|
|
|
2017-03-25 10:48:45 +01:00
|
|
|
if prereqs and sys.stdin.isatty():
|
|
|
|
print "Press Return to continue"
|
|
|
|
try:
|
|
|
|
raw_input()
|
2017-04-30 10:41:55 +02:00
|
|
|
except EOFError, NameError:
|
2017-03-25 10:48:45 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
return install.run(self)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2017-02-24 16:49:53 +01:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
with open(os.path.join(here, 'README.md')) as f:
|
|
|
|
README = f.read()
|
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
bitmsghash = Extension(
|
|
|
|
'pybitmessage.bitmsghash.bitmsghash',
|
|
|
|
sources=['src/bitmsghash/bitmsghash.cpp'],
|
|
|
|
libraries=['pthread', 'crypto'],
|
2017-02-24 16:49:53 +01:00
|
|
|
)
|
|
|
|
|
2017-03-17 19:25:19 +01:00
|
|
|
installRequires = []
|
|
|
|
# this will silently accept alternative providers of msgpack if they are already installed
|
2017-03-25 10:48:45 +01:00
|
|
|
if "msgpack" in detectPrereqs():
|
2017-03-17 19:25:19 +01:00
|
|
|
installRequires.append("msgpack-python")
|
|
|
|
|
2017-03-01 11:29:38 +01:00
|
|
|
try:
|
|
|
|
dist = setup(
|
|
|
|
name='pybitmessage',
|
|
|
|
version=softwareVersion,
|
|
|
|
description="Reference client for Bitmessage: "
|
|
|
|
"a P2P communications protocol",
|
|
|
|
long_description=README,
|
|
|
|
license='MIT',
|
|
|
|
# TODO: add author info
|
|
|
|
#author='',
|
|
|
|
#author_email='',
|
|
|
|
url='https://bitmessage.org',
|
|
|
|
# TODO: add keywords
|
|
|
|
#keywords='',
|
2017-04-04 12:31:52 +02:00
|
|
|
install_requires=installRequires,
|
2017-03-01 15:46:13 +01:00
|
|
|
extras_require={
|
2017-03-17 19:25:19 +01:00
|
|
|
'qrcode': ['qrcode'],
|
|
|
|
'pyopencl': ['pyopencl']
|
2017-03-01 15:46:13 +01:00
|
|
|
},
|
2017-03-01 11:29:38 +01:00
|
|
|
classifiers=[
|
|
|
|
"License :: OSI Approved :: MIT License"
|
|
|
|
"Operating System :: OS Independent",
|
|
|
|
"Programming Language :: Python :: 2.7 :: Only",
|
|
|
|
"Topic :: Internet",
|
|
|
|
"Topic :: Security :: Cryptography",
|
|
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
|
|
],
|
|
|
|
package_dir={'pybitmessage': 'src'},
|
|
|
|
packages=[
|
|
|
|
'pybitmessage',
|
|
|
|
'pybitmessage.bitmessageqt',
|
|
|
|
'pybitmessage.bitmessagecurses',
|
|
|
|
'pybitmessage.messagetypes',
|
|
|
|
'pybitmessage.network',
|
|
|
|
'pybitmessage.pyelliptic',
|
|
|
|
'pybitmessage.socks',
|
2017-03-01 15:46:13 +01:00
|
|
|
'pybitmessage.plugins'
|
2017-03-01 11:29:38 +01:00
|
|
|
],
|
|
|
|
package_data={'': [
|
|
|
|
'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem',
|
|
|
|
'translations/*.ts', 'translations/*.qm',
|
|
|
|
'images/*.png', 'images/*.ico', 'images/*.icns'
|
|
|
|
]},
|
|
|
|
ext_modules=[bitmsghash],
|
|
|
|
zip_safe=False,
|
2017-03-01 15:46:13 +01:00
|
|
|
entry_points={
|
|
|
|
'gui.menu': [
|
|
|
|
'popMenuYourIdentities.qrcode = '
|
|
|
|
'pybitmessage.plugins.qrcodeui [qrcode]'
|
|
|
|
],
|
2017-03-01 11:29:38 +01:00
|
|
|
# 'console_scripts': [
|
|
|
|
# 'pybitmessage = pybitmessage.bitmessagemain:main'
|
|
|
|
# ]
|
2017-03-01 15:46:13 +01:00
|
|
|
},
|
2017-03-25 10:48:45 +01:00
|
|
|
scripts=['src/pybitmessage'],
|
|
|
|
cmdclass={'install': InstallCmd}
|
2017-03-01 11:29:38 +01:00
|
|
|
)
|
2017-03-22 21:47:48 +01:00
|
|
|
except SystemExit as err:
|
|
|
|
print err.message
|
|
|
|
except:
|
2017-03-01 11:29:38 +01:00
|
|
|
print "It looks like building the package failed.\n" \
|
|
|
|
"You may be missing a C++ compiler and the OpenSSL headers."
|
|
|
|
compilerToPackages()
|