Skip to content

build: ongoing list of actions for Python 3 compatibility #25789

Closed

Description

@cclauss

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

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.

Miscellaneous non-blocking cleanups

Please use the "python" label!

Activity

  1. added
    buildIssues and PRs related to Node.js builds or CI infrastructure.
    on Jan 29, 2019
  2. added
    pythonPRs and issues that require attention from people who are familiar with Python.
    toolsIssues and PRs related to the tools directory.
    gypIssues and PRs related to GYP and .gyp or .gypi build files.
    on Jan 29, 2019
  3. thefourtheye commented on Jan 30, 2019

    @thefourtheye
    Contributor

    @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.

  4. targos commented on Jan 30, 2019

    @targos
    Member

    GYP got a few patches for Python 3 compatibility upstream: https://chromium.googlesource.com/external/gyp/+log

  5. thefourtheye commented on Jan 30, 2019

    @thefourtheye
    Contributor

    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.

  6. gengjiawen commented on Jan 30, 2019

    @gengjiawen
    Member

    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.

  7. gengjiawen commented on Jan 30, 2019

    @gengjiawen
    Member

    One more thing, not sure this is the right place. We may need to pre-install some python3 package.
    Package utils not include in python3.

    import utils

  8. cclauss commented on Jan 30, 2019

    @cclauss
    ContributorAuthor

    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

  9. gengjiawen commented on Mar 4, 2019

    @gengjiawen
    Member
  10. 30 remaining items

  11. targos commented on Oct 28, 2019

    @targos
    Member

    @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

    07:58:31 + ./configure
    07:58:32 Node configure: Found Python 3.7.3...
    07:58:32 Traceback (most recent call last):
    07:58:32   File "./configure", line 25, in <module>
    07:58:32     import configure
    07:58:32   File "/home/iojs/build/workspace/node-test-commit-v8-linux/nodes/centos7-ppcle/v8test/v8test/configure.py", line 14, in <module>
    07:58:32     import bz2
    07:58:32   File "/usr/local/lib/python3.7/bz2.py", line 19, in <module>
    07:58:32     from _bz2 import BZ2Compressor, BZ2Decompressor
    07:58:32 ModuleNotFoundError: No module named '_bz2'
    
  12. cclauss commented on Oct 28, 2019

    @cclauss
    ContributorAuthor
  13. gengjiawen commented on Oct 29, 2019

    @gengjiawen
    Member

    This one related: nodejs/node-gyp#1947

    # ./configure --debug -C
    
    Node configure: Found Python 3.7.5...
    INFO: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"
    INFO: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"
    Traceback (most recent call last):
      File "./configure", line 25, in <module>
        import configure
      File "/root/node/configure.py", line 1755, in <module>
        run_gyp(gyp_args)
      File "tools/gyp_node.py", line 54, in run_gyp
        rc = gyp.main(args)
      File "tools/gyp/pylib/gyp/__init__.py", line 547, in main
        return gyp_main(args)
      File "tools/gyp/pylib/gyp/__init__.py", line 532, in gyp_main
        generator.GenerateOutput(flat_list, targets, data, params)
      File "tools/gyp/pylib/gyp/generator/compile_commands_json.py", line 95, in GenerateOutput
        for qualified_target, target in target_dicts.iteritems():
    AttributeError: 'dict' object has no attribute 'iteritems'
  14. sam-github commented on Jan 6, 2020

    @sam-github
    Contributor

    @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?

  15. dylanaraps commented on Jan 6, 2020

    @dylanaraps

    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)/' configure
  16. sam-github commented on Jan 6, 2020

    @sam-github
    Contributor

    @dylanaraps with what node.js version do you do that?

    master:

    node/configure

    Line 24 in 20fd123

    acceptable_pythons = ((3, 8), (3, 7), (3, 6), (3, 5), (2, 7))

  17. dylanaraps commented on Jan 6, 2020

    @dylanaraps

    Apologies, I see that this is fixed in the latest version. Disregard my prior comment. That being said, Python 3 support works flawlessly here. 👍

  18. sam-github commented on Jan 6, 2020

    @sam-github
    Contributor

    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

  19. gengjiawen commented on Jan 29, 2020

    @gengjiawen
    Member

    #31562 after this patch.

    python3 configure.py --debug --ninja failed with:

    Traceback (most recent call last):
      File "configure.py", line 1770, in <module>
        run_gyp(gyp_args)
      File "tools/gyp_node.py", line 54, in run_gyp
        rc = gyp.main(args)
      File "tools/gyp/pylib/gyp/__init__.py", line 547, in main
        return gyp_main(args)
      File "tools/gyp/pylib/gyp/__init__.py", line 532, in gyp_main
        generator.GenerateOutput(flat_list, targets, data, params)
      File "tools/gyp/pylib/gyp/generator/ninja.py", line 2426, in GenerateOutput
        config_name)
      File "tools/gyp/pylib/gyp/generator/ninja.py", line 2317, in GenerateOutputForConfig
        hash_for_rules = hashlib.md5(qualified_target_for_hash).hexdigest()
    TypeError: Unicode-objects must be encoded before hashing
  20. cclauss commented on Jan 29, 2020

    @cclauss
    ContributorAuthor

    On master this 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

  21. gengjiawen commented on Feb 29, 2020

    @gengjiawen
    Member

    Thanks to @targos for #30563, many compatibility issue should be resolved (like ninja issue).

  22. cclauss commented on Feb 29, 2020

    @cclauss
    ContributorAuthor

    Closing — Thanks to everyone who helped to make Node.js on Python 3 happen!

  23. added a commit that references this issue on Apr 16, 2021
  24. added a commit that references this issue on Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buildIssues and PRs related to Node.js builds or CI infrastructure.gypIssues 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.pythonPRs and issues that require attention from people who are familiar with Python.toolsIssues and PRs related to the tools directory.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions