11#!/usr/bin/env python
22
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+
38import errno
49import optparse
510import os
611import pprint
712import re
813import shlex
914import subprocess
10- import sys
1115import shutil
1216import string
1317
@@ -448,7 +452,7 @@ def pkg_config(pkg):
448452 shlex .split (pkg_config ) + ['--silence-errors' , flag , pkg ],
449453 stdout = subprocess .PIPE )
450454 val = proc .communicate ()[0 ].strip ()
451- except OSError , e :
455+ except OSError as e :
452456 if e .errno != errno .ENOENT : raise e # Unexpected error.
453457 return (None , None , None ) # No pkg-config/pkgconf installed.
454458 retval += (val ,)
@@ -484,12 +488,12 @@ def get_version_helper(cc, regexp):
484488 proc = subprocess .Popen (shlex .split (cc ) + ['-v' ], stdin = subprocess .PIPE ,
485489 stderr = subprocess .PIPE , stdout = subprocess .PIPE )
486490 except OSError :
487- print '''Node.js configure error: No acceptable C compiler found!
491+ print ( '''Node.js configure error: No acceptable C compiler found!
488492
489493 Please make sure you have a C compiler installed on your system and/or
490494 consider adjusting the CC environment variable if you installed
491495 it in a non-standard prefix.
492- '''
496+ ''' )
493497 sys .exit ()
494498
495499 match = re .search (regexp , proc .communicate ()[1 ])
@@ -515,12 +519,12 @@ def get_gas_version(cc):
515519 stdin = subprocess .PIPE , stderr = subprocess .PIPE ,
516520 stdout = subprocess .PIPE )
517521 except OSError :
518- print '''Node.js configure error: No acceptable C compiler found!
522+ print ( '''Node.js configure error: No acceptable C compiler found!
519523
520524 Please make sure you have a C compiler installed on your system and/or
521525 consider adjusting the CC environment variable if you installed
522526 it in a non-standard prefix.
523- '''
527+ ''' )
524528 sys .exit ()
525529
526530 match = re .match (r"GNU assembler version ([2-9]\.[0-9]+)" ,
@@ -575,12 +579,12 @@ def cc_macros(cc=None):
575579 stdout = subprocess .PIPE ,
576580 stderr = subprocess .PIPE )
577581 except OSError :
578- print '''Node.js configure error: No acceptable C compiler found!
582+ print ( '''Node.js configure error: No acceptable C compiler found!
579583
580584 Please make sure you have a C compiler installed on your system and/or
581585 consider adjusting the CC environment variable if you installed
582586 it in a non-standard prefix.
583- '''
587+ ''' )
584588 sys .exit ()
585589
586590 p .stdin .write ('\n ' )
@@ -921,7 +925,7 @@ def configure_winsdk(o):
921925
922926def write (filename , data ):
923927 filename = os .path .join (root_dir , filename )
924- print 'creating ' , filename
928+ print ( 'creating %s' % filename )
925929 f = open (filename , 'w+' )
926930 f .write (data )
927931
@@ -941,7 +945,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
941945 patchfile = '%s/%s/%s' % (dir_base , patch_dir , file )
942946 if os .path .isfile (patchfile ):
943947 srcfile = '%s/%s' % (patch_dir , file )
944- print 'Using version-specific floating patch %s' % patchfile
948+ print ( 'Using version-specific floating patch %s' % patchfile )
945949 list .append (srcfile )
946950 break
947951 return list
@@ -956,8 +960,8 @@ def configure_intl(o):
956960 def icu_download (path ):
957961 # download ICU, if needed
958962 if not os .access (options .download_path , os .W_OK ):
959- print 'Error: cannot write to desired download path. ' \
960- 'Either create it or verify permissions.'
963+ print ( 'Error: cannot write to desired download path. ' \
964+ 'Either create it or verify permissions.' )
961965 sys .exit (1 )
962966 for icu in icus :
963967 url = icu ['url' ]
@@ -968,16 +972,16 @@ def configure_intl(o):
968972 if nodedownload .candownload (auto_downloads , "icu" ):
969973 nodedownload .retrievefile (url , targetfile )
970974 else :
971- print ' Re-using existing %s' % targetfile
975+ print ( ' Re-using existing %s' % targetfile )
972976 if os .path .isfile (targetfile ):
973977 sys .stdout .write (' Checking file integrity with MD5:\r ' )
974978 gotmd5 = nodedownload .md5sum (targetfile )
975- print ' MD5: %s %s' % (gotmd5 , targetfile )
979+ print ( ' MD5: %s %s' % (gotmd5 , targetfile ) )
976980 if (md5 == gotmd5 ):
977981 return targetfile
978982 else :
979- print ' Expected: %s *MISMATCH*' % md5
980- print '\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile
983+ print ( ' Expected: %s *MISMATCH*' % md5 )
984+ print ( '\n ** Corrupted ZIP? Delete %s to retry download.\n ' % targetfile )
981985 return None
982986 icu_config = {
983987 'variables' : {}
@@ -997,7 +1001,7 @@ def configure_intl(o):
9971001 with_icu_source = options .with_icu_source
9981002 have_icu_path = bool (options .with_icu_path )
9991003 if have_icu_path and with_intl != 'none' :
1000- print 'Error: Cannot specify both --with-icu-path and --with-intl'
1004+ print ( 'Error: Cannot specify both --with-icu-path and --with-intl' )
10011005 sys .exit (1 )
10021006 elif have_icu_path :
10031007 # Chromium .gyp mode: --with-icu-path
@@ -1025,8 +1029,8 @@ def configure_intl(o):
10251029 o ['variables' ]['v8_enable_i18n_support' ] = 1
10261030 pkgicu = pkg_config ('icu-i18n' )
10271031 if pkgicu [0 ] is None :
1028- print 'Error: could not load pkg-config data for "icu-i18n".'
1029- print 'See above errors or the README.md.'
1032+ print ( 'Error: could not load pkg-config data for "icu-i18n".' )
1033+ print ( 'See above errors or the README.md.' )
10301034 sys .exit (1 )
10311035 (libs , cflags , libpath ) = pkgicu
10321036 # libpath provides linker path which may contain spaces
@@ -1052,17 +1056,17 @@ def configure_intl(o):
10521056 # --with-icu-source processing
10531057 # first, check that they didn't pass --with-icu-source=deps/icu
10541058 if with_icu_source and os .path .abspath (icu_full_path ) == os .path .abspath (with_icu_source ):
1055- print 'Ignoring redundant --with-icu-source=%s' % ( with_icu_source )
1059+ print ( 'Ignoring redundant --with-icu-source=%s' % with_icu_source )
10561060 with_icu_source = None
10571061 # if with_icu_source is still set, try to use it.
10581062 if with_icu_source :
10591063 if os .path .isdir (icu_full_path ):
1060- print 'Deleting old ICU source: %s' % ( icu_full_path )
1064+ print ( 'Deleting old ICU source: %s' % icu_full_path )
10611065 shutil .rmtree (icu_full_path )
10621066 # now, what path was given?
10631067 if os .path .isdir (with_icu_source ):
10641068 # it's a path. Copy it.
1065- print '%s -> %s' % (with_icu_source , icu_full_path )
1069+ print ( '%s -> %s' % (with_icu_source , icu_full_path ) )
10661070 shutil .copytree (with_icu_source , icu_full_path )
10671071 else :
10681072 # could be file or URL.
@@ -1086,7 +1090,8 @@ def configure_intl(o):
10861090 os .rename (tmp_icu , icu_full_path )
10871091 shutil .rmtree (icu_tmp_path )
10881092 else :
1089- print ' Error: --with-icu-source=%s did not result in an "icu" dir.' % with_icu_source
1093+ print (' Error: --with-icu-source=%s did not result in an "icu" dir.' % \
1094+ with_icu_source )
10901095 shutil .rmtree (icu_tmp_path )
10911096 sys .exit (1 )
10921097
@@ -1095,22 +1100,22 @@ def configure_intl(o):
10951100 # ICU source dir relative to root
10961101 o ['variables' ]['icu_path' ] = icu_full_path
10971102 if not os .path .isdir (icu_full_path ):
1098- print '* ECMA-402 (Intl) support didn\' t find ICU in %s..' % ( icu_full_path )
1103+ print ( '* ECMA-402 (Intl) support didn\' t find ICU in %s..' % icu_full_path )
10991104 # can we download (or find) a zipfile?
11001105 localzip = icu_download (icu_full_path )
11011106 if localzip :
11021107 nodedownload .unpack (localzip , icu_parent_path )
11031108 if not os .path .isdir (icu_full_path ):
1104- print ' Cannot build Intl without ICU in %s.' % ( icu_full_path )
1105- print ' (Fix, or disable with "--with-intl=none" )'
1109+ print ( ' Cannot build Intl without ICU in %s.' % icu_full_path )
1110+ print ( ' (Fix, or disable with "--with-intl=none" )' )
11061111 sys .exit (1 )
11071112 else :
1108- print '* Using ICU in %s' % ( icu_full_path )
1113+ print ( '* Using ICU in %s' % icu_full_path )
11091114 # Now, what version of ICU is it? We just need the "major", such as 54.
11101115 # uvernum.h contains it as a #define.
11111116 uvernum_h = os .path .join (icu_full_path , 'source/common/unicode/uvernum.h' )
11121117 if not os .path .isfile (uvernum_h ):
1113- print ' Error: could not load %s - is ICU installed?' % uvernum_h
1118+ print ( ' Error: could not load %s - is ICU installed?' % uvernum_h )
11141119 sys .exit (1 )
11151120 icu_ver_major = None
11161121 matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
@@ -1120,7 +1125,7 @@ def configure_intl(o):
11201125 if m :
11211126 icu_ver_major = m .group (1 )
11221127 if not icu_ver_major :
1123- print ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h
1128+ print ( ' Could not read U_ICU_VERSION_SHORT version from %s' % uvernum_h )
11241129 sys .exit (1 )
11251130 icu_endianness = sys .byteorder [0 ];
11261131 o ['variables' ]['icu_ver_major' ] = icu_ver_major
@@ -1147,8 +1152,8 @@ def configure_intl(o):
11471152 # this is the icudt*.dat file which node will be using (platform endianness)
11481153 o ['variables' ]['icu_data_file' ] = icu_data_file
11491154 if not os .path .isfile (icu_data_path ):
1150- print ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path
1151- print ' See the README.md.'
1155+ print ( ' Error: ICU prebuilt data file %s does not exist.' % icu_data_path )
1156+ print ( ' See the README.md.' )
11521157 # .. and we're not about to build it from .gyp!
11531158 sys .exit (1 )
11541159 # map from variable name to subdirs
0 commit comments