Skip to content

Commit

Permalink
Merge pull request mesonbuild#2357 from LukeShu/flake8
Browse files Browse the repository at this point in the history
Bring into compliance with flake8
  • Loading branch information
jpakkane authored Sep 22, 2017
2 parents 2ab4b39 + 68d4c1e commit be0aa7f
Show file tree
Hide file tree
Showing 22 changed files with 119 additions and 117 deletions.
33 changes: 17 additions & 16 deletions mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os, pickle, re, shlex, shutil, subprocess, sys
import os, pickle, re, shlex, subprocess, sys
from collections import OrderedDict

from . import backends
Expand Down Expand Up @@ -83,10 +83,9 @@ def add_item(self, name, elems):

def write(self, outfile):
self.check_outputs()
line = 'build %s: %s %s' % (
' '.join([ninja_quote(i) for i in self.outfilenames]),
self.rule,
' '.join([ninja_quote(i) for i in self.infilenames]))
line = 'build %s: %s %s' % (' '.join([ninja_quote(i) for i in self.outfilenames]),
self.rule,
' '.join([ninja_quote(i) for i in self.infilenames]))
if len(self.deps) > 0:
line += ' | ' + ' '.join([ninja_quote(x) for x in self.deps])
if len(self.orderdeps) > 0:
Expand Down Expand Up @@ -721,8 +720,7 @@ def generate_target_install(self, d):
# On toolchains/platforms that use an import library for
# linking (separate from the shared library with all the
# code), we need to install that too (dll.a/.lib).
if (isinstance(t, build.SharedLibrary) or
isinstance(t, build.Executable)) and t.get_import_filename():
if (isinstance(t, build.SharedLibrary) or isinstance(t, build.Executable)) and t.get_import_filename():
if custom_install_dir:
# If the DLL is installed into a custom directory,
# install the import library into the same place so
Expand Down Expand Up @@ -856,8 +854,9 @@ def generate_tests(self, outfile):
self.create_target_alias('meson-test', outfile)

# And then benchmarks.
cmd = self.environment.get_build_command(True) + ['test', '--benchmark', '--logbase',
'benchmarklog', '--num-processes=1', '--no-rebuild']
cmd = self.environment.get_build_command(True) + [
'test', '--benchmark', '--logbase',
'benchmarklog', '--num-processes=1', '--no-rebuild']
elem = NinjaBuildElement(self.all_outputs, 'meson-benchmark', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd)
elem.add_item('DESC', 'Running benchmark suite.')
Expand Down Expand Up @@ -1576,9 +1575,10 @@ def generate_rust_compile_rules(self, compiler, outfile):
def generate_swift_compile_rules(self, compiler, outfile):
rule = 'rule %s_COMPILER\n' % compiler.get_language()
full_exe = [ninja_quote(x) for x in self.environment.get_build_command()] + [
'--internal',
'dirchanger',
'$RUNDIR']
'--internal',
'dirchanger',
'$RUNDIR',
]
invoc = (' '.join(full_exe) + ' ' +
' '.join(ninja_quote(i) for i in compiler.get_exelist()))
command = ' command = %s $ARGS $in\n' % invoc
Expand Down Expand Up @@ -2527,10 +2527,11 @@ def get_user_option_args(self):
def generate_dist(self, outfile):
elem = NinjaBuildElement(self.all_outputs, 'meson-dist', 'CUSTOM_COMMAND', 'PHONY')
elem.add_item('DESC', 'Creating source packages')
elem.add_item('COMMAND', self.environment.get_build_command() +
['--internal', 'dist',
self.environment.source_dir,
self.environment.build_dir] + self.environment.get_build_command())
elem.add_item('COMMAND', self.environment.get_build_command() + [
'--internal', 'dist',
self.environment.source_dir,
self.environment.build_dir,
] + self.environment.get_build_command())
elem.add_item('pool', 'console')
elem.write(outfile)
# Alias that runs the target defined above
Expand Down
7 changes: 2 additions & 5 deletions mesonbuild/backend/vs2010backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from .. import dependencies
from .. import mlog
from .. import compilers
from ..build import BuildTarget
from ..compilers import CompilerArgs
from ..mesonlib import MesonException, File
from ..environment import Environment
Expand Down Expand Up @@ -383,8 +382,7 @@ def gen_run_target_vcxproj(self, target, ofname, guid):
cmd = [sys.executable, os.path.join(self.environment.get_script_dir(), 'commandrunner.py'),
self.environment.get_build_dir(),
self.environment.get_source_dir(),
self.get_target_dir(target)] + \
self.environment.get_build_command()
self.get_target_dir(target)] + self.environment.get_build_command()
for i in cmd_raw:
if isinstance(i, build.BuildTarget):
cmd.append(os.path.join(self.environment.get_build_dir(), self.get_target_filename(i)))
Expand Down Expand Up @@ -926,8 +924,7 @@ def gen_vcxproj(self, target, ofname, guid):
ofile.text = '$(OutDir)%s' % target.get_filename()
subsys = ET.SubElement(link, 'SubSystem')
subsys.text = subsystem
if (isinstance(target, build.SharedLibrary) or
isinstance(target, build.Executable)) and target.get_import_filename():
if (isinstance(target, build.SharedLibrary) or isinstance(target, build.Executable)) and target.get_import_filename():
# DLLs built with MSVC always have an import library except when
# they're data-only DLLs, but we don't support those yet.
ET.SubElement(link, 'ImportLibrary').text = target.get_import_filename()
Expand Down
2 changes: 0 additions & 2 deletions mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,5 +1025,3 @@ def get_instruction_set_args(self, instruction_set):
# and the can not be called.
return None
return vs32_instruction_set_args.get(instruction_set, None)


