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: cherrypick python3 changes to input.py from node-gyp #29140

Closed
wants to merge 1 commit into from

Conversation

@cclauss
Copy link
Contributor

commented Aug 15, 2019

Built on the lessons learned in #29130 if we bring all changes done to this file in node-gyp, that breaks our Travis CI tests so this PR cherrypicks only the Python 3 compatibility changes. These changes are somewhat complex because the complier module was removed in Python 3 in favor of ast which was introduced in Python 2.5.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@cclauss cclauss added the python label Aug 15, 2019

@cclauss cclauss requested a review from sam-github Aug 15, 2019

@targos
targos approved these changes Aug 15, 2019
Copy link
Member

left a comment

rubber-stamp

@nodejs-github-bot

This comment has been minimized.

@sam-github

This comment has been minimized.

Copy link
Member

commented Aug 15, 2019

I doubt this will pass ci's linter check on the commit messages, the 2 last commits should be squashed into the first --- I'd do it, but @cclauss your branch is protected, you'll have to unprotect it, or do the squashing yourself, or perhaps it can be done on landing if ci is green, I'm not sure if we do that.

@sam-github sam-github force-pushed the cclauss:py3_input.py-futurize-ast branch from b601fe0 to 83df0d2 Aug 15, 2019

@nodejs-github-bot

This comment has been minimized.

@sam-github sam-github force-pushed the cclauss:py3_input.py-futurize-ast branch from 83df0d2 to 227fbee Aug 15, 2019

@nodejs-github-bot

This comment has been minimized.

@cclauss cclauss force-pushed the cclauss:py3_input.py-futurize-ast branch from 227fbee to 4c7eae1 Aug 16, 2019

@sam-github sam-github force-pushed the cclauss:py3_input.py-futurize-ast branch from 4c7eae1 to f6885f4 Aug 16, 2019

@Trott
Trott approved these changes Aug 18, 2019
Copy link
Member

left a comment

Rubber-stamp LGTM

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@cclauss cclauss requested review from bnoordhuis and richardlau Aug 19, 2019

cclauss added a commit to cclauss/node that referenced this pull request Aug 19, 2019

@Trott Trott added the author ready label Aug 19, 2019

@Trott

This comment has been minimized.

Copy link
Member

commented Aug 20, 2019

What's the best way to land this? Squash everything into a single commit?

@cclauss cclauss referenced this pull request Aug 20, 2019
1 of 4 tasks complete
@gengjiawen

This comment has been minimized.

Copy link
Member

commented Aug 20, 2019

What's the best way to land this? Squash everything into a single commit?

+1 to squash the commit.

@cclauss

This comment has been minimized.

Copy link
Contributor Author

commented Aug 20, 2019

I usually squash like this combined with a well timed git rebase -i master.

However that creates merge commits and requires force push which does not work for this community. Can someone point me to the handful of commands that would allow me to squash without causing rework? A pointer here or I am @cclauss on Slack.

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Aug 20, 2019

@cclauss git pull --rebase && git rebase -i origin/master is what I use. That avoids the merge commit because it's basically a fast-forward.

@@ -709,6 +698,9 @@ def FixupPlatformCommand(cmd):

def ExpandVariables(input, phase, variables, build_file):
# Look for the pattern that gets expanded into variables
def to_utf8(s):
return s if isinstance(s, str) else s.decode("utf-8")

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Aug 20, 2019

Member

Style nit: single quotes.

This comment has been minimized.

Copy link
@cclauss

cclauss Aug 20, 2019

Author Contributor

The Python Software Foundation is going in the opposite direction so the muscle memory is building up but will fix.

raise GypError("%s while executing command '%s' in %s" %
(e, contents, build_file))

p_stdout, p_stderr = p.communicate('')
p_stdout = to_utf8(p_stdout)
p_stderr = to_utf8(p_stderr)

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Aug 20, 2019

Member

I suppose this might cause a runtime exception when the output contains e.g. latin1-encoded file paths?

This comment has been minimized.

Copy link
@cclauss

cclauss Aug 20, 2019

Author Contributor

You are correct. There is the old adage that you can never accurately guess encodings -- you have to be told. Should we leave as is or how should we resolve? We could catch the UnicodeDecodeError and then attempt to return s.decode('latin-1') and if we catch another UnicodeDecodeError just return s. Other approaches?

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Aug 20, 2019

Member

That sounds reasonable, that probably covers 99% of everyday use.

@cclauss cclauss force-pushed the cclauss:py3_input.py-futurize-ast branch from f6885f4 to bbde699 Aug 20, 2019

@nodejs-github-bot

This comment has been minimized.

@Trott

This comment has been minimized.

Copy link
Member

commented Aug 20, 2019

Landed in 3b92998

@Trott Trott closed this Aug 20, 2019

Trott added a commit that referenced this pull request Aug 20, 2019
gyp: futurize imput.py to prepare for Python 3
PR-URL: #29140
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
ronag added a commit to nxtedition/node that referenced this pull request Aug 23, 2019
gyp: futurize imput.py to prepare for Python 3
PR-URL: nodejs#29140
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
BridgeAR added a commit that referenced this pull request Sep 3, 2019
gyp: futurize imput.py to prepare for Python 3
PR-URL: #29140
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@BridgeAR BridgeAR referenced this pull request Sep 3, 2019
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
gyp: futurize imput.py to prepare for Python 3
PR-URL: nodejs#29140
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
gyp: futurize imput.py to prepare for Python 3
PR-URL: nodejs#29140
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.