-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure-tests.py
496 lines (466 loc) · 18.4 KB
/
configure-tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
## This file is part of Invenio.
## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""
Test the suitability of Python core and the availability of various
Python modules for running Invenio. Warn the user if there are
eventual troubles. Exit status: 0 if okay, 1 if not okay. Useful for
running from configure.ac.
"""
## minimally recommended/required versions:
cfg_min_python_version = "2.4"
cfg_max_python_version = "2.9.9999"
cfg_min_mysqldb_version = "1.2.1_p2"
## 0) import modules needed for this testing:
import string
import sys
import getpass
import subprocess
import re
error_messages = []
warning_messages = []
def wait_for_user(msg):
"""Print MSG and prompt user for confirmation."""
try:
raw_input(msg)
except KeyboardInterrupt:
print "\n\nInstallation aborted."
sys.exit(1)
except EOFError:
print " (continuing in batch mode)"
return
## 1) check Python version:
if sys.version < cfg_min_python_version:
error_messages.append(
"""
*******************************************************
** ERROR: TOO OLD PYTHON DETECTED: %s
*******************************************************
** You seem to be using a too old version of Python. **
** You must use at least Python %s. **
** **
** Note that if you have more than one Python **
** installed on your system, you can specify the **
** --with-python configuration option to choose **
** a specific (e.g. non system wide) Python binary. **
** **
** Please upgrade your Python before continuing. **
*******************************************************
""" % (string.replace(sys.version, "\n", ""), cfg_min_python_version)
)
if sys.version > cfg_max_python_version:
error_messages.append(
"""
*******************************************************
** ERROR: TOO NEW PYTHON DETECTED: %s
*******************************************************
** You seem to be using a too new version of Python. **
** You must use at most Python %s. **
** **
** Perhaps you have downloaded and are installing an **
** old Invenio version? Please look for more recent **
** Invenio version or please contact the development **
** team at <[email protected]> about this **
** problem. **
** **
** Installation aborted. **
*******************************************************
""" % (string.replace(sys.version, "\n", ""), cfg_max_python_version)
)
## 2) check for required modules:
try:
import MySQLdb
import base64
import cPickle
import cStringIO
import cgi
import copy
import fileinput
import getopt
import sys
if sys.hexversion < 0x2060000:
import md5
else:
import hashlib
import marshal
import os
import signal
import tempfile
import time
import traceback
import unicodedata
import urllib
import zlib
import wsgiref
except ImportError, msg:
error_messages.append("""
*************************************************
** IMPORT ERROR %s
*************************************************
** Perhaps you forgot to install some of the **
** prerequisite Python modules? Please look **
** at our INSTALL file for more details and **
** fix the problem before continuing! **
*************************************************
""" % msg
)
## 3) check for recommended modules:
try:
if (2**31 - 1) == sys.maxint:
# check for Psyco since we seem to run in 32-bit environment
import psyco
else:
# no need to advise on Psyco on 64-bit systems
pass
except ImportError, msg:
warning_messages.append("""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that Psyco is not really required but we **
** recommend it for faster Invenio operation **
** if you are running in 32-bit operating system. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import rdflib
except ImportError, msg:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that rdflib is needed only if you plan **
** to work with the automatic classification of **
** documents based on RDF-based taxonomies. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import pyRXP
except ImportError, msg:
warning_messages.append("""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that PyRXP is not really required but **
** we recommend it for fast XML MARC parsing. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import dateutil
except ImportError, msg:
warning_messages.append("""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that dateutil is not really required but **
** we recommend it for user-friendly date **
** parsing. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import libxml2
except ImportError, msg:
warning_messages.append("""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that libxml2 is not really required but **
** we recommend it for XML metadata conversions **
** and for fast XML parsing. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import libxslt
except ImportError, msg:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that libxslt is not really required but **
** we recommend it for XML metadata conversions. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import Gnuplot
except ImportError, msg:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that Gnuplot.py is not really required but **
** we recommend it in order to have nice download **
** and citation history graphs on Detailed record **
** pages. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import magic
if not hasattr(magic, "open"):
raise StandardError
except ImportError, msg:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that magic module is not really required **
** but we recommend it in order to have detailed **
** content information about fulltext files. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
except StandardError:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING python-magic
*****************************************************
** The python-magic package you installed is not **
** the one supported by Invenio. Please refer to **
** the INSTALL file for more details. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
"""
)
try:
import reportlab
except ImportError, msg:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that reportlab module is not really **
** required, but we recommend it you want to **
** enrich PDF with OCR information. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
try:
import pyPdf
except ImportError, msg:
warning_messages.append(
"""
*****************************************************
** IMPORT WARNING %s
*****************************************************
** Note that pyPdf module is not really **
** required, but we recommend it you want to **
** enrich PDF with OCR information. **
** **
** You can safely continue installing Invenio **
** now, and add this module anytime later. (I.e. **
** even after your Invenio installation is put **
** into production.) **
*****************************************************
""" % msg
)
## 4) check for versions of some important modules:
if MySQLdb.__version__ < cfg_min_mysqldb_version:
error_messages.append(
"""
*****************************************************
** ERROR: PYTHON MODULE MYSQLDB %s DETECTED
*****************************************************
** You have to upgrade your MySQLdb to at least **
** version %s. You must fix this problem **
** before continuing. Please see the INSTALL file **
** for more details. **
*****************************************************
""" % (MySQLdb.__version__, cfg_min_mysqldb_version)
)
try:
import Stemmer
try:
from Stemmer import algorithms
except ImportError, msg:
error_messages.append(
"""
*****************************************************
** ERROR: STEMMER MODULE PROBLEM %s
*****************************************************
** Perhaps you are using an old Stemmer version? **
** You must either remove your old Stemmer or else **
** upgrade to Snowball Stemmer
** <http://snowball.tartarus.org/wrappers/PyStemmer-1.0.1.tar.gz>
** before continuing. Please see the INSTALL file **
** for more details. **
*****************************************************
""" % (msg)
)
except ImportError:
pass # no prob, Stemmer is optional
## 5) check for Python.h (needed for intbitset):
try:
from distutils.sysconfig import get_python_inc
path_to_python_h = get_python_inc() + os.sep + 'Python.h'
if not os.path.exists(path_to_python_h):
raise StandardError, "Cannot find %s" % path_to_python_h
except StandardError, msg:
error_messages.append(
"""
*****************************************************
** ERROR: PYTHON HEADER FILE ERROR %s
*****************************************************
** You do not seem to have Python developer files **
** installed (such as Python.h). Some operating **
** systems provide these in a separate Python **
** package called python-dev or python-devel. **
** You must install such a package before **
** continuing the installation process. **
*****************************************************
""" % (msg)
)
## Check if ffmpeg is installed and if so, with the minimum configuration for bibencode
try:
try:
process = subprocess.Popen('ffprobe', stderr=subprocess.PIPE, stdout=subprocess.PIPE)
except OSError:
raise StandardError, "FFMPEG/FFPROBE does not seem to be installed!"
returncode = process.wait()
output = process.communicate()[1]
RE_CONFIGURATION = re.compile("(--enable-[a-z0-9\-]*)")
CONFIGURATION_REQUIRED = (
'--enable-gpl',
'--enable-version3',
'--enable-nonfree',
'--enable-libtheora',
'--enable-libvorbis',
'--enable-libvpx',
'--enable-libopenjpeg'
)
options = RE_CONFIGURATION.findall(output)
if sys.version_info < (2, 6):
import sets
s = sets.Set(CONFIGURATION_REQUIRED)
if not s.issubset(options):
raise StandardError, options.difference(s)
else:
if not set(CONFIGURATION_REQUIRED).issubset(options):
raise StandardError, set(CONFIGURATION_REQUIRED).difference(options)
except StandardError, msg:
warning_messages.append(
"""
*****************************************************
** WARNING: FFMPEG CONFIGURATION MISSING %s
*****************************************************
** You do not seem to have FFmpeg configured with **
** the minimum video codecs to run the demo site. **
** Please install the necessary libraries and **
** re-install FFmpeg according to the Invenio **
** installation manual (INSTALL). **
*****************************************************
""" % (msg)
)
if warning_messages:
print """
******************************************************
** WARNING MESSAGES **
******************************************************
"""
for warning in warning_messages:
print warning
if error_messages:
print """
******************************************************
** ERROR MESSAGES **
******************************************************
"""
for error in error_messages:
print error
if warning_messages and error_messages:
print """
There were %(n_err)s error(s) found that you need to solve.
Please see above, solve them, and re-run configure.
Note that there are also %(n_wrn)s warnings you may want
to look into. Aborting the installation.
""" % {'n_wrn': len(warning_messages),
'n_err': len(error_messages)}
sys.exit(1)
elif error_messages:
print """
There were %(n_err)s error(s) found that you need to solve.
Please see above, solve them, and re-run configure.
Aborting the installation.
""" % {'n_err': len(error_messages)}
sys.exit(1)
elif warning_messages:
print """
There were %(n_wrn)s warnings found that you may want to
look into, solve, and re-run configure before you
continue the installation. However, you can also continue
the installation now and solve these issues later, if you wish.
""" % {'n_wrn': len(warning_messages)}
wait_for_user("Press ENTER to continue the installation...")