Skip to content

Commit

Permalink
build: make install.py python 3 compatiable
Browse files Browse the repository at this point in the history
This patch replaces usage of `filter` in such a way that it will be
compatible with Python 3. Also, this patch replaces the usage of `map`
to do a side-effect work with normal `for` loop.

PR-URL: #25583
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
  • Loading branch information
thefourtheye authored and addaleax committed Jan 23, 2019
1 parent b2834ce commit 34da9a3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ def try_remove(path, dst):
try_unlink(target_path)
try_rmdir_r(os.path.dirname(target_path))

def install(paths, dst): map(lambda path: try_copy(path, dst), paths)
def uninstall(paths, dst): map(lambda path: try_remove(path, dst), paths)
def install(paths, dst):
for path in paths:
try_copy(path, dst)

def uninstall(paths, dst):
for path in paths:
try_remove(path, dst)

def npm_files(action):
target_path = 'lib/node_modules/npm/'
Expand All @@ -85,7 +90,7 @@ def npm_files(action):
# npm has a *lot* of files and it'd be a pain to maintain a fixed list here
# so we walk its source directory instead...
for dirname, subdirs, basenames in os.walk('deps/npm', topdown=True):
subdirs[:] = filter('test'.__ne__, subdirs) # skip test suites
subdirs[:] = [subdir for subdir in subdirs if subdir != 'test']
paths = [os.path.join(dirname, basename) for basename in basenames]
action(paths, target_path + dirname[9:] + '/')

Expand Down Expand Up @@ -162,7 +167,7 @@ def ignore_inspector_headers(files, dest):
'deps/v8/include/v8-inspector.h',
'deps/v8/include/v8-inspector-protocol.h'
]
files = filter(lambda name: name not in inspector_headers, files)
files = [name for name in files if name not in inspector_headers]
action(files, dest)

action([
Expand Down

0 comments on commit 34da9a3

Please sign in to comment.