Skip to content

Commit 8bcb1fb

Browse files
joaocgreisrvagg
authored andcommitted
gyp: Python 3 Windows fixes
PR-URL: #1843 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <r@va.gg> Reviewed-By: Matt Cowley <me@mattcowley.co.uk> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 2e24d0a commit 8bcb1fb

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ matrix:
6464
allow_failures:
6565
- os: osx
6666
env: NODE_GYP_FORCE_PYTHON=python3 EXPERIMENTAL_NODE_GYP_PYTHON3=1
67-
- env: >-
68-
PATH=/c/Python37:/c/Python37/Scripts:$PATH
69-
NODE_GYP_FORCE_PYTHON=/c/Python37/python.exe
70-
EXPERIMENTAL_NODE_GYP_PYTHON3=1
7167
install:
7268
#- pip install -r requirements.txt
7369
- pip install flake8 # pytest # add another testing frameworks later

gyp/pylib/gyp/MSVSNew.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def MakeGuid(name, seed='msvs_new'):
4545
not change when the project for a target is rebuilt.
4646
"""
4747
# Calculate a MD5 signature for the seed and name.
48-
d = hashlib.md5(str(seed) + str(name)).hexdigest().upper()
48+
d = hashlib.md5((str(seed) + str(name)).encode('utf-8')).hexdigest().upper()
4949
# Convert most of the signature to GUID form (discard the rest)
5050
guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20]
5151
+ '-' + d[20:32] + '}')

gyp/pylib/gyp/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ def close(self):
394394
os.unlink(self.tmp_path)
395395
raise
396396

397+
def write(self, s):
398+
self.tmp_file.write(s.encode('utf-8'))
399+
397400
return Writer()
398401

399402

gyp/pylib/gyp/easy_xml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False,
120120

121121
default_encoding = locale.getdefaultlocale()[1]
122122
if default_encoding.upper() != encoding.upper():
123-
xml_string = xml_string.decode(default_encoding).encode(encoding)
123+
xml_string = xml_string.encode(encoding)
124124

125125
# Get the old content
126126
try:
@@ -132,7 +132,7 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False,
132132

133133
# It has changed, write it
134134
if existing != xml_string:
135-
f = open(path, 'w')
135+
f = open(path, 'wb')
136136
f.write(xml_string)
137137
f.close()
138138

gyp/pylib/gyp/generator/msvs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,8 +1753,8 @@ def _CollapseSingles(parent, node):
17531753
# such projects up one level.
17541754
if (type(node) == dict and
17551755
len(node) == 1 and
1756-
node.keys()[0] == parent + '.vcproj'):
1757-
return node[node.keys()[0]]
1756+
list(node)[0] == parent + '.vcproj'):
1757+
return node[list(node)[0]]
17581758
if type(node) != dict:
17591759
return node
17601760
for child in node:
@@ -1773,8 +1773,8 @@ def _GatherSolutionFolders(sln_projects, project_objects, flat):
17731773
# Walk down from the top until we hit a folder that has more than one entry.
17741774
# In practice, this strips the top-level "src/" dir from the hierarchy in
17751775
# the solution.
1776-
while len(root) == 1 and type(root[root.keys()[0]]) == dict:
1777-
root = root[root.keys()[0]]
1776+
while len(root) == 1 and type(root[list(root)[0]]) == dict:
1777+
root = root[list(root)[0]]
17781778
# Collapse singles.
17791779
root = _CollapseSingles('', root)
17801780
# Merge buckets until everything is a root entry.

0 commit comments

Comments
 (0)