Total setup.py cleanup and simple script installation
This commit is contained in:
parent
e7506b2ac0
commit
34084bbc80
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -11,3 +11,5 @@ src/**/*.o
|
||||||
src/**/*.so
|
src/**/*.so
|
||||||
build/lib.*
|
build/lib.*
|
||||||
build/temp.*
|
build/temp.*
|
||||||
|
dist
|
||||||
|
*.egg-info
|
||||||
|
|
3
MANIFEST.in
Normal file
3
MANIFEST.in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
include COPYING
|
||||||
|
include README.md
|
||||||
|
recursive-include desktop *
|
107
setup.py
107
setup.py
|
@ -1,10 +1,14 @@
|
||||||
|
#!/usr/bin/env python2.7
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
try:
|
try:
|
||||||
from setuptools import setup, find_packages, Extension
|
from setuptools import setup, Extension
|
||||||
haveSetuptools = True
|
haveSetuptools = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
haveSetuptools = False
|
haveSetuptools = False
|
||||||
import sys
|
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
from src.version import softwareVersion
|
from src.version import softwareVersion
|
||||||
|
|
||||||
|
@ -16,6 +20,7 @@ packageManager = {
|
||||||
"openSUSE": "zypper install",
|
"openSUSE": "zypper install",
|
||||||
"Fedora": "dnf install",
|
"Fedora": "dnf install",
|
||||||
"Guix": "guix package -i",
|
"Guix": "guix package -i",
|
||||||
|
"Gentoo": "emerge"
|
||||||
}
|
}
|
||||||
|
|
||||||
packageName = {
|
packageName = {
|
||||||
|
@ -27,6 +32,7 @@ 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"
|
||||||
},
|
},
|
||||||
"msgpack": {
|
"msgpack": {
|
||||||
"OpenBSD": "py-msgpack",
|
"OpenBSD": "py-msgpack",
|
||||||
|
@ -36,9 +42,11 @@ packageName = {
|
||||||
"openSUSE": "python-msgpack-python",
|
"openSUSE": "python-msgpack-python",
|
||||||
"Fedora": "python2-msgpack",
|
"Fedora": "python2-msgpack",
|
||||||
"Guix": "python2-msgpack",
|
"Guix": "python2-msgpack",
|
||||||
|
"Gentoo": "dev-python/msgpack"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def detectOS():
|
def detectOS():
|
||||||
if detectOS.result is not None:
|
if detectOS.result is not None:
|
||||||
return detectOS.result
|
return detectOS.result
|
||||||
|
@ -52,29 +60,33 @@ def detectOS():
|
||||||
with open("/etc/os-release", 'rt') as osRelease:
|
with open("/etc/os-release", 'rt') as osRelease:
|
||||||
for line in osRelease:
|
for line in osRelease:
|
||||||
if line.startswith("NAME="):
|
if line.startswith("NAME="):
|
||||||
if "fedora" in line.lower():
|
line = line.lower()
|
||||||
|
if "fedora" in line:
|
||||||
detectOS.result = "Fedora"
|
detectOS.result = "Fedora"
|
||||||
elif "opensuse" in line.lower():
|
elif "opensuse" in line:
|
||||||
detectOS.result = "openSUSE"
|
detectOS.result = "openSUSE"
|
||||||
elif "ubuntu" in line.lower():
|
elif "ubuntu" in line:
|
||||||
detectOS.result = "Ubuntu"
|
detectOS.result = "Ubuntu"
|
||||||
elif "debian" in line.lower():
|
elif "debian" in line:
|
||||||
detectOS.result = "Debian"
|
detectOS.result = "Debian"
|
||||||
|
elif "gentoo" in line or "calculate" in line:
|
||||||
|
detectOS.result = "Gentoo"
|
||||||
else:
|
else:
|
||||||
detectOS.result = None
|
detectOS.result = None
|
||||||
return detectOS.result
|
return detectOS.result
|
||||||
|
|
||||||
|
|
||||||
def detectPrereqs(missing=False):
|
def detectPrereqs(missing=False):
|
||||||
available = []
|
available = []
|
||||||
try:
|
try:
|
||||||
import PyQt4.QtCore
|
import_module("PyQt4.QtCore")
|
||||||
if not missing:
|
if not missing:
|
||||||
available.append("PyQt")
|
available.append("PyQt")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if missing:
|
if missing:
|
||||||
available.append("PyQt")
|
available.append("PyQt")
|
||||||
try:
|
try:
|
||||||
import msgpack
|
import_module("msgpack")
|
||||||
if not missing:
|
if not missing:
|
||||||
available.append("msgpack")
|
available.append("msgpack")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -82,19 +94,27 @@ def detectPrereqs(missing=False):
|
||||||
available.append("msgpack")
|
available.append("msgpack")
|
||||||
return available
|
return available
|
||||||
|
|
||||||
|
|
||||||
def prereqToPackages():
|
def prereqToPackages():
|
||||||
print "You can install the requirements by running, as root:"
|
print "You can install the requirements by running, as root:"
|
||||||
print "%s %s" % (packageManager[detectOS()], " ".join(packageName[x][detectOS()] for x in detectPrereqs(True)))
|
print "%s %s" % (
|
||||||
|
packageManager[detectOS()], " ".join(
|
||||||
|
packageName[x][detectOS()] for x in detectPrereqs(True)))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
detectOS.result = None
|
detectOS.result = None
|
||||||
detectPrereqs.result = None
|
detectPrereqs.result = None
|
||||||
if "PyQt" in detectPrereqs(True):
|
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."
|
print "You only need PyQt if you want to use the GUI. " \
|
||||||
print "However, you would have to install it manually because setuptools does not support pyqt."
|
"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. It is highly recommended to use the package manager instead of setuptools." % (detectOS())
|
print "It looks like you're using %s. " \
|
||||||
|
"It is highly recommended to use the package manager " \
|
||||||
|
"instead of setuptools." % (detectOS())
|
||||||
prereqToPackages()
|
prereqToPackages()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if not haveSetuptools:
|
if not haveSetuptools:
|
||||||
|
@ -105,7 +125,8 @@ if __name__ == "__main__":
|
||||||
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()
|
||||||
|
|
||||||
bitmsghash = Extension('bitmsghash.bitmsghash',
|
bitmsghash = Extension(
|
||||||
|
'pybitmessage.bitmsghash.bitmsghash',
|
||||||
sources=['src/bitmsghash/bitmsghash.cpp'],
|
sources=['src/bitmsghash/bitmsghash.cpp'],
|
||||||
libraries=['pthread', 'crypto'],
|
libraries=['pthread', 'crypto'],
|
||||||
)
|
)
|
||||||
|
@ -113,48 +134,46 @@ if __name__ == "__main__":
|
||||||
dist = setup(
|
dist = setup(
|
||||||
name='pybitmessage',
|
name='pybitmessage',
|
||||||
version=softwareVersion,
|
version=softwareVersion,
|
||||||
description='',
|
description="Reference client for Bitmessage: "
|
||||||
|
"a P2P communications protocol",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
license='MIT',
|
license='MIT',
|
||||||
# TODO: add author info
|
# TODO: add author info
|
||||||
#author='',
|
#author='',
|
||||||
#author_email='',
|
#author_email='',
|
||||||
url='https://github.com/Bitmessage/PyBitmessage/',
|
url='https://bitmessage.org',
|
||||||
# TODO: add keywords
|
# TODO: add keywords
|
||||||
#keywords='',
|
#keywords='',
|
||||||
install_requires=['msgpack-python'],
|
install_requires=['msgpack-python'],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"License :: OSI Approved :: MIT License"
|
"License :: OSI Approved :: MIT License"
|
||||||
"Operating System :: MacOS :: MacOS X",
|
"Operating System :: OS Independent",
|
||||||
"Operating System :: Microsoft :: Windows",
|
"Programming Language :: Python :: 2.7 :: Only",
|
||||||
"Operating System :: POSIX :: Linux",
|
"Topic :: Internet",
|
||||||
"Programming Language :: Python :: 2.7.3",
|
"Topic :: Security :: Cryptography",
|
||||||
"Programming Language :: Python :: 2.7.4",
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
"Programming Language :: Python :: 2.7.5",
|
|
||||||
"Programming Language :: Python :: 2.7.6",
|
|
||||||
"Programming Language :: Python :: 2.7.7",
|
|
||||||
"Programming Language :: Python :: 2.7.8",
|
|
||||||
"Programming Language :: Python :: 2.7.9",
|
|
||||||
"Programming Language :: Python :: 2.7.10",
|
|
||||||
"Programming Language :: Python :: 2.7.11",
|
|
||||||
"Programming Language :: Python :: 2.7.12",
|
|
||||||
"Programming Language :: Python :: 2.7.13",
|
|
||||||
],
|
],
|
||||||
package_dir={'':'src'},
|
package_dir={'pybitmessage': 'src'},
|
||||||
packages=['','bitmessageqt', 'bitmessagecurses', 'messagetypes', 'network', 'pyelliptic', 'socks'],
|
packages=[
|
||||||
package_data={'': ['bitmessageqt/*.ui', 'bitmsghash/*.cl', 'keys/*.pem', 'translations/*.ts', 'translations/*.qm', 'images/*.png', 'images/*.ico', 'images/*.icns']},
|
'pybitmessage',
|
||||||
|
'pybitmessage.bitmessageqt',
|
||||||
|
'pybitmessage.bitmessagecurses',
|
||||||
|
'pybitmessage.messagetypes',
|
||||||
|
'pybitmessage.network',
|
||||||
|
'pybitmessage.pyelliptic',
|
||||||
|
'pybitmessage.socks',
|
||||||
|
],
|
||||||
|
package_data={'': [
|
||||||
|
'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem',
|
||||||
|
'translations/*.ts', 'translations/*.qm',
|
||||||
|
'images/*.png', 'images/*.ico', 'images/*.icns'
|
||||||
|
]},
|
||||||
ext_modules=[bitmsghash],
|
ext_modules=[bitmsghash],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
entry_points="""\
|
#entry_points={
|
||||||
[console_scripts]
|
# 'console_scripts': [
|
||||||
bitmessage = bitmessagemain:Main.start
|
# 'pybitmessage = pybitmessage.bitmessagemain:main'
|
||||||
""",
|
# ]
|
||||||
|
#},
|
||||||
|
scripts=['src/pybitmessage']
|
||||||
)
|
)
|
||||||
if (dist.command_obj.get('install_scripts')):
|
|
||||||
with open(os.path.join(dist.command_obj['install_scripts'].install_dir, 'bitmessage'), 'wt') as f:
|
|
||||||
f.write("#!/bin/sh\n")
|
|
||||||
f.write(dist.command_obj['build'].executable + " " + \
|
|
||||||
os.path.join(dist.command_obj['install'].install_lib,
|
|
||||||
os.path.basename(dist.command_obj['bdist_egg'].egg_output),
|
|
||||||
'bitmessagemain.py') + "\n")
|
|
||||||
os.chmod(os.path.join(dist.command_obj['install_scripts'].install_dir, 'bitmessage'), 0555)
|
|
||||||
|
|
|
@ -9,17 +9,22 @@
|
||||||
|
|
||||||
# The software version variable is now held in shared.py
|
# The software version variable is now held in shared.py
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
app_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
os.chdir(app_dir)
|
||||||
|
sys.path.insert(0, app_dir)
|
||||||
|
|
||||||
import depends
|
import depends
|
||||||
depends.check_dependencies()
|
depends.check_dependencies()
|
||||||
|
|
||||||
import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
|
import signal # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
|
||||||
# The next 3 are used for the API
|
# The next 3 are used for the API
|
||||||
from singleinstance import singleinstance
|
from singleinstance import singleinstance
|
||||||
import os
|
|
||||||
import socket
|
import socket
|
||||||
import ctypes
|
import ctypes
|
||||||
from struct import pack
|
from struct import pack
|
||||||
import sys
|
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -28,7 +33,6 @@ from helper_startup import isOurOperatingSystemLimitedToHavingVeryFewHalfOpenCon
|
||||||
|
|
||||||
import defaults
|
import defaults
|
||||||
import shared
|
import shared
|
||||||
from helper_sql import sqlQuery
|
|
||||||
import knownnodes
|
import knownnodes
|
||||||
import state
|
import state
|
||||||
import shutdown
|
import shutdown
|
||||||
|
@ -45,13 +49,13 @@ from class_addressGenerator import addressGenerator
|
||||||
from class_smtpDeliver import smtpDeliver
|
from class_smtpDeliver import smtpDeliver
|
||||||
from class_smtpServer import smtpServer
|
from class_smtpServer import smtpServer
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from debug import logger
|
|
||||||
|
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
import helper_bootstrap
|
import helper_bootstrap
|
||||||
import helper_generic
|
import helper_generic
|
||||||
from helper_threading import *
|
from helper_threading import *
|
||||||
|
|
||||||
|
|
||||||
def connectToStream(streamNumber):
|
def connectToStream(streamNumber):
|
||||||
state.streamsInWhichIAmParticipating.append(streamNumber)
|
state.streamsInWhichIAmParticipating.append(streamNumber)
|
||||||
selfInitiatedConnections[streamNumber] = {}
|
selfInitiatedConnections[streamNumber] = {}
|
||||||
|
@ -309,9 +313,14 @@ class Main:
|
||||||
port = BMConfigParser().getint('bitmessagesettings', 'apiport')
|
port = BMConfigParser().getint('bitmessagesettings', 'apiport')
|
||||||
return {'address':address,'port':port}
|
return {'address':address,'port':port}
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
def main():
|
||||||
mainprogram = Main()
|
mainprogram = Main()
|
||||||
mainprogram.start(BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon'))
|
mainprogram.start(
|
||||||
|
BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon'))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
# So far, the creation of and management of the Bitmessage protocol and this
|
# So far, the creation of and management of the Bitmessage protocol and this
|
||||||
|
|
11
src/pybitmessage
Normal file
11
src/pybitmessage
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/python2.7
|
||||||
|
|
||||||
|
import os
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
dist = pkg_resources.get_distribution('pybitmessage')
|
||||||
|
script_file = os.path.join(dist.location, dist.key, 'bitmessagemain.py')
|
||||||
|
new_globals = globals()
|
||||||
|
new_globals.update(__file__=script_file)
|
||||||
|
|
||||||
|
execfile(script_file, new_globals)
|
Reference in New Issue
Block a user