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 6 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
18 changes: 13 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,8 @@ jobs:
- g++-6
install: *ccache-setup-steps
script:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- export PYTHONPATH="${PYTHONPATH}:$(pwd)/tools"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does PYTHONPATH have to be set? does everyone have to? ./configure should be able to import from tools itself, without needing this. I checked out your branch and tried it, and I didn't have to set any paths to call configure. Still building to confirm.

Copy link
Contributor

@sam-github sam-github Jul 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I have python2.7 and python3.7 in /usr/bin (ubuntu), and 2.7 is chosen. Is this intended? I can't even use python3 manually:

core/lts (pr/28537 *$) % python3 configure
Please use Python 2.7:

  /usr/bin/python2 configure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome... Thanks for digging into this. Files like tools/configure.d/nodedownload.py will need to be able to import six but if that is enabled then I am all good.

You are forced to use legacy Python because this PR does not include something like #25878. Small moves...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go look at #25878

- ./configure
- make -j2 -C out V=1 v8

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

- name: "Test C++ Suites"
Expand All @@ -63,7 +69,8 @@ jobs:
- cp /home/travis/.ccache/cctest out/Release/cctest
- touch config.gypi
script:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- export PYTHONPATH="${PYTHONPATH}:$(pwd)/tools"
- 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 +79,8 @@ jobs:
language: node_js
node_js: "node"
install:
- pyenv global 2.7.15
- pyenv global ${PYTHON_VERSION}
- export PYTHONPATH="${PYTHONPATH}:$(pwd)/tools"
- make lint-py-build || true
script:
- NODE=$(which node) make lint lint-py
Expand Down
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -1507,3 +1507,26 @@ The externally maintained libraries used by Node.js are:
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""

- six, located at tools/six.py, is licensed as follows:
"""
Copyright (c) 2010-2019 Benjamin Peterson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
11 changes: 5 additions & 6 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 @@ -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
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
10 changes: 5 additions & 5 deletions tools/configure.d/nodedownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
# 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
from six.moves.urllib.request 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
2 changes: 2 additions & 0 deletions tools/license-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,6 @@ addlicense "HdrHistogram" "deps/histogram" "$(cat ${rootdir}/deps/histogram/LICE
addlicense "node-heapdump" "src/heap_utils.cc" \
"$(curl -sL https://raw.githubusercontent.com/bnoordhuis/node-heapdump/0ca52441e46241ffbea56a389e2856ec01c48c97/LICENSE)"

addlicense "six" "tools/six.py" "$(sed -e '/^$/,$d' -e 's/^#//' -e 's/^ //' ${rootdir}/tools/six.py)"

mv $tmplicense $licensefile
Loading