Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enhance Python 3 compatibility #28537

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ x-ccache-setup-steps: &ccache-setup-steps
os: linux
dist: xenial
language: cpp
env:
global:
- PYTHON_VERSION="2.7.15"
jobs:
include:
- stage: "Compile"
Expand All @@ -20,7 +23,7 @@ jobs:
- g++-6
install: *ccache-setup-steps
script:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- ./configure
- make -j2 -C out V=1 v8

Expand All @@ -34,7 +37,7 @@ jobs:
- g++-6
install: *ccache-setup-steps
script:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- ./configure
- make -j2 V=1
- cp out/Release/node /home/travis/.ccache
Expand All @@ -47,7 +50,7 @@ jobs:
- mkdir -p out/Release
- cp /home/travis/.ccache/node out/Release/node
script:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- python tools/test.py -j 2 -p dots --report --mode=release --flaky-tests=dontcare default

- name: "Test C++ Suites"
Expand All @@ -63,7 +66,7 @@ jobs:
- cp /home/travis/.ccache/cctest out/Release/cctest
- touch config.gypi
script:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- out/Release/cctest
- make -j1 V=1 test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
- python tools/test.py -j 2 -p dots --report --mode=release --flaky-tests=dontcare addons js-native-api node-api
Expand All @@ -72,7 +75,7 @@ jobs:
language: node_js
node_js: "node"
install:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- make lint-py-build || true
script:
- NODE=$(which node) make lint lint-py
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -1506,4 +1506,4 @@ The externally maintained libraries used by Node.js are:
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""
"""
15 changes: 7 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import shlex
import subprocess
import shutil
import string
from distutils.spawn import find_executable as which

# If not run from node/, cd to node/.
Expand Down Expand Up @@ -675,8 +674,8 @@ def try_check_compiler(cc, lang):
except OSError:
return (False, False, '', '')

proc.stdin.write('__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
'__clang_major__ __clang_minor__ __clang_patchlevel__')
proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
b'__clang_major__ __clang_minor__ __clang_patchlevel__')

values = (proc.communicate()[0].split() + ['0'] * 7)[0:7]
is_clang = values[0] == '1'
Expand Down Expand Up @@ -753,7 +752,7 @@ def get_gas_version(cc):
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.''')

gas_ret = proc.communicate()[1]
gas_ret = str(proc.communicate()[1])
match = re.match(r"GNU assembler version ([2-9]\.[0-9]+)", gas_ret)

if match:
Expand Down Expand Up @@ -818,7 +817,7 @@ def cc_macros(cc=None):
consider adjusting the CC environment variable if you installed
it in a non-standard prefix.''')

p.stdin.write('\n')
p.stdin.write(b'\n')
out = p.communicate()[0]

out = str(out).split('\n')
Expand Down Expand Up @@ -1311,7 +1310,7 @@ def glob_to_var(dir_base, dir_sub, patch_dir):

def configure_intl(o):
def icu_download(path):
depFile = 'tools/icu/current_ver.dep';
depFile = 'tools/icu/current_ver.dep'
with open(depFile) as f:
icus = json.load(f)
# download ICU, if needed
Expand Down Expand Up @@ -1380,7 +1379,7 @@ def write_config(data, name):
o['variables']['icu_small'] = b(True)
locs = set(options.with_icu_locales.split(','))
locs.add('root') # must have root
o['variables']['icu_locales'] = string.join(locs,',')
o['variables']['icu_locales'] = ','.join(str(loc) for loc in locs)
# We will check a bit later if we can use the canned deps/icu-small
elif with_intl == 'full-icu':
# full ICU
Expand Down Expand Up @@ -1520,7 +1519,7 @@ def write_config(data, name):
elif int(icu_ver_major) < icu_versions['minimum_icu']:
error('icu4c v%s.x is too old, v%d.x or later is required.' %
(icu_ver_major, icu_versions['minimum_icu']))
icu_endianness = sys.byteorder[0];
icu_endianness = sys.byteorder[0]
o['variables']['icu_ver_major'] = icu_ver_major
o['variables']['icu_endianness'] = icu_endianness
icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major, 'l')
Expand Down
15 changes: 12 additions & 3 deletions deps/v8/third_party/inspector_protocol/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,24 @@ def init_defaults(config_tuple, path, defaults):
jinja_dir = arg_options.jinja_dir
if not jinja_dir:
raise Exception("jinja directory must be specified")
jinja_dir = jinja_dir.decode('utf8')
try:
jinja_dir = jinja_dir.decode('utf8')
except AttributeError: # Python 3
pass
output_base = arg_options.output_base
if not output_base:
raise Exception("Base output directory must be specified")
output_base = output_base.decode('utf8')
try:
output_base = output_base.decode('utf8')
except AttributeError: # Python 3
pass
config_file = arg_options.config
if not config_file:
raise Exception("Config file name must be specified")
config_file = config_file.decode('utf8')
try:
config_file = config_file.decode('utf8')
except AttributeError: # Python 3
pass
config_base = os.path.dirname(config_file)
config_values = arg_options.config_value
if not config_values:
Expand Down
8 changes: 2 additions & 6 deletions deps/v8/tools/gen-postmortem-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,7 @@ def emit_config():

out.write('/* class type information */\n');
consts = [];
keys = typeclasses.keys();
keys.sort();
for typename in keys:
for typename in sorted(typeclasses):
klass = typeclasses[typename];
consts.append({
'name': 'type_%s__%s' % (klass, typename),
Expand All @@ -649,9 +647,7 @@ def emit_config():

out.write('/* class hierarchy information */\n');
consts = [];
keys = klasses.keys();
keys.sort();
for klassname in keys:
for klassname in sorted(klasses):
pklass = klasses[klassname]['parent'];
bklass = get_base_class(klassname);
if (bklass != 'Object'):
Expand Down
13 changes: 8 additions & 5 deletions tools/configure.d/nodedownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@
# Moved some utilities here from ../../configure

from __future__ import print_function
import urllib
import hashlib
import sys
import zipfile
import tarfile
import fpformat
import contextlib
try:
from urllib.request import FancyURLopener, URLopener
except ImportError:
from urllib import FancyURLopener, URLopener

def formatSize(amt):
"""Format a size as a string in MB"""
return fpformat.fix(amt / 1024000., 1)
# return fpformat.fix(amt / 1024000., 1)
return "%.1f" % (amt / 1024000.)

def spin(c):
"""print out an ASCII 'spinner' based on the value of counter 'c'"""
spin = ".:|'"
return (spin[c % len(spin)])

class ConfigOpener(urllib.FancyURLopener):
class ConfigOpener(FancyURLopener):
"""fancy opener used by retrievefile. Set a UA"""
# append to existing version (UA)
version = '%s node.js/configure' % urllib.URLopener.version
version = '%s node.js/configure' % URLopener.version

def reporthook(count, size, total):
"""internal hook used by retrievefile"""
Expand Down