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 ' )
@@ -955,7 +959,7 @@ def configure_static(o):
955
959
956
960
def write (filename , data ):
957
961
filename = os .path .join (root_dir , filename )
958
- print 'creating ' , filename
962
+ print ( 'creating %s' % filename )
959
963
f = open (filename , 'w+' )
960
964
f .write (data )
961
965
@@ -975,7 +979,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
975
979
patchfile = '%s/%s/%s' % (dir_base , patch_dir , file )
976
980
if os .path .isfile (patchfile ):
977
981
srcfile = '%s/%s' % (patch_dir , file )
978
- print 'Using version-specific floating patch %s' % patchfile
982
+ print ( 'Using version-specific floating patch %s' % patchfile )
979
983
list .append (srcfile )
980
984
break
981
985
return list
@@ -990,8 +994,8 @@ def configure_intl(o):
990
994
def icu_download (path ):
991
995
# download ICU, if needed
992
996
if not os .access (options .download_path , os .W_OK ):
993
- print 'Error: cannot write to desired download path. ' \
994
- 'Either create it or verify permissions.'
997
+ print ( 'Error: cannot write to desired download path. ' \
998
+ 'Either create it or verify permissions.' )
995
999
sys .exit (1 )
996
1000
for icu in icus :
997
1001
url = icu ['url' ]
@@ -1002,16 +1006,16 @@ def configure_intl(o):
1002
1006
if nodedownload .candownload (auto_downloads , "icu" ):
1003
1007
nodedownload .retrievefile (url , targetfile )
1004
1008
else :
1005
- print ' Re-using existing %s' % targetfile
1009
+ print ( ' Re-using existing %s' % targetfile )
1006
1010
if os .path .isfile (targetfile ):
1007
1011
sys .stdout .write (' Checking file integrity with MD5:\r ' )
1008
1012
gotmd5 = nodedownload .md5sum (targetfile )
1009
- print ' MD5: %s %s' % (gotmd5 , targetfile )
1013
+ print ( ' MD5: %s %s' % (gotmd5 , targetfile ) )
1010
1014
if (md5 == gotmd5 ):
1011
1015
return targetfile
1012
1016
else :
1013
- print ' Expected: %s *MISMATCH*' % md5
1014
- print '\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile
1017
+ print ( ' Expected: %s *MISMATCH*' % md5 )
1018
+ print ( '\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile )
1015
1019
return None
1016
1020
icu_config = {
1017
1021
'variables' : {}
@@ -1031,7 +1035,7 @@ def configure_intl(o):
1031
1035
with_icu_source = options .with_icu_source
1032
1036
have_icu_path = bool (options .with_icu_path )
1033
1037
if have_icu_path and with_intl != 'none' :
1034
- print 'Error: Cannot specify both --with-icu-path and --with-intl'
1038
+ print ( 'Error: Cannot specify both --with-icu-path and --with-intl' )
1035
1039
sys .exit (1 )
1036
1040
elif have_icu_path :
1037
1041
# Chromium .gyp mode: --with-icu-path
@@ -1060,8 +1064,8 @@ def configure_intl(o):
1060
1064
o ['variables' ]['v8_enable_i18n_support' ] = 1
1061
1065
pkgicu = pkg_config ('icu-i18n' )
1062
1066
if pkgicu [0 ] is None :
1063
- print 'Error: could not load pkg-config data for "icu-i18n".'
1064
- print 'See above errors or the README.md.'
1067
+ print ( 'Error: could not load pkg-config data for "icu-i18n".' )
1068
+ print ( 'See above errors or the README.md.' )
1065
1069
sys .exit (1 )
1066
1070
(libs , cflags , libpath ) = pkgicu
1067
1071
# libpath provides linker path which may contain spaces
@@ -1114,17 +1118,17 @@ def configure_intl(o):
1114
1118
# --with-icu-source processing
1115
1119
# now, check that they didn't pass --with-icu-source=deps/icu
1116
1120
elif with_icu_source and os .path .abspath (icu_full_path ) == os .path .abspath (with_icu_source ):
1117
- print 'Ignoring redundant --with-icu-source=%s' % ( with_icu_source )
1121
+ print ( 'Ignoring redundant --with-icu-source=%s' % with_icu_source )
1118
1122
with_icu_source = None
1119
1123
# if with_icu_source is still set, try to use it.
1120
1124
if with_icu_source :
1121
1125
if os .path .isdir (icu_full_path ):
1122
- print 'Deleting old ICU source: %s' % ( icu_full_path )
1126
+ print ( 'Deleting old ICU source: %s' % icu_full_path )
1123
1127
shutil .rmtree (icu_full_path )
1124
1128
# now, what path was given?
1125
1129
if os .path .isdir (with_icu_source ):
1126
1130
# it's a path. Copy it.
1127
- print '%s -> %s' % (with_icu_source , icu_full_path )
1131
+ print ( '%s -> %s' % (with_icu_source , icu_full_path ) )
1128
1132
shutil .copytree (with_icu_source , icu_full_path )
1129
1133
else :
1130
1134
# could be file or URL.
@@ -1148,7 +1152,8 @@ def configure_intl(o):
1148
1152
os .rename (tmp_icu , icu_full_path )
1149
1153
shutil .rmtree (icu_tmp_path )
1150
1154
else :
1151
- print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
1155
+ print (' Error: --with-icu-source=%s did not result in an "icu" dir.' % \
1156
+ with_icu_source )
1152
1157
shutil .rmtree (icu_tmp_path )
1153
1158
sys .exit (1 )
1154
1159
@@ -1157,22 +1162,22 @@ def configure_intl(o):
1157
1162
# ICU source dir relative to tools/icu (for .gyp file)
1158
1163
o ['variables' ]['icu_path' ] = icu_full_path
1159
1164
if not os .path .isdir (icu_full_path ):
1160
- print '* ECMA-402 (Intl) support didn\' t find ICU in %s..' % ( icu_full_path )
1165
+ print ( '* ECMA-402 (Intl) support didn\' t find ICU in %s..' % icu_full_path )
1161
1166
# can we download (or find) a zipfile?
1162
1167
localzip = icu_download (icu_full_path )
1163
1168
if localzip :
1164
1169
nodedownload .unpack (localzip , icu_parent_path )
1165
1170
if not os .path .isdir (icu_full_path ):
1166
- print ' Cannot build Intl without ICU in %s.' % ( icu_full_path )
1167
- print ' (Fix, or disable with "--with-intl=none" )'
1171
+ print ( ' Cannot build Intl without ICU in %s.' % icu_full_path )
1172
+ print ( ' (Fix, or disable with "--with-intl=none" )' )
1168
1173
sys .exit (1 )
1169
1174
else :
1170
- print '* Using ICU in %s' % ( icu_full_path )
1175
+ print ( '* Using ICU in %s' % icu_full_path )
1171
1176
# Now, what version of ICU is it? We just need the "major", such as 54.
1172
1177
# uvernum.h contains it as a #define.
1173
1178
uvernum_h = os .path .join (icu_full_path , 'source/common/unicode/uvernum.h' )
1174
1179
if not os .path .isfile (uvernum_h ):
1175
- print ' Error: could not load %s - is ICU installed?' % uvernum_h
1180
+ print ( ' Error: could not load %s - is ICU installed?' % uvernum_h )
1176
1181
sys .exit (1 )
1177
1182
icu_ver_major = None
1178
1183
matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
@@ -1182,7 +1187,7 @@ def configure_intl(o):
1182
1187
if m :
1183
1188
icu_ver_major = m .group (1 )
1184
1189
if not icu_ver_major :
1185
- print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
1190
+ print ( ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h )
1186
1191
sys .exit (1 )
1187
1192
icu_endianness = sys .byteorder [0 ];
1188
1193
o ['variables' ]['icu_ver_major' ] = icu_ver_major
@@ -1209,8 +1214,8 @@ def configure_intl(o):
1209
1214
# this is the icudt*.dat file which node will be using (platform endianness)
1210
1215
o ['variables' ]['icu_data_file' ] = icu_data_file
1211
1216
if not os .path .isfile (icu_data_path ):
1212
- print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
1213
- print ' See the README.md.'
1217
+ print ( ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path )
1218
+ print ( ' See the README.md.' )
1214
1219
# .. and we're not about to build it from .gyp!
1215
1220
sys .exit (1 )
1216
1221
# map from variable name to subdirs
0 commit comments