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-02-24 16:49:53 +01:00
|
|
|
haveSetuptools = True
|
|
|
|
except ImportError:
|
|
|
|
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",
|
|
|
|
"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 = {
|
|
|
|
"PyQt": {
|
|
|
|
"OpenBSD": "py-qt4",
|
|
|
|
"FreeBSD": "py27-qt4",
|
|
|
|
"Debian": "python-qt4",
|
|
|
|
"Ubuntu": "python-qt4",
|
|
|
|
"openSUSE": "python-qt",
|
|
|
|
"Fedora": "PyQt4",
|
|
|
|
"Guix": "python2-pyqt@4.11.4",
|
2017-02-28 14:51:49 +01:00
|
|
|
"Gentoo": "dev-python/PyQt4"
|
2017-02-24 16:49:53 +01:00
|
|
|
},
|
|
|
|
"msgpack": {
|
|
|
|
"OpenBSD": "py-msgpack",
|
|
|
|
"FreeBSD": "py27-msgpack-python",
|
|
|
|
"Debian": "python-msgpack",
|
|
|
|
"Ubuntu": "python-msgpack",
|
|
|
|
"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",
|
|
|
|
"Fedora": "python2-pyopencl",
|
|
|
|
"Gentoo": "dev-python/pyopencl"
|
2017-02-24 16:49:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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"):
|
|
|
|
with open("/etc/os-release", 'rt') as osRelease:
|
|
|
|
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-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-02-24 16:49:53 +01:00
|
|
|
def detectPrereqs(missing=False):
|
|
|
|
available = []
|
|
|
|
try:
|
2017-02-28 14:51:49 +01:00
|
|
|
import_module("PyQt4.QtCore")
|
2017-02-24 16:49:53 +01:00
|
|
|
if not missing:
|
|
|
|
available.append("PyQt")
|
|
|
|
except ImportError:
|
|
|
|
if missing:
|
|
|
|
available.append("PyQt")
|
|
|
|
try:
|
2017-02-28 14:51:49 +01:00
|
|
|
import_module("msgpack")
|
2017-02-24 16:49:53 +01:00
|
|
|
if not missing:
|
|
|
|
available.append("msgpack")
|
|
|
|
except ImportError:
|
|
|
|
if missing:
|
|
|
|
available.append("msgpack")
|
2017-02-28 22:22:36 +01:00
|
|
|
try:
|
|
|
|
import_module("pyopencl")
|
|
|
|
if not missing:
|
|
|
|
available.append("pyopencl")
|
|
|
|
except ImportError:
|
|
|
|
if missing:
|
|
|
|
available.append("pyopencl")
|
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(
|
|
|
|
packageName[x][detectOS()] for x in detectPrereqs(True)))
|
|
|
|
|
2017-02-24 16:49:53 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
detectOS.result = None
|
|
|
|
detectPrereqs.result = None
|
|
|
|
if "PyQt" in detectPrereqs(True):
|
2017-02-28 14:51:49 +01:00
|
|
|
print "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
|
|
|
if detectPrereqs(True) != [] and detectOS() in packageManager:
|
|
|
|
if detectOS() is not None:
|
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 " \
|
|
|
|
"instead of setuptools." % (detectOS())
|
2017-02-24 16:49:53 +01:00
|
|
|
prereqToPackages()
|
|
|
|
sys.exit()
|
|
|
|
if not haveSetuptools:
|
|
|
|
print "It looks like you're missing setuptools."
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
|
|
|
dist = setup(
|
|
|
|
name='pybitmessage',
|
|
|
|
version=softwareVersion,
|
2017-02-28 14:51:49 +01:00
|
|
|
description="Reference client for Bitmessage: "
|
|
|
|
"a P2P communications protocol",
|
2017-02-24 16:49:53 +01:00
|
|
|
long_description=README,
|
|
|
|
license='MIT',
|
|
|
|
# TODO: add author info
|
|
|
|
#author='',
|
|
|
|
#author_email='',
|
2017-02-28 14:51:49 +01:00
|
|
|
url='https://bitmessage.org',
|
2017-02-24 16:49:53 +01:00
|
|
|
# TODO: add keywords
|
|
|
|
#keywords='',
|
2017-02-28 14:51:49 +01:00
|
|
|
install_requires=['msgpack-python'],
|
|
|
|
classifiers=[
|
2017-02-24 16:49:53 +01:00
|
|
|
"License :: OSI Approved :: MIT License"
|
2017-02-28 14:51:49 +01:00
|
|
|
"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-02-24 16:49:53 +01:00
|
|
|
],
|
2017-02-28 14:51:49 +01:00
|
|
|
package_data={'': [
|
|
|
|
'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem',
|
|
|
|
'translations/*.ts', 'translations/*.qm',
|
|
|
|
'images/*.png', 'images/*.ico', 'images/*.icns'
|
|
|
|
]},
|
|
|
|
ext_modules=[bitmsghash],
|
2017-02-24 16:49:53 +01:00
|
|
|
zip_safe=False,
|
2017-02-28 14:51:49 +01:00
|
|
|
#entry_points={
|
|
|
|
# 'console_scripts': [
|
|
|
|
# 'pybitmessage = pybitmessage.bitmessagemain:main'
|
|
|
|
# ]
|
|
|
|
#},
|
|
|
|
scripts=['src/pybitmessage']
|
2017-02-24 16:49:53 +01:00
|
|
|
)
|