2 changes: 1 addition & 1 deletion mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def is_library(fname):
'avx': ['/arch:AVX'],
'avx2': ['/arch:AVX2'],
'neon': None,
}
}

# The 64 bit compiler defaults to /arch:avx.
vs64_instruction_set_args = {'mmx': ['/arch:AVX'],
Expand Down
79 changes: 40 additions & 39 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,6 @@ def get_supported_arguments_method(self, args, kwargs):
h)
return result


def first_supported_argument_method(self, args, kwargs):
for i in mesonlib.stringlistify(args):
if self.compiler.has_argument(i, self.environment):
Expand Down Expand Up @@ -1245,48 +1244,50 @@ def get_cross_property_method(self, args, kwargs):

pch_kwargs = set(['c_pch', 'cpp_pch'])

lang_arg_kwargs = set(['c_args',
'cpp_args',
'd_args',
'd_import_dirs',
'd_unittest',
'd_module_versions',
'fortran_args',
'java_args',
'objc_args',
'objcpp_args',
'rust_args',
'vala_args',
'cs_args',
])
lang_arg_kwargs = set([
'c_args',
'cpp_args',
'd_args',
'd_import_dirs',
'd_unittest',
'd_module_versions',
'fortran_args',
'java_args',
'objc_args',
'objcpp_args',
'rust_args',
'vala_args',
'cs_args',
])

vala_kwargs = set(['vala_header', 'vala_gir', 'vala_vapi'])
rust_kwargs = set(['rust_crate_type'])
cs_kwargs = set(['resources', 'cs_args'])

buildtarget_kwargs = set(['build_by_default',
'build_rpath',
'dependencies',
'extra_files',
'gui_app',
'link_with',
'link_whole',
'link_args',
'link_depends',
'implicit_include_directories',
'include_directories',
'install',
'install_rpath',
'install_dir',
'name_prefix',
'name_suffix',
'native',
'objects',
'override_options',
'pic',
'sources',
'vs_module_defs',
])
buildtarget_kwargs = set([
'build_by_default',
'build_rpath',
'dependencies',
'extra_files',
'gui_app',
'link_with',
'link_whole',
'link_args',
'link_depends',
'implicit_include_directories',
'include_directories',
'install',
'install_rpath',
'install_dir',
'name_prefix',
'name_suffix',
'native',
'objects',
'override_options',
'pic',
'sources',
'vs_module_defs',
])

build_target_common_kwargs = (
buildtarget_kwargs |
Expand Down Expand Up @@ -2013,7 +2014,7 @@ def func_find_program(self, node, args, kwargs):
if not isinstance(use_native, bool):
raise InvalidArguments('Argument to "native" must be a boolean.')
if not use_native:
progobj = self.program_from_cross_file(args)
progobj = self.program_from_cross_file(args)
if progobj is None:
progobj = self.program_from_system(args)
if required and (progobj is None or not progobj.found()):
Expand Down
10 changes: 5 additions & 5 deletions mesonbuild/mesonmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ def validate_dirs(self, dir1, dir2, handshake):
if os.path.exists(priv_dir):
if not handshake:
print('Directory already configured, exiting Meson. Just run your build command\n'
'(e.g. ninja) and Meson will regenerate as necessary. If ninja fails, run ninja\n'
'reconfigure to force Meson to regenerate.\n'
'\nIf build failures persist, manually wipe your build directory to clear any\n'
'stored system data.\n'
'\nTo change option values, run meson configure instead.')
'(e.g. ninja) and Meson will regenerate as necessary. If ninja fails, run ninja\n'
'reconfigure to force Meson to regenerate.\n'
'\nIf build failures persist, manually wipe your build directory to clear any\n'
'stored system data.\n'
'\nTo change option values, run meson configure instead.')
sys.exit(0)
else:
if handshake:
Expand Down
1 change: 0 additions & 1 deletion mesonbuild/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .. import dependencies
from .. import mlog
from ..mesonlib import MesonException
from ..interpreterbase import permittedKwargs, noKwargs

