setup.py updates
- parametrise module list - allow optional modules (pyopencl, PyQt4) - add setuptools - add compiler error detection - press return to continue
This commit is contained in:
parent
15077c9388
commit
af5cb08093
85
setup.py
85
setup.py
|
@ -24,7 +24,7 @@ packageManager = {
|
||||||
}
|
}
|
||||||
|
|
||||||
packageName = {
|
packageName = {
|
||||||
"PyQt": {
|
"PyQt4": {
|
||||||
"OpenBSD": "py-qt4",
|
"OpenBSD": "py-qt4",
|
||||||
"FreeBSD": "py27-qt4",
|
"FreeBSD": "py27-qt4",
|
||||||
"Debian": "python-qt4",
|
"Debian": "python-qt4",
|
||||||
|
@ -32,7 +32,12 @@ packageName = {
|
||||||
"openSUSE": "python-qt",
|
"openSUSE": "python-qt",
|
||||||
"Fedora": "PyQt4",
|
"Fedora": "PyQt4",
|
||||||
"Guix": "python2-pyqt@4.11.4",
|
"Guix": "python2-pyqt@4.11.4",
|
||||||
"Gentoo": "dev-python/PyQt4"
|
"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."
|
||||||
},
|
},
|
||||||
"msgpack": {
|
"msgpack": {
|
||||||
"OpenBSD": "py-msgpack",
|
"OpenBSD": "py-msgpack",
|
||||||
|
@ -49,10 +54,34 @@ packageName = {
|
||||||
"Debian": "python-pyopencl",
|
"Debian": "python-pyopencl",
|
||||||
"Ubuntu": "python-pyopencl",
|
"Ubuntu": "python-pyopencl",
|
||||||
"Fedora": "python2-pyopencl",
|
"Fedora": "python2-pyopencl",
|
||||||
"Gentoo": "dev-python/pyopencl"
|
"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",
|
||||||
|
"Fedora": "python2-setuptools",
|
||||||
|
"openSUSE": "python-setuptools",
|
||||||
|
"Guix": "python2-setuptools",
|
||||||
|
"Gentoo": "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compiling = {
|
||||||
|
"Debian": "build-essential libssl-dev",
|
||||||
|
"Ubuntu": "build-essential libssl-dev",
|
||||||
|
"Fedora": "gcc-c++ redhat-rpm-config python-devel",
|
||||||
|
"openSUSE": "gcc-c++ libopenssl-devel python-devel",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def detectOS():
|
def detectOS():
|
||||||
if detectOS.result is not None:
|
if detectOS.result is not None:
|
||||||
|
@ -87,27 +116,14 @@ def detectOS():
|
||||||
|
|
||||||
def detectPrereqs(missing=False):
|
def detectPrereqs(missing=False):
|
||||||
available = []
|
available = []
|
||||||
|
for module in packageName.keys():
|
||||||
try:
|
try:
|
||||||
import_module("PyQt4.QtCore")
|
import_module(module)
|
||||||
if not missing:
|
if not missing:
|
||||||
available.append("PyQt")
|
available.append(module)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if missing:
|
if missing:
|
||||||
available.append("PyQt")
|
available.append(module)
|
||||||
try:
|
|
||||||
import_module("msgpack")
|
|
||||||
if not missing:
|
|
||||||
available.append("msgpack")
|
|
||||||
except ImportError:
|
|
||||||
if missing:
|
|
||||||
available.append("msgpack")
|
|
||||||
try:
|
|
||||||
import_module("pyopencl")
|
|
||||||
if not missing:
|
|
||||||
available.append("pyopencl")
|
|
||||||
except ImportError:
|
|
||||||
if missing:
|
|
||||||
available.append("pyopencl")
|
|
||||||
return available
|
return available
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,27 +132,40 @@ def prereqToPackages():
|
||||||
print "%s %s" % (
|
print "%s %s" % (
|
||||||
packageManager[detectOS()], " ".join(
|
packageManager[detectOS()], " ".join(
|
||||||
packageName[x][detectOS()] for x in detectPrereqs(True)))
|
packageName[x][detectOS()] for x in detectPrereqs(True)))
|
||||||
|
for package in detectPrereqs(True):
|
||||||
|
if packageName[package]['optional']:
|
||||||
|
print packageName[package]['description']
|
||||||
|
|
||||||
|
def compilerToPackages():
|
||||||
|
if not detectOS() in compiling:
|
||||||
|
return
|
||||||
|
print "You can install the requirements by running, as root:"
|
||||||
|
print "%s %s" % (
|
||||||
|
packageManager[detectOS()], compiling[detectOS()])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
detectOS.result = None
|
detectOS.result = None
|
||||||
detectPrereqs.result = None
|
detectPrereqs.result = None
|
||||||
if "PyQt" in detectPrereqs(True):
|
|
||||||
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."
|
|
||||||
if detectPrereqs(True) != [] and detectOS() in packageManager:
|
if detectPrereqs(True) != [] and detectOS() in packageManager:
|
||||||
if detectOS() is not None:
|
if detectOS() is not None:
|
||||||
print "It looks like you're using %s. " \
|
print "It looks like you're using %s. " \
|
||||||
"It is highly recommended to use the package manager " \
|
"It is highly recommended to use the package manager " \
|
||||||
"instead of setuptools." % (detectOS())
|
"instead of setuptools." % (detectOS())
|
||||||
prereqToPackages()
|
prereqToPackages()
|
||||||
|
for module in detectPrereqs(True):
|
||||||
|
if not packageName[module]['optional']:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not haveSetuptools:
|
if not haveSetuptools:
|
||||||
print "It looks like you're missing setuptools."
|
print "It looks like you're missing setuptools."
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
if detectPrereqs(True) != []:
|
||||||
|
print "Press Return to continue"
|
||||||
|
try:
|
||||||
|
nothing = raw_input
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
with open(os.path.join(here, 'README.md')) as f:
|
with open(os.path.join(here, 'README.md')) as f:
|
||||||
README = f.read()
|
README = f.read()
|
||||||
|
@ -147,6 +176,7 @@ if __name__ == "__main__":
|
||||||
libraries=['pthread', 'crypto'],
|
libraries=['pthread', 'crypto'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
dist = setup(
|
dist = setup(
|
||||||
name='pybitmessage',
|
name='pybitmessage',
|
||||||
version=softwareVersion,
|
version=softwareVersion,
|
||||||
|
@ -193,3 +223,8 @@ if __name__ == "__main__":
|
||||||
#},
|
#},
|
||||||
scripts=['src/pybitmessage']
|
scripts=['src/pybitmessage']
|
||||||
)
|
)
|
||||||
|
except SystemExit:
|
||||||
|
print "It looks like building the package failed.\n" \
|
||||||
|
"You may be missing a C++ compiler and the OpenSSL headers."
|
||||||
|
compilerToPackages()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user