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

Accept Python 3 by default #1844

Closed

Conversation

joaocgreis
Copy link
Member

@joaocgreis joaocgreis commented Jul 23, 2019

Checklist
Description of change

This depends on #1843, I will rebase when that PR lands. Only a971947 needs to be reviewed here.

This makes node-gyp accept Python 3 as compatible without needing EXPERIMENTAL_NODE_GYP_PYTHON3 in the environment. It also looks for python, python3, then python2 (in that order). Note that python is usually Python 2.

@nodejs/node-gyp please not that we cover little more than a basic hello world in our tests, there are probably parts of Gyp that are not covered and are not compatible with Python 3. We will have to be extra careful shipping the node-gyp version that includes this.

@joaocgreis
Copy link
Member Author

Copy link
Contributor

@cclauss cclauss left a comment

Choose a reason for hiding this comment

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

Awesome work here!

Can you please add a Python 3 on macOS on Travis CI test like #1846 just to make sure that is passing?

@joaocgreis
Copy link
Member Author

@cclauss I think #1846 is the proper place to do it, this PR might take a while to land. I'll rebase on top of that PR and adjust accordingly when it lands!

@joaocgreis
Copy link
Member Author

This is blocked by #1846, we can't land this with OSX failing.

@rvagg
Copy link
Member

rvagg commented Jul 26, 2019

seems good to me but I'm confused on whether the macos problems block this and #1843 or if they can land independently of that?

@cclauss
Copy link
Contributor

cclauss commented Jul 26, 2019

We can land this with the macOS tests still running in allow_failures mode. Our README clearly states that Python 3 is not supported which aligns with Travis CI's intent for allow_failures

[allow_failures] lets you add in experimental and preparatory builds to test against versions or configurations that you are not ready to officially support.

@joaocgreis
Copy link
Member Author

#1843 has landed. In there, node-gyp only uses Python 3 if EXPERIMENTAL_NODE_GYP_PYTHON3 is defined, so it should not break anything we currently have.

This PR removes that flag, making node-gyp accept Python 3. So, if a release is shipped with this PR, node-gyp will start using Python 3 in the users computers, and any issue we have will manifest there.

Currently, we know Python 3 is failing on osx, so shipping a release with this would break node-gyp on every osx machine that has Python 3 installed.

We know that our tests pass with Python 3 on Windows and Linux, but our tests don't have a good coverage of gyp. It's likely that there are modules out there that use parts of gyp that we don't test here, and those would be broken as well. GYP3 could help a lot with this.

So, we can't land this PR until all failures that we know of are fixed.

joaocgreis added a commit to JaneaSystems/node-gyp that referenced this pull request Jul 26, 2019
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch 2 times, most recently from 9be02bc to 9318e21 Compare July 26, 2019 15:19
joaocgreis added a commit to joaocgreis/node-gyp that referenced this pull request Jul 26, 2019
joaocgreis added a commit to JaneaSystems/node-gyp that referenced this pull request Jul 26, 2019
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch from 9318e21 to b154b07 Compare July 26, 2019 15:27
@sam-github
Copy link
Contributor

nodejs/node#29246 bumped into this.

I'm not sure what the plan is. If I'm missing the conversation elsewhere, pls point me there! I don't want to fragment an existing conversation.

node's tests can't pass on a py3-only machine until npm has a copy of node-gyp that supports py3.

Does npm even get node-gyp from this repo? :-( Sorry, you can see how late to this "party" I'm arriving.

@bnoordhuis
Copy link
Member

Does npm even get node-gyp from this repo?

Yes. :-)

@joaocgreis
Copy link
Member Author

