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 should use Python 3 not Python #2660

Closed
wants to merge 4 commits into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented May 10, 2022

See #2654

Checklist
  • npm install && npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

@@ -5,4 +5,4 @@

set -e
base=$(dirname "$0")
exec python "${base}/gyp_main.py" "$@"
exec python3 "${base}/gyp_main.py" "$@"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this variable consider python-related settings described here?
https://github.com/nodejs/node-gyp#configuring-python-dependency

Copy link
Contributor

@DeeDeeG DeeDeeG May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR would effectively do what you're suggesting @biodranik. (I haven't re-reviewed my own PR in a while, so I'd want a chance to do that before/if it got merged.)

(For those familiar with the deep workings of this repo: My PR would make gyp run with the Python binary found by find-python.js... find-python.js is the script that honors all those Python binary configuration options you linked to.)

Granted, most users with a Python binary that can run gyp have it accessible on their PATH as python and/or as python3. (Or they have some compatible Python as python and/or python3 on their PATH). So for most users, my PR is not needed.

For those who don't; for the few who rely exclusively on those Python binary configuration options node-gyp offers to pass find-python.js, who don't have such a compatible-with-gyp Python binary on their PATH, it feels like the configs are a bit of a lie, and them not being used to actually run gyp is a bit of a broken promise (promise implied by the existence of the config options).

Copy link
Contributor

@DeeDeeG DeeDeeG May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... digging deeper and doing some quick testing... the file gyp/gyp modified by this PR is apparently never run by node-gyp. This file is a tiny bash script wrapper around gyp/gyp_main.py. node-gyp skips the wrapper in favor of running gyp/gyp_main.py directly.

It does so here:

$ ~/node-gyp/bin/node-gyp.js configure
gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.15.0 | linux | x64
gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/home/[user]/node-gyp/gyp/gyp_main.py',
[ . . . ]
gyp info spawn args ]

I also modified the gyp/gyp script to echo some stuff and touch a file at an absolute path, then ran node-gyp rebuild to see if anything happened. Nothing was echoed from gyp/gyp, and the file was not touched/was not present on my disk. So... I conclude the gyp/gyp script was not run by node-gyp.

(end of expanded info)

Given the above, I think this PR is fully unnecessary for the node-gyp repo, should make zero difference, as this is in a file that is not ever being run. (Might be of some use at https://github.com/nodejs/gyp-next??)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 to the fix. [ EDIT: Hmm, I think this PR does nothing in the context of node-gyp. (node-gyp never runs the file changed by this PR.) I explained it in another comment here: #2660 (comment) ]

nits:

  • This change should also be done in https://github.com/nodejs/gyp-next at some point.
  • This has a few extra/duplicate/irrelevant commits now (after a force push was apparently done on master branch recently).
  • Please merge this with a commit message prefix that will show on the CHANGELOG: (list here) such as fix:, gyp:, or python:. Or fix(gyp):, fix(python):...

@cclauss
Copy link
Contributor Author

cclauss commented Jun 10, 2022

Closing in favor of #2362

@cclauss cclauss closed this Jun 10, 2022
@cclauss cclauss deleted the gyp-should-use-Python-3-not-Python branch June 10, 2022 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants