-
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
Don't use the "-2" flag with the py.exe launcher on Windows #2131
Conversation
I will update the commit message(s) to follow the commit guidelines, and probably squash them into one commit, unless maintainers prefer it broken up like this. |
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.
Very impressive first time contribution! Thanks for seeing this and fixing it.
ee90b5c
to
ae8e2b3
Compare
Some additional notes:
|
lib/find-python.js
Outdated
`- executing "${this.pyLauncher}" to get Python 2 executable path`) | ||
this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false, | ||
`- executing "${this.pyLauncher}" to get Python executable path`) | ||
this.run(this.pyLauncher, [...this.argsExecutable], 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.
I don't think [...this.argsExecutable]
needs to be an array anymore. I'm not sure if the ... is needed, either.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
https://stackoverflow.com/questions/31048953/what-do-these-three-dots-in-react-do
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.
Small moves please. Leave this PR as is and allow maintainers time to review it as is.
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.
Tests pass with the following:
this.run(this.pyLauncher, [...this.argsExecutable], false, | |
this.run(this.pyLauncher, this.argsExecutable, 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.
Will wait for updates from reviewers, thanks.
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.
yeah, go with your suggestion, it's correct 👍
If that's true then this change seems good to me! I don't think I have a good way to vet that claim but I imagine @cclauss has more of a clue than me about such things so 👍 . |
Hi, @rvagg. Regarding this:
I read that in the documentation of the
To verify this, I started with a Windows install with no Python on the system, and installed Python 2 and 3 with the |
By the way: The thing about "per-user installs being preferred over system-wide ones" sounded a little odd (what if Python 3 is installed system-wide, and Python 2 is installed just for the current user? Would it launch Python 2 by default?) I tried to reproduce this behavior as described in the documentation, but I couldn't reproduce it. I tested with the following Pythons installed:
C:\Users\[User]>py -0
Installed Pythons found by py Launcher for Windows
-3.8-32 *
-3.7-32
-2.7-32 The asterisk indicates the default Python that C:\Users\[User]>py
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'C:\\Program Files (x86)\\Python38-32\\python.exe' I can't reproduce the "per-user install takes precedence over a system-wide install" at all. And I can't think of an official way to install the same version of Python both system-wide and per-user, because the install wizard won't let you do that. (You can install the 64-bit and 32-bit editions of the same Python version, but the |
Now that node-gyp supports both Python 2 and Python 3, We don't need to explicitly try to find only Python 2. Fixes: nodejs#2130 Refs: https://docs.python.org/3/using/windows.html#launcher
We no longer use this flag, so testing for it would understandably fail!
ae8e2b3
to
ee0b793
Compare
Force pushed with the code change discussed above. Also added this to the bottom of the first commit:
Happy to adjust or remove that if requested, just let me now. |
The failing tests are unrelated to these changes. Please do not make further modifications. Keep it simple and give maintainers time to review your work. Further ongoning code changes and more paragraphs of text will only slow down the review process. Force push is frowned upon in Node.js repos. |
all sounds good, and py.exe is an official Python thing too, correct? so we'd expect to see this installed by default on Windows systems with some version of Python installed? Has it been shipping for long enough to likely be everywhere that Python is on Windows? |
Yes. |
I have the ability to test things and report back / explain the nitty-gritty technical details, so please feel free to direct mention me (@DeeDeeG) if there is anything you need. |
Now that node-gyp supports both Python 2 and Python 3, We don't need to explicitly try to find only Python 2. Fixes: #2130 Refs: https://docs.python.org/3/using/windows.html#launcher PR-URL: #2131 Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
excellent work, landed in c255ffb, will get it into v7.0.0 this week |
Checklist
npm install && npm test
passesDescription of change
Fixes #2130
The
py.exe
launcher for Windows helps to locate Python on the system.The
-2
or-3
flags can specify a major version to find. Now thatnode-gyp
supports Python 3, it makes sense to not restrict thepy.exe
launcher to only finding Python 2. It would be advantageous to let it find Python 3 as well.The
py.exe
launcher prefers newer (higher version number) Python when multiple versions are found. (i.e. it prefers Python 3 over Python 2 if both are available).