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
@@ -448,7 +452,7 @@ def pkg_config(pkg):
448
452
shlex.split(pkg_config) + ['--silence-errors', flag, pkg],
449
453
stdout=subprocess.PIPE)
450
454
val = proc.communicate()[0].strip()
451
- except OSError, e:
455
+ except OSError as e:
452
456
if e.errno != errno.ENOENT: raise e # Unexpected error.
453
457
return (None, None, None) # No pkg-config/pkgconf installed.
454
458
retval += (val,)
@@ -484,12 +488,12 @@ def get_version_helper(cc, regexp):
484
488
proc = subprocess.Popen(shlex.split(cc) + ['-v'], stdin=subprocess.PIPE,
485
489
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
486
490
except OSError:
487
- print '''Node.js configure error: No acceptable C compiler found!
491
+ print( '''Node.js configure error: No acceptable C compiler found!
488
492
489
493
Please make sure you have a C compiler installed on your system and/or
490
494
consider adjusting the CC environment variable if you installed
491
495
it in a non-standard prefix.
492
- '''
496
+ ''')
493
497
sys.exit()
494
498
495
499
match = re.search(regexp, proc.communicate()[1])
@@ -515,12 +519,12 @@ def get_gas_version(cc):
515
519
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
516
520
stdout=subprocess.PIPE)
517
521
except OSError:
518
- print '''Node.js configure error: No acceptable C compiler found!
522
+ print( '''Node.js configure error: No acceptable C compiler found!
519
523
520
524
Please make sure you have a C compiler installed on your system and/or
521
525
consider adjusting the CC environment variable if you installed
522
526
it in a non-standard prefix.
523
- '''
527
+ ''')
524
528
sys.exit()
525
529
526
530
match = re.match(r"GNU assembler version ([2-9]\.[0-9]+)",
@@ -575,12 +579,12 @@ def cc_macros(cc=None):
575
579
stdout=subprocess.PIPE,
576
580
stderr=subprocess.PIPE)
577
581
except OSError:
578
- print '''Node.js configure error: No acceptable C compiler found!
582
+ print( '''Node.js configure error: No acceptable C compiler found!
579
583
580
584
Please make sure you have a C compiler installed on your system and/or
581
585
consider adjusting the CC environment variable if you installed
582
586
it in a non-standard prefix.
583
- '''
587
+ ''')
584
588
sys.exit()
585
589
586
590
p.stdin.write('\n')
@@ -921,7 +925,7 @@ def configure_winsdk(o):
921
925
922
926
def write(filename, data):
923
927
filename = os.path.join(root_dir, filename)
924
- print 'creating ', filename
928
+ print( 'creating %s' % filename)
925
929
f = open(filename, 'w+')
926
930
f.write(data)
927
931
@@ -941,7 +945,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):
941
945
patchfile = '%s/%s/%s' % (dir_base, patch_dir, file)
942
946
if os.path.isfile(patchfile):
943
947
srcfile = '%s/%s' % (patch_dir, file)
944
- print 'Using version-specific floating patch %s' % patchfile
948
+ print( 'Using version-specific floating patch %s' % patchfile)
945
949
list.append(srcfile)
946
950
break
947
951
return list
@@ -956,8 +960,8 @@ def configure_intl(o):
956
960
def icu_download(path):
957
961
# download ICU, if needed
958
962
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.')
961
965
sys.exit(1)
962
966
for icu in icus:
963
967
url = icu['url']
@@ -968,16 +972,16 @@ def configure_intl(o):
968
972
if nodedownload.candownload(auto_downloads, "icu"):
969
973
nodedownload.retrievefile(url, targetfile)
970
974
else:
971
- print ' Re-using existing %s' % targetfile
975
+ print( ' Re-using existing %s' % targetfile)
972
976
if os.path.isfile(targetfile):
973
977
sys.stdout.write(' Checking file integrity with MD5:\r')
974
978
gotmd5 = nodedownload.md5sum(targetfile)
975
- print ' MD5: %s %s' % (gotmd5, targetfile)
979
+ print( ' MD5: %s %s' % (gotmd5, targetfile) )
976
980
if (md5 == gotmd5):
977
981
return targetfile
978
982
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)
981
985
return None
982
986
icu_config = {
983
987
'variables': {}
@@ -997,7 +1001,7 @@ def configure_intl(o):
997
1001
with_icu_source = options.with_icu_source
998
1002
have_icu_path = bool(options.with_icu_path)
999
1003
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')
1001
1005
sys.exit(1)
1002
1006
elif have_icu_path:
1003
1007
# Chromium .gyp mode: --with-icu-path
@@ -1025,8 +1029,8 @@ def configure_intl(o):
1025
1029
o['variables']['v8_enable_i18n_support'] = 1
1026
1030
pkgicu = pkg_config('icu-i18n')
1027
1031
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.')
1030
1034
sys.exit(1)
1031
1035
(libs, cflags, libpath) = pkgicu
1032
1036
# libpath provides linker path which may contain spaces
@@ -1052,17 +1056,17 @@ def configure_intl(o):
1052
1056
# --with-icu-source processing
1053
1057
# first, check that they didn't pass --with-icu-source=deps/icu
1054
1058
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)
1056
1060
with_icu_source = None
1057
1061
# if with_icu_source is still set, try to use it.
1058
1062
if with_icu_source:
1059
1063
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)
1061
1065
shutil.rmtree(icu_full_path)
1062
1066
# now, what path was given?
1063
1067
if os.path.isdir(with_icu_source):
1064
1068
# 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) )
1066
1070
shutil.copytree(with_icu_source, icu_full_path)
1067
1071
else:
1068
1072
# could be file or URL.
@@ -1086,7 +1090,8 @@ def configure_intl(o):
1086
1090
os.rename(tmp_icu, icu_full_path)
1087
1091
shutil.rmtree(icu_tmp_path)
1088
1092
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)
1090
1095
shutil.rmtree(icu_tmp_path)
1091
1096
sys.exit(1)
1092
1097
@@ -1095,22 +1100,22 @@ def configure_intl(o):
1095
1100
# ICU source dir relative to root
1096
1101
o['variables']['icu_path'] = icu_full_path
1097
1102
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)
1099
1104
# can we download (or find) a zipfile?
1100
1105
localzip = icu_download(icu_full_path)
1101
1106
if localzip:
1102
1107
nodedownload.unpack(localzip, icu_parent_path)
1103
1108
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" )')
1106
1111
sys.exit(1)
1107
1112
else:
1108
- print '* Using ICU in %s' % ( icu_full_path)
1113
+ print( '* Using ICU in %s' % icu_full_path)
1109
1114
# Now, what version of ICU is it? We just need the "major", such as 54.
1110
1115
# uvernum.h contains it as a #define.
1111
1116
uvernum_h = os.path.join(icu_full_path, 'source/common/unicode/uvernum.h')
1112
1117
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)
1114
1119
sys.exit(1)
1115
1120
icu_ver_major = None
1116
1121
matchVerExp = r'^\s*#define\s+U_ICU_VERSION_SHORT\s+"([^"]*)".*'
@@ -1120,7 +1125,7 @@ def configure_intl(o):
1120
1125
if m:
1121
1126
icu_ver_major = m.group(1)
1122
1127
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)
1124
1129
sys.exit(1)
1125
1130
icu_endianness = sys.byteorder[0];
1126
1131
o['variables']['icu_ver_major'] = icu_ver_major
@@ -1147,8 +1152,8 @@ def configure_intl(o):
1147
1152
# this is the icudt*.dat file which node will be using (platform endianness)
1148
1153
o['variables']['icu_data_file'] = icu_data_file
1149
1154
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.')
1152
1157
# .. and we're not about to build it from .gyp!
1153
1158
sys.exit(1)
1154
1159
# map from variable name to subdirs
0 commit comments