Repository navigation
build: ongoing list of actions for Python 3 compatibility #25789
Copy link
Copy link
Closed
Labels
buildIssues and PRs related to Node.js builds or CI infrastructure.Issues and PRs related to Node.js builds or CI infrastructure.gypIssues and PRs related to GYP and .gyp or .gypi build files.Issues and PRs related to GYP and .gyp or .gypi build files.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.pythonPRs and issues that require attention from people who are familiar with Python.PRs and issues that require attention from people who are familiar with Python.toolsIssues and PRs related to the tools directory.Issues and PRs related to the tools directory.
Description
We have several threads in issues and pull requests related to Python 3 compatibility. We need a task list to keep in sync and to show our progress
- test: Fix Python unittests in ./test and ./tools test: Fix Python unittests in ./test and ./tools #30340
- tools: pull xcode_emulation.py fixes from node-gyp tools: pull xcode_emulation.py fixes from node-gyp #30272
- deprecated python3 "imp" module used in tools/test.py deprecated python3 module "imp" used in tools/test.py #29418 Fixed in tools: fix Python 3 deprecation warning in test.py #30208 ?
- Build: No module named 'distutils.spawn' Build: No module named 'distutils.spawn' #30189
- v8: load_objects_from_file() using utf-8 v8: load_objects_from_file() using utf-8 #30218
- upstream to v8 https://chromium-review.googlesource.com/c/v8/v8/+/1895560
- tools: check-imports using utf-8 tools: check-imports using utf-8 #30220
- gyp_round_trip I: Release nodejs/node-gyp@5.x --> npm-cli --> /deps/npm
- node-gyp: Decode stdout on Python 3 (Decode stdout on Python 3 node-gyp#1890)
- node-gyp: release v5.0.4 so that npm can pick it up (Release proposal: v5.0.4 node-gyp#1893)
- npm/cli: node gyp 5.0.5 (node gyp 5.0.4 npm/cli#260)
- re-vendor npm-cli back into nodejs/node /deps/npm deps: update npm to 6.12.0 #29885
- pull non-travis code out of build: test Python 3.7 on Travis CI #29451 and PR it (test: debug output for dlopen-ping-pong test #29818)
- build: Switch Travis tests to use Python 3 explicitly for configure/build/test, existing CI will continue to use Python 2 (build: test Python 3.7 on Travis CI #29451 )
- tap2junit update to support py3
- tap2junit import into nodejs org, blocked on: Update tap13 from upstream, reapply py3 compatibility PR tap2junit#18 (comment) (Update tap13 from upstream, reapply py3 compat again tap2junit#19)
- build: allow Python 3.8 build: allow Python 3.8 #30194
- node: find and use Python 3.x before Python 2.x: discussion landed on master
- node-gyp: release 6.x preferring Python 3: Release proposal: v6.0.0 node-gyp#1892
- node: tools: fix Python 3 syntax error in mac_tool.py tools: fix Python 3 syntax error in mac_tool.py #30146
- tools: py3 nodedownload.py tools: make nodedownload.py Python 3 compatible #29104
- v8: py3 gen-postmortem-metadata.py deps: V8: cherry-pick e3d7f8a #29105 (landed upstream in v8)
- build: py3 configure.py build: py3 configure.py #29106
- pseudo-tty tests don't run with py 3 tools: make pty_helper.py python3-compatible #29167
- gyp: cherrypick python3 changes to input.py from node-gyp gyp: cherrypick python3 changes to input.py from node-gyp #29140
- build: add Python 3 tests to Travis CI build: add Python 3 tests to Travis CI #29196 (or build: try GitHub Actions CI for running tests #29193)
- tools: fix Python 3 issues in gyp/generator/make.py tools: fix Python 3 issues in gyp/generator/make.py #29214
- tools: fix Python 3 issues in tools/icu/icutrim.py tools: fix Python 3 issues in tools/icu/icutrim.py #29213
- v8: fix mixup with bytes.decode() and str.encode() tools: fix mixup with bytes.decode() and str.encode() #29208
- tools: fix Python 3 issues in inspector_protocol tools: fix Python 3 issues in inspector_protocol #29296
- test: use print() function in both Python 2 and 3 test: use print() function in both Python 2 and 3 #29298
- Accept Python 3 on Windows Accept Python 3 on Windows #29236
- build: test Python 3.6 and 3.7 on Travis CI build: test Python 3.6 and 3.7 on Travis CI #29291
- tools: from io import StringIO in ninja.py tools: from io import StringIO in ninja.py #29371
- tools: fix GYP ninja generator for Python 3 tools: fix GYP ninja generator for Python 3 #29416
- build,win: fix Python detection on localized OS build,win: fix Python detection on localized OS #29423
- build: add comment to .travis.yml on how to test Py3 build: add comment to .travis.yml on how to test Py3 #29473
- tools/test.py is not yet Python 3 compatible tools/test.py is not yet Python 3 compatible #29246
- build: find Python 3 or Python 2 in configure build: find Python 3 or Python 2 in configure #25878 modifies ./configure to prefer py2 to py3 See: https://github.com/cclauss/node-configure
- 'async' is a reserved word in Python >= 3.7 'async' is a reserved word in Python >= 3.7 #29326
- https://chromium-review.googlesource.com/c/deps/inspector_protocol/+/1781351
- deps: need to cherrypick async fix into inspector code generator deps: need to cherrypick async fix into inspector code generator #29548
- tools: python3 compat for inspector code generator tools: python3 compat for inspector code generator #29340
- tap2junit: Python 3 changes plus automated testing Python 3 changes plus automated testing tap2junit#5
- tap2junit: v0.1.5 release (tap2junit v0.1.5 proposal tap2junit#12) to the Python Packaging Index PyPI
- node-gyp: Accept Python 3 by default (semver-major) Accept Python 3 by default node-gyp#1844
- node-gyp: doc: Declare that node-gyp is Python 3 compatible doc: Declare that node-gyp is Python 3 compatible node-gyp#1811
- node-test-commit-v8-linux is perma red: V8 CI is not Python 3 compatible #30152
- gyp_round_trip_II: Release nodejs/node-gyp@6.x (prefers py3 over py2) --> npm-cli --> /deps/npm
- node-gyp: Release proposal: node-gyp@6.0.1 Release proposal: node-gyp@6.0.1 node-gyp#1935
- node-gyp: npm-cli update and release
Release 6.13.0 npm/cli#276?? - node-gyp: npm-cli revendor into deps/npm
- node: backport build: prefer python 3 over 2 for configure #30091 to 13.x
- node: backport build: prefer python 3 over 2 for configure #30091 to 12.x?
- Watch our CI.... see QA
- Add Python 3.8 to Travis CI when Travis' pyenv is updated.
- win: change to use Python in install tool #31221
QA:: Our CI machines are mix of machines that have Python 2, have Python 3, have both, have a python symlink, have it not, etc. By preferring Python 3 in configure/make/test some set of our current machines will start to test against Python 3, but many will continue to test against Python 2. The more modern machines will use 3, as will our users running more up-to-date operating systems in the next year.
Upstream V8 issues:
Neither Chromium or depot_tools are Python 3 compatible yet. This doesn't effect the main Node.js builds, but does affect our V8 integration builds, where v8 is built and tested.
- migration of Chromium to Python 3: https://bugs.chromium.org/p/chromium/issues/detail?id=942720
- specific one for depot_tools: https://bugs.chromium.org/p/chromium/issues/detail?id=984182
Miscellaneous non-blocking cleanups
-
Travis CI does not test ./configure --ninja test test: adding test for configure ninja #30033reverted - configure.py: upgrade from optparse to argparse build: replace optparse for argparse in configure.py #29814
- Tests do not test ./configure --ninja Tests do not test ./configure --ninja #29415 reopened
- sort((MSVSFolder, MSVSProject)) node-gyp Python 3 support node-addon-api#445 (comment)
- sort out the home for tap2junit: Transfer jenkins CI tool tap2junit into Node.js org admin#413
- investigate using nodejs/node-gyp:gyp/ as up-stream for nodejs/node:tools/gyp/, see The GYP issue: where, how and who to maintain node-gyp#1791 for more information and alternate proposals.
Please use the "python" label!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
buildIssues and PRs related to Node.js builds or CI infrastructure.Issues and PRs related to Node.js builds or CI infrastructure.gypIssues and PRs related to GYP and .gyp or .gypi build files.Issues and PRs related to GYP and .gyp or .gypi build files.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.pythonPRs and issues that require attention from people who are familiar with Python.PRs and issues that require attention from people who are familiar with Python.toolsIssues and PRs related to the tools directory.Issues and PRs related to the tools directory.
Activity
thefourtheye commentedon Jan 30, 2019
@cclauss This is one neatly compiled list. Thanks for doing that 👍 I am just wondering if we can start dealing with GYP's Python 3 compatibility.
targos commentedon Jan 30, 2019
GYP got a few patches for Python 3 compatibility upstream: https://chromium.googlesource.com/external/gyp/+log
thefourtheye commentedon Jan 30, 2019
Oh, that's great. @refack and @cclauss have been working on @refack's fork of GYP at https://github.com/refack/GYP in this regard. Perhaps we can consolidate our efforts.
gengjiawen commentedon Jan 30, 2019
I will like to talk ci involved this. I know we are current introduce docker in node ci system.
We can introduce a docker image only with python3 to test our code.
gengjiawen commentedon Jan 30, 2019
One more thing, not sure this is the right place. We may need to pre-install some python3 package.
Package
utilsnot include in python3.node/tools/test.py
Line 43 in 86a49ce
cclauss commentedon Jan 30, 2019
node/tools/utils.py the file in question. Perhaps we need to start adding from __future__ import absolute_import.
https://stackoverflow.com/questions/33743880/what-does-from-future-import-absolute-import-actually-do
gengjiawen commentedon Mar 4, 2019
Maybe need to install python3 in this file too https://github.com/nodejs/node/blob/26cfaf4c1803d3d95c875865a1c671b914a16f4b/tools/bootstrap/windows_boxstarter.
tools: windows_boxstarter "choco install python -y" for Python 3
30 remaining items
targos commentedon Oct 28, 2019
@sam-github @cclauss The switch to preferring Python 3 seems to have broken our V8 CI on
centos7-ppcle.See https://ci.nodejs.org/job/node-test-commit-v8-linux/2590/nodes=centos7-ppcle,v8test=v8test/console
cclauss commentedon Oct 28, 2019
https://stackoverflow.com/questions/12806122/missing-python-bz2-module
gengjiawen commentedon Oct 29, 2019
This one related: nodejs/node-gyp#1947
sam-github commentedon Jan 6, 2020
@cclauss I haven't heard of anyone having troubles with Python 3, have you, or anyone else?
Are there next steps we can take now?
dylanaraps commentedon Jan 6, 2020
I've been building node with Python 3 for a while however the following workaround is needed for Python >= 3.8. It's a simple "hack" but it enables node to build on Python 3.8.
It seems to be limited to Python < 3.5(?). Not sure if this is true for Master or not.
sed -i 's/(3, 5)/(3, 8)/' configuresam-github commentedon Jan 6, 2020
@dylanaraps with what node.js version do you do that?
master:
node/configure
Line 24 in 20fd123
dylanaraps commentedon Jan 6, 2020
Apologies, I see that this is fixed in the latest version. Disregard my prior comment. That being said, Python 3 support works flawlessly here. 👍
sam-github commentedon Jan 6, 2020
Talked to @cclauss, we came up with a plan. We'll open new issues for this, but for the moment, here's the notes.
Reminder:
1. Update npm to node-gyp@6.x on the next npm major, npm@7
This needs coordination with the npm team, @nodejs/npm
node-gyp@6 "prefers" py3 over py2 (node-gyp@5, what npm@6 uses, uses py3 only if py2 is not found). Changing the default is considered
semver-major, which might be excessively paranoid, but nobody wants to break the ecosystem.ATM, note that node 10.x and greater all have npm@6, which means that right now py3-only systems should build node.js addons with py3 on all currently supported node.js release lines.
2. node.js 12.x must support being built with py3
node@12.x will outlive py2 EOL by a long time, it must get non-experimental support for building with py3
We will identify the commits/PRs that need backporting.
3. node.js 10.x should support being built with py3
nodejs@10 outlives py2 EOL, so should be buildable with py3. Whether we can achieve that will take some analysis, maybe its easy, maybe its drifted too far from 12.x. If its way too hard/destabilizing, we might need to make an exception for it to our "unsupported platform" policy.
Note that lack of support for py3 means that https://github.com/felixrieseberg/windows-build-tools cannot yet install py3 instead of py2 - if it did that, users wouldn't be able to build node.js 10.x on Windows with using it. I mention, because its one example of the kind of downstream pain caused by not having py3 support. It might become a problem on non-Windows platforms, too, as py2 becomes less commonly packaged, or perhaps not packaged at all.
/cc @nodejs/tsc @nodejs/python @nodejs/node-gyp
gengjiawen commentedon Jan 29, 2020
#31562 after this patch.
python3 configure.py --debug --ninjafailed with:cclauss commentedon Jan 29, 2020
On
masterthis code is at line 2385 and the proper encoding is done on the line above.Please see: https://github.com/nodejs/node/search?q=qualified_target_for_hash
gengjiawen commentedon Feb 29, 2020
Thanks to @targos for #30563, many compatibility issue should be resolved (like ninja issue).
cclauss commentedon Feb 29, 2020
Closing — Thanks to everyone who helped to make Node.js on Python 3 happen!
build: remove support for Python 2
Makefile: Upgrade to Python 3