-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Release proposal: v5.0.4 #1893
Release proposal: v5.0.4 #1893
Changes from all commits
18d5c7c
fa0ed4a
da1b031
1267b4d
2e24d0a
8bcb1fb
5553cd9
1cb4708
3f4972c
06019ba
a976151
785e527
1186e89
aab118e
5f3ed92
19dbc9a
60a4083
f753c16
36638af
1236869
b887c40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,44 @@ | |
|
||
import os | ||
import sys | ||
import subprocess | ||
|
||
PY3 = bytes != str | ||
|
||
# Below IsCygwin() function copied from pylib/gyp/common.py | ||
def IsCygwin(): | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insert the if PY3: stdout = stdout.decode("utf-8") code from #1890. |
||
except Exception: | ||
return False | ||
|
||
|
||
def UnixifyPath(path): | ||
try: | ||
if not IsCygwin(): | ||
return path | ||
out = subprocess.Popen(["cygpath", "-u", path], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT) | ||
stdout, stderr = out.communicate() | ||
if PY3: | ||
stdout = stdout.decode("utf-8") | ||
return str(stdout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insert the if PY3: stdout = stdout.decode("utf-8") code from #1890. |
||
except Exception: | ||
return path | ||
|
||
|
||
# Make sure we're using the version of pylib in this repo, not one installed | ||
# elsewhere on the system. | ||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'pylib')) | ||
# elsewhere on the system. Also convert to Unix style path on Cygwin systems, | ||
# else the 'gyp' library will not be found | ||
path = UnixifyPath(sys.argv[0]) | ||
sys.path.insert(0, os.path.join(os.path.dirname(path), 'pylib')) | ||
import gyp | ||
|
||
if __name__ == '__main__': | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ | |
import re | ||
import tempfile | ||
import sys | ||
import subprocess | ||
|
||
PY3 = bytes != str | ||
|
||
|
||
# A minimal memoizing decorator. It'll blow up if the args aren't immutable, | ||
|
@@ -337,11 +340,16 @@ def WriteOnDiff(filename): | |
class Writer(object): | ||
"""Wrapper around file which only covers the target if it differs.""" | ||
def __init__(self): | ||
# On Cygwin remove the "dir" argument because `C:` prefixed paths are treated as relative, | ||
# consequently ending up with current dir "/cygdrive/c/..." being prefixed to those, which was | ||
# obviously a non-existent path, for example: "/cygdrive/c/<some folder>/C:\<my win style abs path>". | ||
# See https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp for more details | ||
base_temp_dir = "" if IsCygwin() else os.path.dirname(filename) | ||
# Pick temporary file. | ||
tmp_fd, self.tmp_path = tempfile.mkstemp( | ||
suffix='.tmp', | ||
prefix=os.path.split(filename)[1] + '.gyp.', | ||
dir=os.path.split(filename)[0]) | ||
dir=base_temp_dir) | ||
try: | ||
self.tmp_file = os.fdopen(tmp_fd, 'wb') | ||
except Exception: | ||
|
@@ -394,6 +402,9 @@ def close(self): | |
os.unlink(self.tmp_path) | ||
raise | ||
|
||
def write(self, s): | ||
self.tmp_file.write(s.encode('utf-8')) | ||
|
||
return Writer() | ||
|
||
|
||
|
@@ -608,3 +619,16 @@ def CrossCompileRequested(): | |
os.environ.get('AR_target') or | ||
os.environ.get('CC_target') or | ||
os.environ.get('CXX_target')) | ||
|
||
def IsCygwin(): | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Insert the if PY3: stdout = stdout.decode("utf-8") code from #1890. |
||
except Exception: | ||
return False | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This # should be removed so that we use Py37 instead of Py36.