Skip to content

Commit 8d60afa

Browse files
committed
Remove support for Python 2
1 parent cc1cbce commit 8d60afa

37 files changed

+210
-243
lines changed

README.md

+4-10
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,22 @@ Depending on your operating system, you will need to install:
3030

3131
### On Unix
3232

33-
* Python v2.7, v3.5, v3.6, v3.7, or v3.8
33+
* Python v3.5, v3.6, v3.7, v3.8, or v3.9
3434
* `make`
3535
* A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org)
3636

3737
### On macOS
3838

3939
**ATTENTION**: If your Mac has been _upgraded_ to macOS Catalina (10.15), please read [macOS_Catalina.md](macOS_Catalina.md).
4040

41-
* Python v2.7, v3.5, v3.6, v3.7, or v3.8
41+
* Python v3.5, v3.6, v3.7, v3.8, or v3.9
4242
* [Xcode](https://developer.apple.com/xcode/download/)
4343
* You also need to install the `XCode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode installed, you can find them under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`. This step will install `clang`, `clang++`, and `make`.
4444

4545
### On Windows
4646

4747
Install the current version of Python from the [Microsoft Store package](https://docs.python.org/3/using/windows.html#the-microsoft-store-package).
4848

49-
#### Option 1
50-
51-
Install all the required tools and configurations using Microsoft's [windows-build-tools](https://github.com./felixrieseberg/windows-build-tools) using `npm install --global windows-build-tools` from an elevated PowerShell or CMD.exe (run as Administrator).
52-
53-
#### Option 2
54-
5549
Install tools and configuration manually:
5650
* Install Visual C++ Build Environment: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools)
5751
(using "Visual C++ build tools" workload) or [Visual Studio 2017 Community](https://visualstudio.microsoft.com/pl/thank-you-downloading-visual-studio/?sku=Community)
@@ -64,8 +58,8 @@ Install tools and configuration manually:
6458

6559
### Configuring Python Dependency
6660

67-
`node-gyp` requires that you have installed a compatible version of Python, one of: v2.7, v3.5, v3.6,
68-
v3.7, or v3.8. If you have multiple Python versions installed, you can identify which Python
61+
`node-gyp` requires that you have installed a compatible version of Python, one of: v3.5, v3.6,
62+
v3.7, v3.8, or v3.9. If you have multiple Python versions installed, you can identify which Python
6963
version `node-gyp` should use in one of the following ways:
7064

7165
1. by setting the `--python` command-line option, e.g.:

gyp/pylib/gyp/MSVSNew.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def MakeGuid(name, seed="msvs_new"):
6969
# ------------------------------------------------------------------------------
7070

7171

72-
class MSVSSolutionEntry(object):
72+
class MSVSSolutionEntry:
7373
def __cmp__(self, other):
7474
# Sort by name then guid (so things are in order on vs2008).
7575
return cmp((self.name, self.get_guid()), (other.name, other.get_guid()))
@@ -190,7 +190,7 @@ def set_msbuild_toolset(self, msbuild_toolset):
190190
# ------------------------------------------------------------------------------
191191

192192

193-
class MSVSSolution(object):
193+
class MSVSSolution:
194194
"""Visual Studio solution."""
195195

196196
def __init__(
@@ -292,14 +292,14 @@ def Write(self, writer=gyp.common.WriteOnDiff):
292292
if e.items:
293293
f.write("\tProjectSection(SolutionItems) = preProject\r\n")
294294
for i in e.items:
295-
f.write("\t\t%s = %s\r\n" % (i, i))
295+
f.write(f"\t\t{i} = {i}\r\n")
296296
f.write("\tEndProjectSection\r\n")
297297

298298
if isinstance(e, MSVSProject):
299299
if e.dependencies:
300300
f.write("\tProjectSection(ProjectDependencies) = postProject\r\n")
301301
for d in e.dependencies:
302-
f.write("\t\t%s = %s\r\n" % (d.get_guid(), d.get_guid()))
302+
f.write(f"\t\t{d.get_guid()} = {d.get_guid()}\r\n")
303303
f.write("\tEndProjectSection\r\n")
304304

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

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

368368
f.write("EndGlobal\r\n")

gyp/pylib/gyp/MSVSProject.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# ------------------------------------------------------------------------------
1010

1111

12-
class Tool(object):
12+
class Tool:
1313
"""Visual Studio tool."""
1414

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

3333

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

3737
def __init__(self, name, contents=None):
@@ -48,7 +48,7 @@ def __init__(self, name, contents=None):
4848
# ------------------------------------------------------------------------------
4949

5050

51-
class Writer(object):
51+
class Writer:
5252
"""Visual Studio XML project writer."""
5353

5454
def __init__(self, project_path, version, name, guid=None, platforms=None):

gyp/pylib/gyp/MSVSSettings.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
1515
"""
1616

17-
from __future__ import print_function
1817

1918
from gyp import string_types
2019

@@ -36,7 +35,7 @@
3635
_msbuild_name_of_tool = {}
3736

3837

39-
class _Tool(object):
38+
class _Tool:
4039
"""Represents a tool used by MSVS or MSBuild.
4140
4241
Attributes:
@@ -68,7 +67,7 @@ def _GetMSBuildToolSettings(msbuild_settings, tool):
6867
return msbuild_settings.setdefault(tool.msbuild_name, {})
6968

7069

71-
class _Type(object):
70+
class _Type:
7271
"""Type of settings (Base class)."""
7372

7473
def ValidateMSVS(self, value):
@@ -195,7 +194,7 @@ class _Enumeration(_Type):
195194
def __init__(self, label_list, new=None):
196195
_Type.__init__(self)
197196
self._label_list = label_list
198-
self._msbuild_values = set(value for value in label_list if value is not None)
197+
self._msbuild_values = {value for value in label_list if value is not None}
199198
if new is not None:
200199
self._msbuild_values.update(new)
201200

@@ -342,7 +341,7 @@ def _Translate(value, msbuild_settings):
342341
if value == "true":
343342
tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
344343
if "AdditionalOptions" in tool_settings:
345-
new_flags = "%s %s" % (tool_settings["AdditionalOptions"], flag)
344+
new_flags = "{} {}".format(tool_settings["AdditionalOptions"], flag)
346345
else:
347346
new_flags = flag
348347
tool_settings["AdditionalOptions"] = new_flags
@@ -536,14 +535,14 @@ def _ValidateSettings(validators, settings, stderr):
536535
tool_validators[setting](value)
537536
except ValueError as e:
538537
print(
539-
"Warning: for %s/%s, %s" % (tool_name, setting, e),
538+
f"Warning: for {tool_name}/{setting}, {e}",
540539
file=stderr,
541540
)
542541
else:
543542
_ValidateExclusionSetting(
544543
setting,
545544
tool_validators,
546-
("Warning: unrecognized setting %s/%s" % (tool_name, setting)),
545+
(f"Warning: unrecognized setting {tool_name}/{setting}"),
547546
stderr,
548547
)
549548

gyp/pylib/gyp/MSVSToolFile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import gyp.easy_xml as easy_xml
88

99

10-
class Writer(object):
10+
class Writer:
1111
"""Visual Studio XML tool file writer."""
1212

1313
def __init__(self, tool_file_path, name):

gyp/pylib/gyp/MSVSUserFile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _QuoteWin32CommandLineArgs(args):
5353
return new_args
5454

5555

56-
class Writer(object):
56+
class Writer:
5757
"""Visual Studio XML user user file writer."""
5858

5959
def __init__(self, user_file_path, version, name):
@@ -93,7 +93,7 @@ def AddDebugSettings(
9393
abs_command = _FindCommandInPath(command[0])
9494

9595
if environment and isinstance(environment, dict):
96-
env_list = ['%s="%s"' % (key, val) for (key, val) in environment.items()]
96+
env_list = [f'{key}="{val}"' for (key, val) in environment.items()]
9797
environment = " ".join(env_list)
9898
else:
9999
environment = ""

gyp/pylib/gyp/MSVSUtil.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _SuffixName(name, suffix):
5555
Target name with suffix added (foo_suffix#target)
5656
"""
5757
parts = name.rsplit("#", 1)
58-
parts[0] = "%s_%s" % (parts[0], suffix)
58+
parts[0] = "{}_{}".format(parts[0], suffix)
5959
return "#".join(parts)
6060

6161

@@ -160,7 +160,7 @@ def _GetPdbPath(target_dict, config_name, vars):
160160
return pdb_path
161161

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

166166
return pdb_path

gyp/pylib/gyp/MSVSVersion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def JoinPath(*args):
1818
return os.path.normpath(os.path.join(*args))
1919

2020

21-
class VisualStudioVersion(object):
21+
class VisualStudioVersion:
2222
"""Information regarding a version of Visual Studio."""
2323

2424
def __init__(
@@ -235,7 +235,7 @@ def _RegistryGetValueUsingWinReg(key, value):
235235
assert root == "HKLM" # Only need HKLM for now.
236236
with OpenKey(HKEY_LOCAL_MACHINE, subkey) as hkey:
237237
return QueryValueEx(hkey, value)[0]
238-
except WindowsError:
238+
except OSError:
239239
return None
240240

241241

gyp/pylib/gyp/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Use of this source code is governed by a BSD-style license that can be
55
# found in the LICENSE file.
66

7-
from __future__ import print_function
87

98
import copy
109
import gyp.input
@@ -193,7 +192,7 @@ def ShlexEnv(env_name):
193192

194193
def FormatOpt(opt, value):
195194
if opt.startswith("--"):
196-
return "%s=%s" % (opt, value)
195+
return f"{opt}={value}"
197196
return opt + value
198197

199198

gyp/pylib/gyp/common.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
2222
# among other "problems".
23-
class memoize(object):
23+
class memoize:
2424
def __init__(self, func):
2525
self.func = func
2626
self.cache = {}
@@ -348,7 +348,7 @@ def WriteOnDiff(filename):
348348
the target if it differs (on close).
349349
"""
350350

351-
class Writer(object):
351+
class Writer:
352352
"""Wrapper around file which only covers the target if it differs."""
353353

354354
def __init__(self):
@@ -566,8 +566,8 @@ def pop(self, last=True): # pylint: disable=W0221
566566

567567
def __repr__(self):
568568
if not self:
569-
return "%s()" % (self.__class__.__name__,)
570-
return "%s(%r)" % (self.__class__.__name__, list(self))
569+
return f"{self.__class__.__name__}()"
570+
return "{}({!r})".format(self.__class__.__name__, list(self))
571571

572572
def __eq__(self, other):
573573
if isinstance(other, OrderedSet):

gyp/pylib/gyp/easy_xml.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
8484
rest = specification[1:]
8585
if rest and isinstance(rest[0], dict):
8686
for at, val in sorted(rest[0].items()):
87-
xml_parts.append(' %s="%s"' % (at, _XmlEscape(val, attr=True)))
87+
xml_parts.append(' {}="{}"'.format(at, _XmlEscape(val, attr=True)))
8888
rest = rest[1:]
8989
if rest:
9090
xml_parts.append(">")
@@ -101,7 +101,7 @@ def _ConstructContentList(xml_parts, specification, pretty, level=0):
101101
_ConstructContentList(xml_parts, child_spec, pretty, level + 1)
102102
if multi_line and indentation:
103103
xml_parts.append(indentation)
104-
xml_parts.append("</%s>%s" % (name, new_line))
104+
xml_parts.append(f"</{name}>{new_line}")
105105
else:
106106
xml_parts.append("/>%s" % new_line)
107107

@@ -125,9 +125,9 @@ def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False, win32=False
125125

126126
# Get the old content
127127
try:
128-
with open(path, "r") as file:
128+
with open(path) as file:
129129
existing = file.read()
130-
except IOError:
130+
except OSError:
131131
existing = None
132132

133133
# It has changed, write it

gyp/pylib/gyp/flock_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main(args):
1818
executor.Dispatch(args)
1919

2020

21-
class FlockTool(object):
21+
class FlockTool:
2222
"""This class emulates the 'flock' command."""
2323

2424
def Dispatch(self, args):

gyp/pylib/gyp/generator/analyzer.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
then the "all" target includes "b1" and "b2".
6363
"""
6464

65-
from __future__ import print_function
6665

6766
import gyp.common
6867
import json
@@ -216,7 +215,7 @@ def _ExtractSources(target, target_dict, toplevel_dir):
216215
return results
217216

218217

219-
class Target(object):
218+
class Target:
220219
"""Holds information about a particular target:
221220
deps: set of Targets this Target depends upon. This is not recursive, only the
222221
direct dependent Targets.
@@ -252,7 +251,7 @@ def __init__(self, name):
252251
self.is_or_has_linked_ancestor = False
253252

254253

255-
class Config(object):
254+
class Config:
256255
"""Details what we're looking for
257256
files: set of files to search for
258257
targets: see file description for details."""
@@ -271,10 +270,10 @@ def Init(self, params):
271270
if not config_path:
272271
return
273272
try:
274-
f = open(config_path, "r")
273+
f = open(config_path)
275274
config = json.load(f)
276275
f.close()
277-
except IOError:
276+
except OSError:
278277
raise Exception("Unable to open file " + config_path)
279278
except ValueError as e:
280279
raise Exception("Unable to parse config file " + config_path + str(e))
@@ -586,7 +585,7 @@ def _WriteOutput(params, **values):
586585
f = open(output_path, "w")
587586
f.write(json.dumps(values) + "\n")
588587
f.close()
589-
except IOError as e:
588+
except OSError as e:
590589
print("Error writing to output file", output_path, str(e))
591590

592591

@@ -627,7 +626,7 @@ def CalculateVariables(default_variables, params):
627626
default_variables.setdefault("OS", operating_system)
628627

629628

630-
class TargetCalculator(object):
629+
class TargetCalculator:
631630
"""Calculates the matching test_targets and matching compile_targets."""
632631

633632
def __init__(

0 commit comments

Comments
 (0)