1
1
#!/usr/bin/env python
2
2
3
+ import sys
4
+ if sys .version_info [0 ] != 2 or sys .version_info [1 ] not in (6 , 7 ):
5
+ sys .stdout .write ("Please use either Python 2.6 or 2.7\n " )
6
+ sys .exit (1 )
7
+
3
8
import errno
4
9
import optparse
5
10
import os
6
11
import pprint
7
12
import re
8
13
import shlex
9
14
import subprocess
10
- import sys
11
15
import shutil
12
16
import string
13
17
@@ -488,7 +492,7 @@ def pkg_config(pkg):
488
492
shlex .split (pkg_config ) + ['--silence-errors' , flag , pkg ],
489
493
stdout = subprocess .PIPE )
490
494
val = proc .communicate ()[0 ].strip ()
491
- except OSError , e :
495
+ except OSError as e :
492
496
if e .errno != errno .ENOENT : raise e # Unexpected error.
493
497
return (None , None , None ) # No pkg-config/pkgconf installed.
494
498
retval += (val ,)
@@ -524,12 +528,12 @@ def get_version_helper(cc, regexp):
524
528
proc = subprocess .Popen (shlex .split (cc ) + ['-v' ], stdin = subprocess .PIPE ,
525
529
stderr = subprocess .PIPE , stdout = subprocess .PIPE )
526
530
except OSError :
527
- print '''Node.js configure error: No acceptable C compiler found!
531
+ print ( '''Node.js configure error: No acceptable C compiler found!
528
532
529
533
Please make sure you have a C compiler installed on your system and/or
530
534
consider adjusting the CC environment variable if you installed
531
535
it in a non-standard prefix.
532
- '''
536
+ ''' )
533
537
sys .exit ()
534
538
535
539
match = re .search (regexp , proc .communicate ()[1 ])
@@ -555,12 +559,12 @@ def get_gas_version(cc):
555
559
stdin = subprocess .PIPE , stderr = subprocess .PIPE ,
556
560
stdout = subprocess .PIPE )
557
561
except OSError :
558
- print '''Node.js configure error: No acceptable C compiler found!
562
+ print ( '''Node.js configure error: No acceptable C compiler found!
559
563
560
564
Please make sure you have a C compiler installed on your system and/or
561
565
consider adjusting the CC environment variable if you installed
562
566
it in a non-standard prefix.
563
- '''
567
+ ''' )
564
568
sys .exit ()
565
569
566
570
match = re .match (r"GNU assembler version ([2-9]\.[0-9]+)" ,
@@ -615,12 +619,12 @@ def cc_macros(cc=None):
615
619
stdout = subprocess .PIPE ,
616
620
stderr = subprocess .PIPE )
617
621
except OSError :
618
- print '''Node.js configure error: No acceptable C compiler found!
622
+ print ( '''Node.js configure error: No acceptable C compiler found!
619
623
620
624
Please make sure you have a C compiler installed on your system and/or
621
625
consider adjusting the CC environment variable if you installed
622
626
it in a non-standard prefix.
623
- '''
627
+ ''' )
624
628
sys .exit ()
625
629
626
630
p .stdin .write ('\n ' )
@@ -956,7 +960,7 @@ def configure_static(o):
956
960
957
961
def write (filename , data ):
958
962
filename = os .path .join (root_dir , filename )
959
- print 'creating ' , filename
963
+ print ( 'creating %s' % filename )
960
964
f = open (filename , 'w+' )
961
965
f .write (data )
962
966
@@ -976,7 +980,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
976
980
patchfile = '%s/%s/%s' % (dir_base , patch_dir , file )
977
981
if os .path .isfile (patchfile ):
978
982
srcfile = '%s/%s' % (patch_dir , file )
979
- print 'Using version-specific floating patch %s' % patchfile
983
+ print ( 'Using version-specific floating patch %s' % patchfile )
980
984
list .append (srcfile )
981
985
break
982
986
return list
@@ -991,8 +995,8 @@ def configure_intl(o):
991
995
def icu_download (path ):
992
996
# download ICU, if needed
993
997
if not os .access (options .download_path , os .W_OK ):
994
- print 'Error: cannot write to desired download path. ' \
995
- 'Either create it or verify permissions.'
998
+ print ( 'Error: cannot write to desired download path. ' \
999
+ 'Either create it or verify permissions.' )
996
1000
sys .exit (1 )
997
1001
for icu in icus :
998
1002
url = icu ['url' ]
@@ -1003,16 +1007,16 @@ def configure_intl(o):
1003
1007
if nodedownload .candownload (auto_downloads , "icu" ):
1004
1008
nodedownload .retrievefile (url , targetfile )
1005
1009
else :
1006
- print ' Re-using existing %s' % targetfile
1010
+ print ( ' Re-using existing %s' % targetfile )
1007
1011
if os .path .isfile (targetfile ):
1008
1012
sys .stdout .write (' Checking file integrity with MD5:\r ' )
1009
1013
gotmd5 = nodedownload .md5sum (targetfile )
1010
- print ' MD5: %s %s' % (gotmd5 , targetfile )
1014
+ print ( ' MD5: %s %s' % (gotmd5 , targetfile ) )
1011
1015
if (md5 == gotmd5 ):
1012
1016
return targetfile
1013
1017
else :
1014
- print ' Expected: %s *MISMATCH*' % md5
1015
- print '\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile
1018
+ print ( ' Expected: %s *MISMATCH*' % md5 )
1019
+ print ( '\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile )
1016
1020
return None
1017
1021
icu_config = {
1018
1022
'variables' : {}
@@ -1032,7 +1036,7 @@ def configure_intl(o):
1032
1036
with_icu_source = options .with_icu_source
1033
1037
have_icu_path = bool (options .with_icu_path )
1034
1038
if have_icu_path and with_intl != 'none' :
1035
- print 'Error: Cannot specify both --with-icu-path and --with-intl'
1039
+ print ( 'Error: Cannot specify both --with-icu-path and --with-intl' )
1036
1040
sys .exit (1 )
1037
1041
elif have_icu_path :
1038
1042
# Chromium .gyp mode: --with-icu-path
@@ -1061,8 +1065,8 @@ def configure_intl(o):
1061
1065
o ['variables' ]['v8_enable_i18n_support' ] = 1
1062
1066
pkgicu = pkg_config ('icu-i18n' )
1063
1067
if pkgicu [0 ] is None :
1064
- print 'Error: could not load pkg-config data for "icu-i18n".'
1065
- print 'See above errors or the README.md.'
1068
+ print ( 'Error: could not load pkg-config data for "icu-i18n".' )
1069
+ print ( 'See above errors or the README.md.' )
1066
1070
sys .exit (1 )
1067
1071
(libs , cflags , libpath ) = pkgicu
1068
1072
# libpath provides linker path which may contain spaces
@@ -1115,17 +1119,17 @@ def configure_intl(o):
1115
1119
# --with-icu-source processing
1116
1120
# now, check that they didn't pass --with-icu-source=deps/icu
1117
1121
elif with_icu_source and os .path .abspath (icu_full_path ) == os .path .abspath (with_icu_source ):
1118
- print 'Ignoring redundant --with-icu-source=%s' % ( with_icu_source )
1122
+ print ( 'Ignoring redundant --with-icu-source=%s' % with_icu_source )
1119
1123
with_icu_source = None
1120
1124
# if with_icu_source is still set, try to use it.
1121
1125
if with_icu_source :
1122
1126
if os .path .isdir (icu_full_path ):
1123
- print 'Deleting old ICU source: %s' % ( icu_full_path )
1127
+ print ( 'Deleting old ICU source: %s' % icu_full_path )
1124
1128
shutil .rmtree (icu_full_path )
1125
1129
# now, what path was given?
1126
1130
if os .path .isdir (with_icu_source ):
1127
1131
# it's a path. Copy it.
1128
- print '%s -> %s' % (with_icu_source , icu_full_path )
1132
+ print ( '%s -> %s' % (with_icu_source , icu_full_path ) )
1129
1133
shutil .copytree (with_icu_source , icu_full_path )
1130
1134
else :
1131
1135
# could be file or URL.
@@ -1149,7 +1153,8 @@ def configure_intl(o):
1149
1153
os .rename (tmp_icu , icu_full_path )
1150
1154
shutil .rmtree (icu_tmp_path )
1151
1155
else :
1152
- print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
1156
+ print (' Error: --with-icu-source=%s did not result in an "icu" dir.' % \
1157
+ with_icu_source )
1153
1158
shutil .rmtree (icu_tmp_path )
1154
1159
sys .exit (1 )
1155
1160
@@ -1158,22 +1163,22 @@ def configure_intl(o):
1158
1163
# ICU source dir relative to tools/icu (for .gyp file)
1159
1164
o ['variables' ]['icu_path' ] = icu_full_path
1160
1165
if not os .path .isdir (icu_full_path ):
1161
- print '* ECMA-402 (Intl) support didn\' t find ICU in %s..' % ( icu_full_path )
1166
+ print ( '* ECMA-402 (Intl) support didn\' t find ICU in %s..' % icu_full_path )
1162
1167
# can we download (or find) a zipfile?
1163
1168
localzip = icu_download (icu_full_path )
1164
1169
if localzip :
1165
1170
nodedownload .unpack (localzip , icu_parent_path )
1166
1171
if not os .path .isdir (icu_full_path ):
1167
- print ' Cannot build Intl without ICU in %s.' % ( icu_full_path )
1168
- print ' (Fix, or disable with "--with-intl=none" )'
1172
+ print ( ' Cannot build Intl without ICU in %s.' % icu_full_path )
1173
+ print ( ' (Fix, or disable with "--with-intl=none" )' )
1169
1174
sys .exit (1 )
1170
1175
else :
1171
- print '* Using ICU in %s' % ( icu_full_path )
1176
+ print ( '* Using ICU in %s' % icu_full_path )
1172
1177
# Now, what version of ICU is it? We just need the "major", such as 54.
1173
1178
# uvernum.h contains it as a #define.
1174
1179
uvernum_h = os .path .join (icu_full_path , 'source/common/unicode/uvernum.h' )
1175
1180
if not os .path .isfile (uvernum_h ):
1176
- print ' Error: could not load %s - is ICU installed?' % uvernum_h
1181
+ print ( ' Error: could not load %s - is ICU installed?' % uvernum_h )
1177
1182
sys .exit (1 )
1178
1183
icu_ver_major = None
1179
1184
matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
@@ -1183,7 +1188,7 @@ def configure_intl(o):
1183
1188
if m :
1184
1189
icu_ver_major = m .group (1 )
1185
1190
if not icu_ver_major :
1186
- print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
1191
+ print ( ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h )
1187
1192
sys .exit (1 )
1188
1193
icu_endianness = sys .byteorder [0 ];
1189
1194
o ['variables' ]['icu_ver_major' ] = icu_ver_major
@@ -1210,8 +1215,8 @@ def configure_intl(o):
1210
1215
# this is the icudt*.dat file which node will be using (platform endianness)
1211
1216
o ['variables' ]['icu_data_file' ] = icu_data_file
1212
1217
if not os .path .isfile (icu_data_path ):
1213
- print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
1214
- print ' See the README.md.'
1218
+ print ( ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path )
1219
+ print ( ' See the README.md.' )
1215
1220
# .. and we're not about to build it from .gyp!
1216
1221
sys .exit (1 )
1217
1222
# map from variable name to subdirs
0 commit comments