2424}
2525
2626packageName = {
27- "PyQt " : {
27+ "PyQt4 " : {
2828 "OpenBSD" : "py-qt4" ,
2929 "FreeBSD" : "py27-qt4" ,
3030 "Debian" : "python-qt4" ,
3131 "Ubuntu" : "python-qt4" ,
3232 "openSUSE" : "python-qt" ,
3333 "Fedora" : "PyQt4" ,
3434 "Guix" : "python2-pyqt@4.11.4" ,
35- "Gentoo" : "dev-python/PyQt4"
35+ "Gentoo" : "dev-python/PyQt4" ,
36+ 'optional' : True ,
37+ 'description' : "You only need PyQt if you want to use the GUI. " \
38+ "When only running as a daemon, this can be skipped.\n " \
39+ "However, you would have to install it manually " \
40+ "because setuptools does not support PyQt."
3641 },
3742 "msgpack" : {
3843 "OpenBSD" : "py-msgpack" ,
4954 "Debian" : "python-pyopencl" ,
5055 "Ubuntu" : "python-pyopencl" ,
5156 "Fedora" : "python2-pyopencl" ,
52- "Gentoo" : "dev-python/pyopencl"
57+ "openSUSE" : "" ,
58+ "OpenBSD" : "" ,
59+ "Guix" : "" ,
60+ "Gentoo" : "dev-python/pyopencl" ,
61+ "optional" : True ,
62+ 'description' : "If you install pyopencl, you will be able to use " \
63+ "GPU acceleration for proof of work. \n " \
64+ "You also need a compatible GPU and drivers."
65+ },
66+ "setuptools" : {
67+ "OpenBSD" : "py-setuptools" ,
68+ "FreeBSD" : "py27-setuptools" ,
69+ "Debian" : "python-setuptools" ,
70+ "Ubuntu" : "python-setuptools" ,
71+ "Fedora" : "python2-setuptools" ,
72+ "openSUSE" : "python-setuptools" ,
73+ "Guix" : "python2-setuptools" ,
74+ "Gentoo" : "" ,
5375 }
5476}
5577
78+ compiling = {
79+ "Debian" : "build-essential libssl-dev" ,
80+ "Ubuntu" : "build-essential libssl-dev" ,
81+ "Fedora" : "gcc-c++ redhat-rpm-config python-devel" ,
82+ "openSUSE" : "gcc-c++ libopenssl-devel python-devel" ,
83+ }
84+
5685
5786def detectOS ():
5887 if detectOS .result is not None :
@@ -87,27 +116,14 @@ def detectOS():
87116
88117def detectPrereqs (missing = False ):
89118 available = []
90- try :
91- import_module ("PyQt4.QtCore" )
92- if not missing :
93- available .append ("PyQt" )
94- except ImportError :
95- if missing :
96- available .append ("PyQt" )
97- try :
98- import_module ("msgpack" )
99- if not missing :
100- available .append ("msgpack" )
101- except ImportError :
102- if missing :
103- available .append ("msgpack" )
104- try :
105- import_module ("pyopencl" )
106- if not missing :
107- available .append ("pyopencl" )
108- except ImportError :
109- if missing :
110- available .append ("pyopencl" )
119+ for module in packageName .keys ():
120+ try :
121+ import_module (module )
122+ if not missing :
123+ available .append (module )
124+ except ImportError :
125+ if missing :
126+ available .append (module )
111127 return available
112128
113129
@@ -116,27 +132,40 @@ def prereqToPackages():
116132 print "%s %s" % (
117133 packageManager [detectOS ()], " " .join (
118134 packageName [x ][detectOS ()] for x in detectPrereqs (True )))
135+ for package in detectPrereqs (True ):
136+ if packageName [package ]['optional' ]:
137+ print packageName [package ]['description' ]
119138
139+ def compilerToPackages ():
140+ if not detectOS () in compiling :
141+ return
142+ print "You can install the requirements by running, as root:"
143+ print "%s %s" % (
144+ packageManager [detectOS ()], compiling [detectOS ()])
120145
121146if __name__ == "__main__" :
122147 detectOS .result = None
123148 detectPrereqs .result = None
124- if "PyQt" in detectPrereqs (True ):
125- print "You only need PyQt if you want to use the GUI. " \
126- "When only running as a daemon, this can be skipped.\n " \
127- "However, you would have to install it manually " \
128- "because setuptools does not support pyqt."
129149 if detectPrereqs (True ) != [] and detectOS () in packageManager :
130150 if detectOS () is not None :
131151 print "It looks like you're using %s. " \
132152 "It is highly recommended to use the package manager " \
133153 "instead of setuptools." % (detectOS ())
134154 prereqToPackages ()
135- sys .exit ()
155+ for module in detectPrereqs (True ):
156+ if not packageName [module ]['optional' ]:
157+ sys .exit ()
136158 if not haveSetuptools :
137159 print "It looks like you're missing setuptools."
138160 sys .exit ()
139161
162+ if detectPrereqs (True ) != []:
163+ print "Press Return to continue"
164+ try :
165+ nothing = raw_input
166+ except NameError :
167+ pass
168+
140169 here = os .path .abspath (os .path .dirname (__file__ ))
141170 with open (os .path .join (here , 'README.md' )) as f :
142171 README = f .read ()
@@ -147,49 +176,55 @@ def prereqToPackages():
147176 libraries = ['pthread' , 'crypto' ],
148177 )
149178
150- dist = setup (
151- name = 'pybitmessage' ,
152- version = softwareVersion ,
153- description = "Reference client for Bitmessage: "
154- "a P2P communications protocol" ,
155- long_description = README ,
156- license = 'MIT' ,
157- # TODO: add author info
158- #author='',
159- #author_email='',
160- url = 'https://bitmessage.org' ,
161- # TODO: add keywords
162- #keywords='',
163- install_requires = ['msgpack-python' ],
164- classifiers = [
165- "License :: OSI Approved :: MIT License"
166- "Operating System :: OS Independent" ,
167- "Programming Language :: Python :: 2.7 :: Only" ,
168- "Topic :: Internet" ,
169- "Topic :: Security :: Cryptography" ,
170- "Topic :: Software Development :: Libraries :: Python Modules" ,
171- ],
172- package_dir = {'pybitmessage' : 'src' },
173- packages = [
174- 'pybitmessage' ,
175- 'pybitmessage.bitmessageqt' ,
176- 'pybitmessage.bitmessagecurses' ,
177- 'pybitmessage.messagetypes' ,
178- 'pybitmessage.network' ,
179- 'pybitmessage.pyelliptic' ,
180- 'pybitmessage.socks' ,
181- ],
182- package_data = {'' : [
183- 'bitmessageqt/*.ui' , 'bitmsghash/*.cl' , 'sslkeys/*.pem' ,
184- 'translations/*.ts' , 'translations/*.qm' ,
185- 'images/*.png' , 'images/*.ico' , 'images/*.icns'
186- ]},
187- ext_modules = [bitmsghash ],
188- zip_safe = False ,
189- #entry_points={
190- # 'console_scripts': [
191- # 'pybitmessage = pybitmessage.bitmessagemain:main'
192- # ]
193- #},
194- scripts = ['src/pybitmessage' ]
195- )
179+ try :
180+ dist = setup (
181+ name = 'pybitmessage' ,
182+ version = softwareVersion ,
183+ description = "Reference client for Bitmessage: "
184+ "a P2P communications protocol" ,
185+ long_description = README ,
186+ license = 'MIT' ,
187+ # TODO: add author info
188+ #author='',
189+ #author_email='',
190+ url = 'https://bitmessage.org' ,
191+ # TODO: add keywords
192+ #keywords='',
193+ install_requires = ['msgpack-python' ],
194+ classifiers = [
195+ "License :: OSI Approved :: MIT License"
196+ "Operating System :: OS Independent" ,
197+ "Programming Language :: Python :: 2.7 :: Only" ,
198+ "Topic :: Internet" ,
199+ "Topic :: Security :: Cryptography" ,
200+ "Topic :: Software Development :: Libraries :: Python Modules" ,
201+ ],
202+ package_dir = {'pybitmessage' : 'src' },
203+ packages = [
204+ 'pybitmessage' ,
205+ 'pybitmessage.bitmessageqt' ,
206+ 'pybitmessage.bitmessagecurses' ,
207+ 'pybitmessage.messagetypes' ,
208+ 'pybitmessage.network' ,
209+ 'pybitmessage.pyelliptic' ,
210+ 'pybitmessage.socks' ,
211+ ],
212+ package_data = {'' : [
213+ 'bitmessageqt/*.ui' , 'bitmsghash/*.cl' , 'sslkeys/*.pem' ,
214+ 'translations/*.ts' , 'translations/*.qm' ,
215+ 'images/*.png' , 'images/*.ico' , 'images/*.icns'
216+ ]},
217+ ext_modules = [bitmsghash ],
218+ zip_safe = False ,
219+ #entry_points={
220+ # 'console_scripts': [
221+ # 'pybitmessage = pybitmessage.bitmessagemain:main'
222+ # ]
223+ #},
224+ scripts = ['src/pybitmessage' ]
225+ )
226+ except SystemExit :
227+ print "It looks like building the package failed.\n " \
228+ "You may be missing a C++ compiler and the OpenSSL headers."
229+ compilerToPackages ()
230+
0 commit comments