@sam-github my comment above is still a valid summary of the current situation. Going forward, I believe the options on the table are either to use GYP3 (#1845) or fix the osx issues (@cclauss might be working on that).

This PR is ready to be rebased and land landed when we believe Python 3 support to be ready. However, this PR does not change any Python code, it only removes the block to run on Python 3.

@joaocgreis
Copy link
Member Author

Rebased to make Travis run again, but it's still red. Current status: #1844 (comment) and #1844 (comment)

@cclauss
Copy link
Contributor

cclauss commented Sep 25, 2019

The macOS error looks related to #1854 so I will attack it...

Fixed in Decode stdout on Python 3 #1890

cclauss added a commit to cclauss/node-gyp that referenced this pull request Sep 25, 2019
This was referenced Sep 25, 2019
@cclauss
Copy link
Contributor

cclauss commented Sep 26, 2019

Please rebase again to resolve conflict and ensure macOS now passes.

@cclauss
Copy link
Contributor

cclauss commented Sep 26, 2019

Once this PR lands, does NODE_GYP_FORCE_PYTHON=python3 still have to be set to use Py3?

  • On a machine that has both Python 2 and Python 3 installed?
  • On a machine that only has Python 3 installed?

joaocgreis added a commit to JaneaSystems/node-gyp that referenced this pull request Sep 26, 2019
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch from f7a28c3 to a490ca5 Compare September 26, 2019 13:09
joaocgreis added a commit to joaocgreis/node-gyp that referenced this pull request Sep 30, 2019
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch from a490ca5 to 1276037 Compare September 30, 2019 05:28
joaocgreis added a commit to joaocgreis/node-gyp that referenced this pull request Sep 30, 2019
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch from 1276037 to 3066b03 Compare September 30, 2019 05:47
joaocgreis added a commit to joaocgreis/node-gyp that referenced this pull request Sep 30, 2019
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch 2 times, most recently from 0ffb1aa to 167b563 Compare September 30, 2019 06:43
@joaocgreis joaocgreis force-pushed the joaocgreis-J7N-python3-3 branch from 167b563 to 05138c8 Compare September 30, 2019 06:47
@joaocgreis
Copy link
Member Author

Once this PR lands, does NODE_GYP_FORCE_PYTHON=python3 still have to be set to use Py3?

Doesn't "have" to, but I'd rather keep it in most (if not all) of the entries in Travis, since not having it was the reason we didn't know what Python was actually being run before. This is a good way to avoid surprises.

On a machine that has both Python 2 and Python 3 installed?
On a machine that only has Python 3 installed?

Without NODE_GYP_FORCE_PYTHON the code looks for python, then python3, then python2. Whatever exists first is what's used.

joaocgreis added a commit that referenced this pull request Sep 30, 2019
PR-URL: #1844
Reviewed-By: Christian Clauss <cclauss@me.com>
@joaocgreis
Copy link
Member Author

Hit an issue because of isaacs/minizlib#9 - Travis kept 1.3.1 in cache. Should be fixed now, forced update in one run and Travis updated the cache.

CI: https://ci.nodejs.org/view/All/job/nodegyp-test-pull-request/155/ ✔️

Landed in 3d1c60a

@joaocgreis joaocgreis closed this Sep 30, 2019
@sam-github
Copy link
Contributor

Does this change which version of python is chosen? I can't tell from the diff.

I.e

  • with python2, python3, and python (2.7) in /usr/bin, which will get chosen?
  • with python2, python3, and python (3.6) in /usr/bin, which will get chosen?

I don't have any concerns either way, but I think we should call out in the docs/changelog if the order of choice changed, right now it just says Python 3 is accepted, not under which conditions is preferred, if ever.

@cclauss
Copy link
Contributor

cclauss commented Oct 2, 2019

Without NODE_GYP_FORCE_PYTHON the code looks for python, then python3, then python2.
Whatever exists first is what's used.

I take that to mean python will be used.

@sam-github
Copy link
Contributor

This makes node-gyp accept Python 3 and look for it before looking for Python 2, making Python 3 the default.

@joaocgreis Can I edit this description? I think that isn't quite accurate, it should be

This makes node-gyp accept Python 3 as compatible without needing EXPERIMENTAL_NODE_GYP_PYTHON3 in the environment. It also looks for python, python3, then python2 (in that order). Note that python is usually Python 2.

Personally, I suggest that this PR can and should land on 5.x, with the minor tweek of moving python3 to after python2, so that users will Python 2 if they have it.

cf #1892 (comment) and previous discussion

rvagg pushed a commit that referenced this pull request Oct 4, 2019
Python 3 is allowed as a compatible Python, but its looked for after
Python 2.

rvagg: removed additional EXPERIMENTAL_NODE_GYP_PYTHON3 in
.travis.yml from a previous commit while landing.

Backport-of: #1844
PR-URL: #1910
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
rvagg pushed a commit that referenced this pull request Oct 4, 2019
Python 3 is allowed as a compatible Python, but its looked for after
Python 2.

rvagg: removed additional EXPERIMENTAL_NODE_GYP_PYTHON3 in
.travis.yml from a previous commit while landing.

Backport-of: #1844
PR-URL: #1910
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: João Reis <reis@janeasystems.com>
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.

6 participants