class permittedSnippetKwargs:

Expand Down
25 changes: 14 additions & 11 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from .. import build
import os
import sys
import copy
import subprocess
from . import ModuleReturnValue
Expand All @@ -30,7 +29,7 @@
from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import find_program, get_include_args
from . import ExtensionModule
from . import noKwargs, permittedKwargs
from ..interpreterbase import noKwargs, permittedKwargs

# gresource compilation is broken due to the way
# the resource compiler and Ninja clash about it
Expand Down Expand Up @@ -697,18 +696,22 @@ def yelp(self, state, args, kwargs):
args.append('--langs=' + '@@'.join(langs))
inscript = build.RunScript(script, args)

potargs = state.environment.get_build_command() + ['--internal', 'yelphelper', 'pot',
'--subdir=' + state.subdir,
'--id=' + project_id,
'--sources=' + source_str]
potargs = state.environment.get_build_command() + [
'--internal', 'yelphelper', 'pot',
'--subdir=' + state.subdir,
'--id=' + project_id,
'--sources=' + source_str,
]
pottarget = build.RunTarget('help-' + project_id + '-pot', potargs[0],
potargs[1:], [], state.subdir)

poargs = state.environment.get_build_command() + ['--internal', 'yelphelper', 'update-po',
'--subdir=' + state.subdir,
'--id=' + project_id,
'--sources=' + source_str,
'--langs=' + '@@'.join(langs)]
poargs = state.environment.get_build_command() + [
'--internal', 'yelphelper', 'update-po',
'--subdir=' + state.subdir,
'--id=' + project_id,
'--sources=' + source_str,
'--langs=' + '@@'.join(langs),
]
potarget = build.RunTarget('help-' + project_id + '-update-po', poargs[0],
poargs[1:], [], state.subdir)

Expand Down
9 changes: 5 additions & 4 deletions mesonbuild/modules/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import shutil

from os import path
from .. import coredata, mesonlib, build
from ..mesonlib import MesonException
from . import ModuleReturnValue
from . import ExtensionModule
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

PRESET_ARGS = {
'glib': [
Expand Down Expand Up @@ -72,8 +71,10 @@ def merge_file(self, state, args, kwargs):
datadirs = self._get_data_dirs(state, mesonlib.stringlistify(kwargs.pop('data_dirs', [])))
datadirs = '--datadirs=' + ':'.join(datadirs) if datadirs else None

command = state.environment.get_build_command() + ['--internal', 'msgfmthelper',
'@INPUT@', '@OUTPUT@', file_type, podir]
command = state.environment.get_build_command() + [
'--internal', 'msgfmthelper',
'@INPUT@', '@OUTPUT@', file_type, podir
]
if datadirs:
command.append(datadirs)

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/modtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from . import ModuleReturnValue
from . import ExtensionModule
from . import noKwargs
from ..interpreterbase import noKwargs

class TestModule(ExtensionModule):

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .. import mlog
from . import ModuleReturnValue
from . import ExtensionModule
from . import permittedKwargs
from ..interpreterbase import permittedKwargs


class PkgConfigModule(ExtensionModule):
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/modules/python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

from . import ExtensionModule
from mesonbuild.modules import ModuleReturnValue
from . import noKwargs, permittedSnippetKwargs
from . import permittedSnippetKwargs
from ..interpreterbase import noKwargs
from ..interpreter import shlib_kwargs

mod_kwargs = set()
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import ExtensionModule
import xml.etree.ElementTree as ET
from . import ModuleReturnValue
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

class Qt4Module(ExtensionModule):
tools_detected = False
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import ExtensionModule
import xml.etree.ElementTree as ET
from . import ModuleReturnValue
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

class Qt5Module(ExtensionModule):
tools_detected = False
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from . import GirTarget, TypelibTarget
from . import ModuleReturnValue
from . import ExtensionModule
from . import noKwargs
from ..interpreterbase import noKwargs

import os

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import get_include_args
from . import ModuleReturnValue
from . import ExtensionModule
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

class WindowsModule(ExtensionModule):

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/wrap/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def download(self, p, packagename):
def extract_package(self, package):
if sys.version_info < (3, 5):
try:
import lzma
import lzma # noqa: F401
del lzma
except ImportError:
pass
Expand Down
Loading

0 comments on commit be0aa7f

Please sign in to comment.