24
24
}
25
25
26
26
packageName = {
27
- "PyQt " : {
27
+ "PyQt4 " : {
28
28
"OpenBSD" : "py-qt4" ,
29
29
"FreeBSD" : "py27-qt4" ,
30
30
"Debian" : "python-qt4" ,
31
31
"Ubuntu" : "python-qt4" ,
32
32
"openSUSE" : "python-qt" ,
33
33
"Fedora" : "PyQt4" ,
34
34
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."
36
41
},
37
42
"msgpack" : {
38
43
"OpenBSD" : "py-msgpack" ,
49
54
"Debian" : "python-pyopencl" ,
50
55
"Ubuntu" : "python-pyopencl" ,
51
56
"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" : "" ,
53
75
}
54
76
}
55
77
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
+
56
85
57
86
def detectOS ():
58
87
if detectOS .result is not None :
@@ -87,27 +116,14 @@ def detectOS():
87
116
88
117
def detectPrereqs (missing = False ):
89
118
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 )
111
127
return available
112
128
113
129
@@ -116,27 +132,40 @@ def prereqToPackages():
116
132
print "%s %s" % (
117
133
packageManager [detectOS ()], " " .join (
118
134
packageName [x ][detectOS ()] for x in detectPrereqs (True )))
135
+ for package in detectPrereqs (True ):
136
+ if packageName [package ]['optional' ]:
137
+ print packageName [package ]['description' ]
119
138
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 ()])
120
145
121
146
if __name__ == "__main__" :
122
147
detectOS .result = None
123
148
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."
129
149
if detectPrereqs (True ) != [] and detectOS () in packageManager :
130
150
if detectOS () is not None :
131
151
print "It looks like you're using %s. " \
132
152
"It is highly recommended to use the package manager " \
133
153
"instead of setuptools." % (detectOS ())
134
154
prereqToPackages ()
135
- sys .exit ()
155
+ for module in detectPrereqs (True ):
156
+ if not packageName [module ]['optional' ]:
157
+ sys .exit ()
136
158
if not haveSetuptools :
137
159
print "It looks like you're missing setuptools."
138
160
sys .exit ()
139
161
162
+ if detectPrereqs (True ) != []:
163
+ print "Press Return to continue"
164
+ try :
165
+ nothing = raw_input
166
+ except NameError :
167
+ pass
168
+
140
169
here = os .path .abspath (os .path .dirname (__file__ ))
141
170
with open (os .path .join (here , 'README.md' )) as f :
142
171
README = f .read ()
@@ -147,49 +176,55 @@ def prereqToPackages():
147
176
libraries = ['pthread' , 'crypto' ],
148
177
)
149
178
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