From 2890d2849b1d001a64657c9acb2cd2c053877290 Mon Sep 17 00:00:00 2001 From: Jiawen Geng Date: Mon, 23 Aug 2021 01:49:21 +0000 Subject: [PATCH] feat(gyp): update gyp to v0.9.6 --- gyp/.github/workflows/Python_tests.yml | 2 +- gyp/.github/workflows/node-gyp.yml | 4 ++- gyp/CHANGELOG.md | 38 ++++++++++++++++++++ gyp/pylib/gyp/MSVSUtil.py | 2 +- gyp/pylib/gyp/common.py | 2 +- gyp/pylib/gyp/easy_xml.py | 6 ++-- gyp/pylib/gyp/generator/android.py | 6 ++-- gyp/pylib/gyp/generator/make.py | 2 +- gyp/pylib/gyp/generator/msvs.py | 29 ++++++++++----- gyp/pylib/gyp/generator/ninja.py | 32 ++++++++--------- gyp/pylib/gyp/input.py | 2 +- gyp/pylib/gyp/msvs_emulation.py | 49 +++++++++++++++++--------- gyp/pylib/gyp/win_tool.py | 5 +-- gyp/pylib/gyp/xcodeproj_file.py | 8 ++--- gyp/setup.py | 2 +- gyp/test_gyp.py | 21 ++++------- 16 files changed, 137 insertions(+), 73 deletions(-) diff --git a/gyp/.github/workflows/Python_tests.yml b/gyp/.github/workflows/Python_tests.yml index 649251c8dd..92303b635f 100644 --- a/gyp/.github/workflows/Python_tests.yml +++ b/gyp/.github/workflows/Python_tests.yml @@ -23,7 +23,7 @@ jobs: python -m pip install --upgrade pip pip install -r requirements_dev.txt - name: Lint with flake8 - run: flake8 . --count --show-source --statistics + run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics - name: Test with pytest run: pytest # - name: Run doctests with pytest diff --git a/gyp/.github/workflows/node-gyp.yml b/gyp/.github/workflows/node-gyp.yml index 59d23fdffc..bd7c85ffda 100644 --- a/gyp/.github/workflows/node-gyp.yml +++ b/gyp/.github/workflows/node-gyp.yml @@ -8,6 +8,8 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] + python: [3.6, 3.9] + runs-on: ${{ matrix.os }} steps: - name: Clone gyp-next @@ -24,7 +26,7 @@ jobs: node-version: 14.x - uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: ${{ matrix.python }} - name: Install dependencies run: | cd node-gyp diff --git a/gyp/CHANGELOG.md b/gyp/CHANGELOG.md index 6d66b3acd2..f5e9f63476 100644 --- a/gyp/CHANGELOG.md +++ b/gyp/CHANGELOG.md @@ -1,5 +1,43 @@ # Changelog +### [0.9.6](https://www.github.com/nodejs/gyp-next/compare/v0.9.5...v0.9.6) (2021-08-23) + + +### Bug Fixes + +* align flake8 test ([#122](https://www.github.com/nodejs/gyp-next/issues/122)) ([f1faa8d](https://www.github.com/nodejs/gyp-next/commit/f1faa8d3081e1a47e917ff910892f00dff16cf8a)) +* **msvs:** fix paths again in action command arguments ([#121](https://www.github.com/nodejs/gyp-next/issues/121)) ([7159dfb](https://www.github.com/nodejs/gyp-next/commit/7159dfbc5758c9ec717e215f2c36daf482c846a1)) + +### [0.9.5](https://www.github.com/nodejs/gyp-next/compare/v0.9.4...v0.9.5) (2021-08-18) + + +### Bug Fixes + +* add python 3.6 to node-gyp integration test ([3462d4c](https://www.github.com/nodejs/gyp-next/commit/3462d4ce3c31cce747513dc7ca9760c81d57c60e)) +* revert for windows compatibility ([d078e7d](https://www.github.com/nodejs/gyp-next/commit/d078e7d7ae080ddae243188f6415f940376a7368)) +* support msvs_quote_cmd in ninja generator ([#117](https://www.github.com/nodejs/gyp-next/issues/117)) ([46486ac](https://www.github.com/nodejs/gyp-next/commit/46486ac6e9329529d51061e006a5b39631e46729)) + +### [0.9.4](https://www.github.com/nodejs/gyp-next/compare/v0.9.3...v0.9.4) (2021-08-09) + + +### Bug Fixes + +* .S is an extension for asm file on Windows ([#115](https://www.github.com/nodejs/gyp-next/issues/115)) ([d2fad44](https://www.github.com/nodejs/gyp-next/commit/d2fad44ef3a79ca8900f1307060153ded57053fc)) + +### [0.9.3](https://www.github.com/nodejs/gyp-next/compare/v0.9.2...v0.9.3) (2021-07-07) + + +### Bug Fixes + +* build failure with ninja and Python 3 on Windows ([#113](https://www.github.com/nodejs/gyp-next/issues/113)) ([c172d10](https://www.github.com/nodejs/gyp-next/commit/c172d105deff5db4244e583942215918fa80dd3c)) + +### [0.9.2](https://www.github.com/nodejs/gyp-next/compare/v0.9.1...v0.9.2) (2021-05-21) + + +### Bug Fixes + +* add support of utf8 encoding ([#105](https://www.github.com/nodejs/gyp-next/issues/105)) ([4d0f93c](https://www.github.com/nodejs/gyp-next/commit/4d0f93c249286d1f0c0f665f5fe7346119f98cf1)) + ### [0.9.1](https://www.github.com/nodejs/gyp-next/compare/v0.9.0...v0.9.1) (2021-05-14) diff --git a/gyp/pylib/gyp/MSVSUtil.py b/gyp/pylib/gyp/MSVSUtil.py index cb55305eae..36bb782bd3 100644 --- a/gyp/pylib/gyp/MSVSUtil.py +++ b/gyp/pylib/gyp/MSVSUtil.py @@ -55,7 +55,7 @@ def _SuffixName(name, suffix): Target name with suffix added (foo_suffix#target) """ parts = name.rsplit("#", 1) - parts[0] = "{}_{}".format(parts[0], suffix) + parts[0] = f"{parts[0]}_{suffix}" return "#".join(parts) diff --git a/gyp/pylib/gyp/common.py b/gyp/pylib/gyp/common.py index ba310ce247..9213fcc5e8 100644 --- a/gyp/pylib/gyp/common.py +++ b/gyp/pylib/gyp/common.py @@ -562,7 +562,7 @@ def pop(self, last=True): # pylint: disable=W0221 def __repr__(self): if not self: return f"{self.__class__.__name__}()" - return "{}({!r})".format(self.__class__.__name__, list(self)) + return f"{self.__class__.__name__}({list(self)!r})" def __eq__(self, other): if isinstance(other, OrderedSet): diff --git a/gyp/pylib/gyp/easy_xml.py b/gyp/pylib/gyp/easy_xml.py index e475b5530c..bda1a47468 100644 --- a/gyp/pylib/gyp/easy_xml.py +++ b/gyp/pylib/gyp/easy_xml.py @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import sys import re import os import locale @@ -84,7 +85,7 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0): rest = specification[1:] if rest and isinstance(rest[0], dict): for at, val in sorted(rest[0].items()): - xml_parts.append(' {}="{}"'.format(at, _XmlEscape(val, attr=True))) + xml_parts.append(f' {at}="{_XmlEscape(val, attr=True)}"') rest = rest[1:] if rest: xml_parts.append(">") @@ -106,7 +107,8 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0): xml_parts.append("/>%s" % new_line) -def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, win32=False): +def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, + win32=(sys.platform == "win32")): """ Writes the XML content to disk, touching the file only if it has changed. Args: diff --git a/gyp/pylib/gyp/generator/android.py b/gyp/pylib/gyp/generator/android.py index 040d8088a2..cdf1a4832c 100644 --- a/gyp/pylib/gyp/generator/android.py +++ b/gyp/pylib/gyp/generator/android.py @@ -349,7 +349,7 @@ def WriteActions(self, actions, extra_sources, extra_outputs): for output in outputs[1:]: # Make each output depend on the main output, with an empty command # to force make to notice that the mtime has changed. - self.WriteLn("{}: {} ;".format(self.LocalPathify(output), main_output)) + self.WriteLn(f"{self.LocalPathify(output)}: {main_output} ;") extra_outputs += outputs self.WriteLn() @@ -616,7 +616,7 @@ def WriteSources(self, spec, configs, extra_sources): if IsCPPExtension(ext) and ext != local_cpp_extension: local_file = root + local_cpp_extension if local_file != source: - self.WriteLn("{}: {}".format(local_file, self.LocalPathify(source))) + self.WriteLn(f"{local_file}: {self.LocalPathify(source)}") self.WriteLn("\tmkdir -p $(@D); cp $< $@") origin_src_dirs.append(os.path.dirname(source)) final_generated_sources.append(local_file) @@ -908,7 +908,7 @@ def WriteTarget( if isinstance(v, list): self.WriteList(v, k) else: - self.WriteLn("{} := {}".format(k, make.QuoteIfNecessary(v))) + self.WriteLn(f"{k} := {make.QuoteIfNecessary(v)}") self.WriteLn("") # Add to the set of targets which represent the gyp 'all' target. We use the diff --git a/gyp/pylib/gyp/generator/make.py b/gyp/pylib/gyp/generator/make.py index eb9102dd15..c595f20fe2 100644 --- a/gyp/pylib/gyp/generator/make.py +++ b/gyp/pylib/gyp/generator/make.py @@ -2133,7 +2133,7 @@ def WriteSortedXcodeEnv(self, target, env): # export foo := a\ b # it does not -- the backslash is written to the env as literal character. # So don't escape spaces in |env[k]|. - self.WriteLn("{}: export {} := {}".format(QuoteSpaces(target), k, v)) + self.WriteLn(f"{QuoteSpaces(target)}: export {k} := {v}") def Objectify(self, path): """Convert a path to its output directory form.""" diff --git a/gyp/pylib/gyp/generator/msvs.py b/gyp/pylib/gyp/generator/msvs.py index 5435eb1e1f..8308fa8433 100644 --- a/gyp/pylib/gyp/generator/msvs.py +++ b/gyp/pylib/gyp/generator/msvs.py @@ -152,7 +152,7 @@ def _NormalizedSource(source): return source -def _FixPath(path): +def _FixPath(path, separator="\\"): """Convert paths to a form that will make sense in a vcproj file. Arguments: @@ -168,9 +168,12 @@ def _FixPath(path): and not _IsWindowsAbsPath(path) ): path = os.path.join(fixpath_prefix, path) - path = path.replace("/", "\\") + if separator == "\\": + path = path.replace("/", "\\") path = _NormalizedSource(path) - if path and path[-1] == "\\": + if separator == "/": + path = path.replace("\\", "/") + if path and path[-1] == separator: path = path[:-1] return path @@ -185,9 +188,9 @@ def _IsWindowsAbsPath(path): return path.startswith("c:") or path.startswith("C:") -def _FixPaths(paths): +def _FixPaths(paths, separator="\\"): """Fix each of the paths of the list.""" - return [_FixPath(i) for i in paths] + return [_FixPath(i, separator) for i in paths] def _ConvertSourcesToFilterHierarchy( @@ -314,7 +317,7 @@ def _ConfigBaseName(config_name, platform_name): def _ConfigFullName(config_name, config_data): platform_name = _ConfigPlatform(config_data) - return "{}|{}".format(_ConfigBaseName(config_name, platform_name), platform_name) + return f"{_ConfigBaseName(config_name, platform_name)}|{platform_name}" def _ConfigWindowsTargetPlatformVersion(config_data, version): @@ -335,7 +338,7 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version): # Find a matching entry in sdk_dir\include. expected_sdk_dir = r"%s\include" % sdk_dir names = sorted( - [ + ( x for x in ( os.listdir(expected_sdk_dir) @@ -343,7 +346,7 @@ def _ConfigWindowsTargetPlatformVersion(config_data, version): else [] ) if x.startswith(version) - ], + ), reverse=True, ) if names: @@ -418,7 +421,15 @@ def _BuildCommandLineForRuleRaw( # file out of the raw command string, and some commands (like python) are # actually batch files themselves. command.insert(0, "call") - arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in cmd[1:]] + # Fix the paths + # TODO(quote): This is a really ugly heuristic, and will miss path fixing + # for arguments like "--arg=path" or "/opt:path". + # If the argument starts with a slash or dash, it's probably a command line + # switch + # Return the path with forward slashes because the command using it might + # not support backslashes. + arguments = [i if (i[:1] in "/-") else _FixPath(i, "/") for i in cmd[1:]] + arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in arguments] arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments] if quote_cmd: # Support a mode for using cmd directly. diff --git a/gyp/pylib/gyp/generator/ninja.py b/gyp/pylib/gyp/generator/ninja.py index ca032aef20..d173bf2299 100644 --- a/gyp/pylib/gyp/generator/ninja.py +++ b/gyp/pylib/gyp/generator/ninja.py @@ -638,7 +638,7 @@ def GenerateDescription(self, verb, message, fallback): if self.toolset != "target": verb += "(%s)" % self.toolset if message: - return "{} {}".format(verb, self.ExpandSpecial(message)) + return f"{verb} {self.ExpandSpecial(message)}" else: return f"{verb} {self.name}: {fallback}" @@ -654,10 +654,10 @@ def WriteActions( description = self.GenerateDescription( "ACTION", action.get("message", None), name ) - is_cygwin = ( - self.msvs_settings.IsRuleRunUnderCygwin(action) + win_shell_flags = ( + self.msvs_settings.GetRuleShellFlags(action) if self.flavor == "win" - else False + else None ) args = action["action"] depfile = action.get("depfile", None) @@ -665,7 +665,7 @@ def WriteActions( depfile = self.ExpandSpecial(depfile, self.base_to_build) pool = "console" if int(action.get("ninja_use_console", 0)) else None rule_name, _ = self.WriteNewNinjaRule( - name, args, description, is_cygwin, env, pool, depfile=depfile + name, args, description, win_shell_flags, env, pool, depfile=depfile ) inputs = [self.GypPathToNinja(i, env) for i in action["inputs"]] @@ -707,14 +707,14 @@ def WriteRules( rule.get("message", None), ("%s " + generator_default_variables["RULE_INPUT_PATH"]) % name, ) - is_cygwin = ( - self.msvs_settings.IsRuleRunUnderCygwin(rule) + win_shell_flags = ( + self.msvs_settings.GetRuleShellFlags(rule) if self.flavor == "win" - else False + else None ) pool = "console" if int(rule.get("ninja_use_console", 0)) else None rule_name, args = self.WriteNewNinjaRule( - name, args, description, is_cygwin, env, pool + name, args, description, win_shell_flags, env, pool ) # TODO: if the command references the outputs directly, we should @@ -733,7 +733,7 @@ def WriteRules( def cygwin_munge(path): # pylint: disable=cell-var-from-loop - if is_cygwin: + if win_shell_flags and win_shell_flags.cygwin: return path.replace("\\", "/") return path @@ -1221,7 +1221,7 @@ def WriteSourcesForArch( command = "cc_s" elif ( self.flavor == "win" - and ext == "asm" + and ext in ("asm", "S") and not self.msvs_settings.HasExplicitAsmRules(spec) ): command = "asm" @@ -1899,7 +1899,7 @@ def WriteVariableList(self, ninja_file, var, values): ninja_file.variable(var, " ".join(values)) def WriteNewNinjaRule( - self, name, args, description, is_cygwin, env, pool, depfile=None + self, name, args, description, win_shell_flags, env, pool, depfile=None ): """Write out a new ninja "rule" statement for a given command. @@ -1946,13 +1946,14 @@ def WriteNewNinjaRule( if self.flavor == "win": rspfile = rule_name + ".$unique_name.rsp" # The cygwin case handles this inside the bash sub-shell. - run_in = "" if is_cygwin else " " + self.build_to_base - if is_cygwin: + run_in = "" if win_shell_flags.cygwin else " " + self.build_to_base + if win_shell_flags.cygwin: rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine( args, self.build_to_base ) else: - rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args) + rspfile_content = gyp.msvs_emulation.EncodeRspFileList( + args, win_shell_flags.quote) command = ( "%s gyp-win-tool action-wrapper $arch " % sys.executable + rspfile @@ -2389,7 +2390,6 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name ) if flavor == "win": master_ninja.variable("ld_host", ld_host) - master_ninja.variable("ldxx_host", ldxx_host) else: master_ninja.variable( "ld_host", CommandWithWrapper("LINK", wrappers, ld_host) diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py index ca7ce44eab..354958bfb2 100644 --- a/gyp/pylib/gyp/input.py +++ b/gyp/pylib/gyp/input.py @@ -225,7 +225,7 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes, is_target, check return data[build_file_path] if os.path.exists(build_file_path): - build_file_contents = open(build_file_path).read() + build_file_contents = open(build_file_path, encoding='utf-8').read() else: raise GypError(f"{build_file_path} not found (cwd: {os.getcwd()})") diff --git a/gyp/pylib/gyp/msvs_emulation.py b/gyp/pylib/gyp/msvs_emulation.py index f744e38df1..5b9c2712e0 100644 --- a/gyp/pylib/gyp/msvs_emulation.py +++ b/gyp/pylib/gyp/msvs_emulation.py @@ -7,6 +7,7 @@ build systems, primarily ninja. """ +import collections import os import re import subprocess @@ -19,7 +20,7 @@ windows_quoter_regex = re.compile(r'(\\*)"') -def QuoteForRspFile(arg): +def QuoteForRspFile(arg, quote_cmd=True): """Quote a command line argument so that it appears as one argument when processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for Windows programs).""" @@ -36,7 +37,8 @@ def QuoteForRspFile(arg): # For a literal quote, CommandLineToArgvW requires 2n+1 backslashes # preceding it, and results in n backslashes + the quote. So we substitute # in 2* what we match, +1 more, plus the quote. - arg = windows_quoter_regex.sub(lambda mo: 2 * mo.group(1) + '\\"', arg) + if quote_cmd: + arg = windows_quoter_regex.sub(lambda mo: 2 * mo.group(1) + '\\"', arg) # %'s also need to be doubled otherwise they're interpreted as batch # positional arguments. Also make sure to escape the % so that they're @@ -48,12 +50,17 @@ def QuoteForRspFile(arg): # These commands are used in rsp files, so no escaping for the shell (via ^) # is necessary. - # Finally, wrap the whole thing in quotes so that the above quote rule - # applies and whitespace isn't a word break. - return '"' + arg + '"' + # As a workaround for programs that don't use CommandLineToArgvW, gyp + # supports msvs_quote_cmd=0, which simply disables all quoting. + if quote_cmd: + # Finally, wrap the whole thing in quotes so that the above quote rule + # applies and whitespace isn't a word break. + return f'"{arg}"' + return arg -def EncodeRspFileList(args): + +def EncodeRspFileList(args, quote_cmd): """Process a list of arguments using QuoteCmdExeArgument.""" # Note that the first argument is assumed to be the command. Don't add # quotes around it because then built-ins like 'echo', etc. won't work. @@ -67,7 +74,8 @@ def EncodeRspFileList(args): program = call + " " + os.path.normpath(program) else: program = os.path.normpath(args[0]) - return program + " " + " ".join(QuoteForRspFile(arg) for arg in args[1:]) + return (program + " " + + " ".join(QuoteForRspFile(arg, quote_cmd) for arg in args[1:])) def _GenericRetrieve(root, default, path): @@ -333,7 +341,7 @@ def _TargetConfig(self, config): # first level is globally for the configuration (this is what we consider # "the" config at the gyp level, which will be something like 'Debug' or # 'Release'), VS2015 and later only use this level - if self.vs_version.short_name >= 2015: + if int(self.vs_version.short_name) >= 2015: return config # and a second target-specific configuration, which is an # override for the global one. |config| is remapped here to take into @@ -537,7 +545,7 @@ def GetCflags(self, config): ) ] ) - if self.vs_version.project_version >= 12.0: + if float(self.vs_version.project_version) >= 12.0: # New flag introduced in VS2013 (project version 12.0) Forces writes to # the program database (PDB) to be serialized through MSPDBSRV.EXE. # https://msdn.microsoft.com/en-us/library/dn502518.aspx @@ -933,13 +941,22 @@ def BuildCygwinBashCommandLine(self, args, path_to_base): ) return cmd - def IsRuleRunUnderCygwin(self, rule): - """Determine if an action should be run under cygwin. If the variable is - unset, or set to 1 we use cygwin.""" - return ( - int(rule.get("msvs_cygwin_shell", self.spec.get("msvs_cygwin_shell", 1))) - != 0 - ) + RuleShellFlags = collections.namedtuple("RuleShellFlags", ["cygwin", "quote"]) + + def GetRuleShellFlags(self, rule): + """Return RuleShellFlags about how the given rule should be run. This + includes whether it should run under cygwin (msvs_cygwin_shell), and + whether the commands should be quoted (msvs_quote_cmd).""" + # If the variable is unset, or set to 1 we use cygwin + cygwin = int(rule.get("msvs_cygwin_shell", + self.spec.get("msvs_cygwin_shell", 1))) != 0 + # Default to quoting. There's only a few special instances where the + # target command uses non-standard command line parsing and handle quotes + # and quote escaping differently. + quote_cmd = int(rule.get("msvs_quote_cmd", 1)) + assert quote_cmd != 0 or cygwin != 1, \ + "msvs_quote_cmd=0 only applicable for msvs_cygwin_shell=0" + return MsvsSettings.RuleShellFlags(cygwin, quote_cmd) def _HasExplicitRuleForExtension(self, spec, extension): """Determine if there's an explicit rule for a particular extension.""" diff --git a/gyp/pylib/gyp/win_tool.py b/gyp/pylib/gyp/win_tool.py index 4dbcda50a4..638eee4002 100755 --- a/gyp/pylib/gyp/win_tool.py +++ b/gyp/pylib/gyp/win_tool.py @@ -221,8 +221,9 @@ def ExecLinkWithManifests( # and sometimes doesn't unfortunately. with open(our_manifest) as our_f: with open(assert_manifest) as assert_f: - our_data = our_f.read().translate(None, string.whitespace) - assert_data = assert_f.read().translate(None, string.whitespace) + translator = str.maketrans('', '', string.whitespace) + our_data = our_f.read().translate(translator) + assert_data = assert_f.read().translate(translator) if our_data != assert_data: os.unlink(out) diff --git a/gyp/pylib/gyp/xcodeproj_file.py b/gyp/pylib/gyp/xcodeproj_file.py index 5863ef45df..076eea3721 100644 --- a/gyp/pylib/gyp/xcodeproj_file.py +++ b/gyp/pylib/gyp/xcodeproj_file.py @@ -299,8 +299,8 @@ def __repr__(self): try: name = self.Name() except NotImplementedError: - return "<{} at 0x{:x}>".format(self.__class__.__name__, id(self)) - return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self)) + return f"<{self.__class__.__name__} at 0x{id(self):x}>" + return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>" def Copy(self): """Make a copy of this object. @@ -2251,7 +2251,7 @@ class PBXContainerItemProxy(XCObject): def __repr__(self): props = self._properties name = "{}.gyp:{}".format(props["containerPortal"].Name(), props["remoteInfo"]) - return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self)) + return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>" def Name(self): # Admittedly not the best name, but it's what Xcode uses. @@ -2288,7 +2288,7 @@ class PBXTargetDependency(XCObject): def __repr__(self): name = self._properties.get("name") or self._properties["target"].Name() - return "<{} {!r} at 0x{:x}>".format(self.__class__.__name__, name, id(self)) + return f"<{self.__class__.__name__} {name!r} at 0x{id(self):x}>" def Name(self): # Admittedly not the best name, but it's what Xcode uses. diff --git a/gyp/setup.py b/gyp/setup.py index f4a9481937..0ce46123cc 100644 --- a/gyp/setup.py +++ b/gyp/setup.py @@ -15,7 +15,7 @@ setup( name="gyp-next", - version="0.9.1", + version="0.9.6", description="A fork of the GYP build system for use in the Node.js projects", long_description=long_description, long_description_content_type="text/markdown", diff --git a/gyp/test_gyp.py b/gyp/test_gyp.py index 757d2fc0b0..9ba264170f 100755 --- a/gyp/test_gyp.py +++ b/gyp/test_gyp.py @@ -140,10 +140,7 @@ def main(argv=None): if not args.quiet: runner.print_results() - if runner.failures: - return 1 - else: - return 0 + return 1 if runner.failures else 0 def print_configuration_info(): @@ -152,8 +149,8 @@ def print_configuration_info(): sys.path.append(os.path.abspath("test/lib")) import TestMac - print(" Mac {} {}".format(platform.mac_ver()[0], platform.mac_ver()[2])) - print(" Xcode %s" % TestMac.Xcode.Version()) + print(f" Mac {platform.mac_ver()[0]} {platform.mac_ver()[2]}") + print(f" Xcode {TestMac.Xcode.Version()}") elif sys.platform == "win32": sys.path.append(os.path.abspath("pylib")) import gyp.MSVSVersion @@ -162,8 +159,8 @@ def print_configuration_info(): print(" MSVS %s" % gyp.MSVSVersion.SelectVisualStudioVersion().Description()) elif sys.platform in ("linux", "linux2"): print(" Linux %s" % " ".join(platform.linux_distribution())) - print(" Python %s" % platform.python_version()) - print(" PYTHONPATH=%s" % os.environ["PYTHONPATH"]) + print(f" Python {platform.python_version()}") + print(f" PYTHONPATH={os.environ['PYTHONPATH']}") print() @@ -222,13 +219,9 @@ def run_test(self, test, fmt, i): res_msg = f" {res} {took:.3f}s" self.print_(res_msg) - if ( - stdout - and not stdout.endswith("PASSED\n") - and not (stdout.endswith("NO RESULT\n")) - ): + if stdout and not stdout.endswith(("PASSED\n", "NO RESULT\n")): print() - print("\n".join(" %s" % line for line in stdout.splitlines())) + print("\n".join(f" {line}" for line in stdout.splitlines())) elif not self.isatty: print()