Skip to content

Commit 30949f8

Browse files
thefourtheyeaddaleax
authored andcommittedJan 28, 2019
build: make configure.py compatible with python 3
This patch replaces the following 1. Usage of `filter` with `None` to remove falsy items. 2. Usage of `map` to create lists. (Replaced with List comprehensions). 3. Dictionary's `iteritems` which is removed in Python 3. PR-URL: #25580 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 021d197 commit 30949f8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎configure.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,8 @@ def configure_library(lib, output):
11421142
if options.__dict__[shared_lib + '_includes']:
11431143
output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
11441144
elif pkg_cflags:
1145-
output['include_dirs'] += (
1146-
filter(None, map(str.strip, pkg_cflags.split('-I'))))
1145+
stripped_flags = [flag.strip() for flag in pkg_cflags.split('-I')]
1146+
output['include_dirs'] += [flag for flag in stripped_flags if flag]
11471147

11481148
# libpath needs to be provided ahead libraries
11491149
if options.__dict__[shared_lib + '_libpath']:
@@ -1159,7 +1159,7 @@ def configure_library(lib, output):
11591159
output['libraries'] += [pkg_libpath]
11601160

11611161
default_libs = getattr(options, shared_lib + '_libname')
1162-
default_libs = map('-l{0}'.format, default_libs.split(','))
1162+
default_libs = ['-l{0}'.format(lib) for lib in default_libs.split(',')]
11631163

11641164
if default_libs:
11651165
output['libraries'] += default_libs
@@ -1385,7 +1385,8 @@ def write_config(data, name):
13851385
# safe to split, cannot contain spaces
13861386
o['libraries'] += libs.split()
13871387
if cflags:
1388-
o['include_dirs'] += filter(None, map(str.strip, cflags.split('-I')))
1388+
stripped_flags = [flag.strip() for flag in cflags.split('-I')]
1389+
o['include_dirs'] += [flag for flag in stripped_flags if flag]
13891390
# use the "system" .gyp
13901391
o['variables']['icu_gyp_path'] = 'tools/icu/icu-system.gyp'
13911392
return
@@ -1666,7 +1667,7 @@ def make_bin_override():
16661667
if options.prefix:
16671668
config['PREFIX'] = options.prefix
16681669

1669-
config = '\n'.join(map('='.join, config.iteritems())) + '\n'
1670+
config = '\n'.join(['='.join(item) for item in config.items()]) + '\n'
16701671

16711672
# On Windows there's no reason to search for a different python binary.
16721673
bin_override = None if sys.platform == 'win32' else make_bin_override()

0 commit comments

Comments
 (0)
Please sign in to comment.