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

gyp: update gyp to v0.8.0 #2318

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions gyp/.github/workflows/Python_tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# TODO: Enable os: windows-latest
# TODO: Enable python-version: 3.5
# TODO: Enable pytest --doctest-modules

name: Python_tests
Expand All @@ -9,10 +8,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 15
max-parallel: 8
matrix:
os: [macos-latest, ubuntu-latest] # , windows-latest]
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
16 changes: 16 additions & 0 deletions gyp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [0.8.0](https://www.github.com/nodejs/gyp-next/compare/v0.7.0...v0.8.0) (2021-01-15)


### ⚠ BREAKING CHANGES

* remove support for Python 2

### Bug Fixes

* revert posix build job ([#86](https://www.github.com/nodejs/gyp-next/issues/86)) ([39dc34f](https://www.github.com/nodejs/gyp-next/commit/39dc34f0799c074624005fb9bbccf6e028607f9d))


### gyp

* Remove support for Python 2 ([#88](https://www.github.com/nodejs/gyp-next/issues/88)) ([22e4654](https://www.github.com/nodejs/gyp-next/commit/22e465426fd892403c95534229af819a99c3f8dc))

## [0.7.0](https://www.github.com/nodejs/gyp-next/compare/v0.6.2...v0.7.0) (2020-12-17)


Expand Down
12 changes: 3 additions & 9 deletions gyp/gyp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
import sys
import subprocess

PY3 = bytes != str


def IsCygwin():
# Function copied from pylib/gyp/common.py
try:
out = subprocess.Popen(
"uname", stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
stdout, stderr = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return "CYGWIN" in str(stdout)
stdout, _ = out.communicate()
return "CYGWIN" in stdout.decode("utf-8")
except Exception:
return False

Expand All @@ -33,9 +29,7 @@ def UnixifyPath(path):
["cygpath", "-u", path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
stdout, _ = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return str(stdout)
return stdout.decode("utf-8")
except Exception:
return path

Expand Down
19 changes: 8 additions & 11 deletions gyp/pylib/gyp/MSVSNew.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@

import gyp.common

try:
cmp
except NameError:

def cmp(x, y):
return (x > y) - (x < y)
def cmp(x, y):
return (x > y) - (x < y)


# Initialize random number generator
Expand Down Expand Up @@ -69,7 +66,7 @@ def MakeGuid(name, seed="msvs_new"):
# ------------------------------------------------------------------------------


class MSVSSolutionEntry(object):
class MSVSSolutionEntry:
def __cmp__(self, other):
# Sort by name then guid (so things are in order on vs2008).
return cmp((self.name, self.get_guid()), (other.name, other.get_guid()))
Expand Down Expand Up @@ -190,7 +187,7 @@ def set_msbuild_toolset(self, msbuild_toolset):
# ------------------------------------------------------------------------------


class MSVSSolution(object):
class MSVSSolution:
"""Visual Studio solution."""

def __init__(
Expand Down Expand Up @@ -292,14 +289,14 @@ def Write(self, writer=gyp.common.WriteOnDiff):
if e.items:
f.write("\tProjectSection(SolutionItems) = preProject\r\n")
for i in e.items:
f.write("\t\t%s = %s\r\n" % (i, i))
f.write(f"\t\t{i} = {i}\r\n")
f.write("\tEndProjectSection\r\n")

if isinstance(e, MSVSProject):
if e.dependencies:
f.write("\tProjectSection(ProjectDependencies) = postProject\r\n")
for d in e.dependencies:
f.write("\t\t%s = %s\r\n" % (d.get_guid(), d.get_guid()))
f.write(f"\t\t{d.get_guid()} = {d.get_guid()}\r\n")
f.write("\tEndProjectSection\r\n")

f.write("EndProject\r\n")
Expand All @@ -310,7 +307,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
# Configurations (variants)
f.write("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n")
for v in self.variants:
f.write("\t\t%s = %s\r\n" % (v, v))
f.write(f"\t\t{v} = {v}\r\n")
f.write("\tEndGlobalSection\r\n")

# Sort config guids for easier diffing of solution changes.
Expand Down Expand Up @@ -362,7 +359,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
if not isinstance(e, MSVSFolder):
continue # Does not apply to projects, only folders
for subentry in e.entries:
f.write("\t\t%s = %s\r\n" % (subentry.get_guid(), e.get_guid()))
f.write(f"\t\t{subentry.get_guid()} = {e.get_guid()}\r\n")
f.write("\tEndGlobalSection\r\n")

f.write("EndGlobal\r\n")
Expand Down
6 changes: 3 additions & 3 deletions gyp/pylib/gyp/MSVSProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# ------------------------------------------------------------------------------


class Tool(object):
class Tool:
"""Visual Studio tool."""

def __init__(self, name, attrs=None):
Expand All @@ -31,7 +31,7 @@ def _GetSpecification(self):
return ["Tool", self._attrs]


class Filter(object):
class Filter:
"""Visual Studio filter - that is, a virtual folder."""

def __init__(self, name, contents=None):
Expand All @@ -48,7 +48,7 @@ def __init__(self, name, contents=None):
# ------------------------------------------------------------------------------


class Writer(object):
class Writer:
"""Visual Studio XML project writer."""

def __init__(self, project_path, version, name, guid=None, platforms=None):
Expand Down
26 changes: 11 additions & 15 deletions gyp/pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
"""

from __future__ import print_function

from gyp import string_types

import sys
import re
import sys

# Dictionaries of settings validators. The key is the tool name, the value is
# a dictionary mapping setting names to validation functions.
Expand All @@ -36,7 +32,7 @@
_msbuild_name_of_tool = {}


class _Tool(object):
class _Tool:
"""Represents a tool used by MSVS or MSBuild.

Attributes:
Expand Down Expand Up @@ -68,7 +64,7 @@ def _GetMSBuildToolSettings(msbuild_settings, tool):
return msbuild_settings.setdefault(tool.msbuild_name, {})


class _Type(object):
class _Type:
"""Type of settings (Base class)."""

def ValidateMSVS(self, value):
Expand Down Expand Up @@ -110,11 +106,11 @@ class _String(_Type):
"""A setting that's just a string."""

def ValidateMSVS(self, value):
if not isinstance(value, string_types):
if not isinstance(value, str):
raise ValueError("expected string; got %r" % value)

def ValidateMSBuild(self, value):
if not isinstance(value, string_types):
if not isinstance(value, str):
raise ValueError("expected string; got %r" % value)

def ConvertToMSBuild(self, value):
Expand All @@ -126,11 +122,11 @@ class _StringList(_Type):
"""A settings that's a list of strings."""

def ValidateMSVS(self, value):
if not isinstance(value, string_types) and not isinstance(value, list):
if not isinstance(value, (list, str)):
raise ValueError("expected string list; got %r" % value)

def ValidateMSBuild(self, value):
if not isinstance(value, string_types) and not isinstance(value, list):
if not isinstance(value, (list, str)):
raise ValueError("expected string list; got %r" % value)

def ConvertToMSBuild(self, value):
Expand Down Expand Up @@ -195,7 +191,7 @@ class _Enumeration(_Type):
def __init__(self, label_list, new=None):
_Type.__init__(self)
self._label_list = label_list
self._msbuild_values = set(value for value in label_list if value is not None)
self._msbuild_values = {value for value in label_list if value is not None}
if new is not None:
self._msbuild_values.update(new)

Expand Down Expand Up @@ -342,7 +338,7 @@ def _Translate(value, msbuild_settings):
if value == "true":
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
if "AdditionalOptions" in tool_settings:
new_flags = "%s %s" % (tool_settings["AdditionalOptions"], flag)
new_flags = "{} {}".format(tool_settings["AdditionalOptions"], flag)
else:
new_flags = flag
tool_settings["AdditionalOptions"] = new_flags
Expand Down Expand Up @@ -536,14 +532,14 @@ def _ValidateSettings(validators, settings, stderr):
tool_validators[setting](value)
except ValueError as e:
print(
"Warning: for %s/%s, %s" % (tool_name, setting, e),
f"Warning: for {tool_name}/{setting}, {e}",
file=stderr,
)
else:
_ValidateExclusionSetting(
setting,
tool_validators,
("Warning: unrecognized setting %s/%s" % (tool_name, setting)),
(f"Warning: unrecognized setting {tool_name}/{setting}"),
stderr,
)

Expand Down
5 changes: 1 addition & 4 deletions gyp/pylib/gyp/MSVSSettings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import unittest
import gyp.MSVSSettings as MSVSSettings

try:
from StringIO import StringIO # Python 2
except ImportError:
from io import StringIO # Python 3
from io import StringIO


class TestSequenceFunctions(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion gyp/pylib/gyp/MSVSToolFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import gyp.easy_xml as easy_xml


class Writer(object):
class Writer:
"""Visual Studio XML tool file writer."""

def __init__(self, tool_file_path, name):
Expand Down
4 changes: 2 additions & 2 deletions gyp/pylib/gyp/MSVSUserFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _QuoteWin32CommandLineArgs(args):
return new_args


class Writer(object):
class Writer:
"""Visual Studio XML user user file writer."""

def __init__(self, user_file_path, version, name):
Expand Down Expand Up @@ -93,7 +93,7 @@ def AddDebugSettings(
abs_command = _FindCommandInPath(command[0])

if environment and isinstance(environment, dict):
env_list = ['%s="%s"' % (key, val) for (key, val) in environment.items()]
env_list = [f'{key}="{val}"' for (key, val) in environment.items()]
environment = " ".join(env_list)
else:
environment = ""
Expand Down
4 changes: 2 additions & 2 deletions gyp/pylib/gyp/MSVSUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _SuffixName(name, suffix):
Target name with suffix added (foo_suffix#target)
"""
parts = name.rsplit("#", 1)
parts[0] = "%s_%s" % (parts[0], suffix)
parts[0] = "{}_{}".format(parts[0], suffix)
return "#".join(parts)


Expand Down Expand Up @@ -160,7 +160,7 @@ def _GetPdbPath(target_dict, config_name, vars):
return pdb_path

pdb_base = target_dict.get("product_name", target_dict["target_name"])
pdb_base = "%s.%s.pdb" % (pdb_base, TARGET_TYPE_EXT[target_dict["type"]])
pdb_base = "{}.{}.pdb".format(pdb_base, TARGET_TYPE_EXT[target_dict["type"]])
pdb_path = vars["PRODUCT_DIR"] + "/" + pdb_base

return pdb_path
Expand Down
24 changes: 6 additions & 18 deletions gyp/pylib/gyp/MSVSVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
import sys
import glob

PY3 = bytes != str


def JoinPath(*args):
return os.path.normpath(os.path.join(*args))


class VisualStudioVersion(object):
class VisualStudioVersion:
"""Information regarding a version of Visual Studio."""

def __init__(
Expand Down Expand Up @@ -176,9 +174,7 @@ def _RegistryQueryBase(sysdir, key, value):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Obtain the stdout from reg.exe, reading to the end so p.returncode is valid
# Note that the error text may be in [1] in some cases
text = p.communicate()[0]
if PY3:
text = text.decode("utf-8")
text = p.communicate()[0].decode("utf-8")
# Check return code from reg.exe; officially 0==success and 1==error
if p.returncode:
return None
Expand Down Expand Up @@ -221,21 +217,15 @@ def _RegistryGetValueUsingWinReg(key, value):
value: The particular registry value to read.
Return:
contents of the registry key's value, or None on failure. Throws
ImportError if _winreg is unavailable.
ImportError if winreg is unavailable.
"""
try:
# Python 2
from _winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
except ImportError:
# Python 3
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx

from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
try:
root, subkey = key.split("\\", 1)
assert root == "HKLM" # Only need HKLM for now.
with OpenKey(HKEY_LOCAL_MACHINE, subkey) as hkey:
return QueryValueEx(hkey, value)[0]
except WindowsError:
except OSError:
return None


Expand Down Expand Up @@ -426,9 +416,7 @@ def _ConvertToCygpath(path):
"""Convert to cygwin path if we are using cygwin."""
if sys.platform == "cygwin":
p = subprocess.Popen(["cygpath", path], stdout=subprocess.PIPE)
path = p.communicate()[0].strip()
if PY3:
path = path.decode("utf-8")
path = p.communicate()[0].decode("utf-8").strip()
return path


Expand Down
Loading