Skip to content

build will fail if only python3 avaiable #38791

Description

@gengjiawen

Found this on testing gcc-11 docker image.

[251/3367] ACTION postmortem-metadata: gen-postmortem-metadata_7acc03b21ed727c9887fcf4669bc652e
FAILED: gen/debug-support.cc 
cd ../../tools/v8_gypfiles; python ../../deps/v8/tools/gen-postmortem-metadata.py ../../out/Release/gen/debug-support.cc ../../out/Release/gen/torque-generated/instance-types.h ../../deps/v8/src/objects/allocation-site.h ../../deps/v8/src/objects/allocation-site-inl.h ../../deps/v8/src/objects/cell.h ../../deps/v8/src/objects/cell-inl.h ../../deps/v8/src/objects/code.h ../../deps/v8/src/objects/code-inl.h ../../deps/v8/src/objects/data-handler.h ../../deps/v8/src/objects/data-handler-inl.h ../../deps/v8/src/objects/descriptor-array.h ../../deps/v8/src/objects/descriptor-array-inl.h ../../deps/v8/src/objects/feedback-cell.h ../../deps/v8/src/objects/feedback-cell-inl.h ../../deps/v8/src/objects/fixed-array.h ../../deps/v8/src/objects/fixed-array-inl.h ../../deps/v8/src/objects/heap-number.h ../../deps/v8/src/objects/heap-number-inl.h ../../deps/v8/src/objects/heap-object.h ../../deps/v8/src/objects/heap-object-inl.h ../../deps/v8/src/objects/instance-type.h ../../deps/v8/src/objects/js-array-buffer.h ../../deps/v8/src/objects/js-array-buffer-inl.h ../../deps/v8/src/objects/js-array.h ../../deps/v8/src/objects/js-array-inl.h ../../deps/v8/src/objects/js-function-inl.h ../../deps/v8/src/objects/js-function.cc ../../deps/v8/src/objects/js-function.h ../../deps/v8/src/objects/js-objects.cc ../../deps/v8/src/objects/js-objects.h ../../deps/v8/src/objects/js-objects-inl.h ../../deps/v8/src/objects/js-promise.h ../../deps/v8/src/objects/js-promise-inl.h ../../deps/v8/src/objects/js-regexp.cc ../../deps/v8/src/objects/js-regexp.h ../../deps/v8/src/objects/js-regexp-inl.h ../../deps/v8/src/objects/js-regexp-string-iterator.h ../../deps/v8/src/objects/js-regexp-string-iterator-inl.h ../../deps/v8/src/objects/map.cc ../../deps/v8/src/objects/map.h ../../deps/v8/src/objects/map-inl.h ../../deps/v8/src/objects/name.h ../../deps/v8/src/objects/name-inl.h ../../deps/v8/src/objects/objects.h ../../deps/v8/src/objects/objects-inl.h ../../deps/v8/src/objects/oddball.h ../../deps/v8/src/objects/oddball-inl.h ../../deps/v8/src/objects/primitive-heap-object.h ../../deps/v8/src/objects/primitive-heap-object-inl.h ../../deps/v8/src/objects/scope-info.h ../../deps/v8/src/objects/scope-info-inl.h ../../deps/v8/src/objects/script.h ../../deps/v8/src/objects/script-inl.h ../../deps/v8/src/objects/shared-function-info.cc ../../deps/v8/src/objects/shared-function-info.h ../../deps/v8/src/objects/shared-function-info-inl.h ../../deps/v8/src/objects/string.cc ../../deps/v8/src/objects/string-comparator.cc ../../deps/v8/src/objects/string-comparator.h ../../deps/v8/src/objects/string.h ../../deps/v8/src/objects/string-inl.h ../../deps/v8/src/objects/struct.h ../../deps/v8/src/objects/struct-inl.h
/bin/sh: 1: python: not found

Activity

  1. targos commented on May 24, 2021

    @targos
    Member

    It's because actions that run Python in our gypfiles directly reference the python executable:

    'python',

    Maybe we should do something in GYP to expose sys.executable as a variable?

  2. added
    gypIssues and PRs related to GYP and .gyp or .gypi build files.
    pythonPRs and issues that require attention from people who are familiar with Python.
    on May 24, 2021
  3. richardlau commented on May 24, 2021

    @richardlau
    Member

    I believe this is only an issue for building with Ninja. With make our configure scripts write out the path to Python as the PYTHON make variable via config.mk but also create a symbolic python link to sys.executable if it's not the same binary as python on the PATH and append the directory containing the link to PATH:

    node/configure.py

    Lines 1952 to 1954 in e9e851f

    # Not needed for trivial case. Useless when it's a win32 path.
    if sys.executable != 'python' and ':\\' not in sys.executable:
    config['PYTHON'] = sys.executable

    node/configure.py

    Lines 1971 to 1976 in e9e851f

    # On Windows there's no reason to search for a different python binary.
    bin_override = None if sys.platform == 'win32' else make_bin_override()
    if bin_override:
    config_str = 'export PATH:=' + bin_override + ':$(PATH)\n' + config_str
    write('config.mk', do_not_edit + config_str)

    node/configure.py

    Lines 1837 to 1868 in e9e851f

    def make_bin_override():
    if sys.platform == 'win32':
    raise Exception('make_bin_override should not be called on win32.')
    # If the system python is not the python we are running (which should be
    # python 3), then create a directory with a symlink called `python` to our
    # sys.executable. This directory will be prefixed to the PATH, so that
    # other tools that shell out to `python` will use the appropriate python
    which_python = which('python')
    if (which_python and
    os.path.realpath(which_python) == os.path.realpath(sys.executable)):
    return
    bin_override = os.path.abspath('out/tools/bin')
    try:
    os.makedirs(bin_override)
    except OSError as e:
    if e.errno != errno.EEXIST: raise e
    python_link = os.path.join(bin_override, 'python')
    try:
    os.unlink(python_link)
    except OSError as e:
    if e.errno != errno.ENOENT: raise e
    os.symlink(sys.executable, python_link)
    # We need to set the environment right now so that when gyp (in run_gyp)
    # shells out, it finds the right python (specifically at
    # https://github.com/nodejs/node/blob/d82e107/deps/v8/gypfiles/toolchain.gypi#L43)
    os.environ['PATH'] = bin_override + ':' + os.environ['PATH']
    return bin_override

    (FWIW this is also the reason the V8 CI builds fail when Node.js' configure is run with Python 3 as the override means #!/usr/bin/env python ends up pointing to the Python 3 binary configure was run with instead of the default python.)

  4. skys215 commented on Mar 16, 2022

    @skys215

    Am I the only one face the same problem after upgrading macos to 12.3?

    npm ERR! gyp info using node-gyp@3.5.0
    npm ERR! gyp info using node@17.7.1 | darwin | x64
    npm ERR! gyp verb command rebuild []
    npm ERR! gyp verb command clean []
    npm ERR! gyp verb clean removing "build" directory
    npm ERR! gyp verb command configure []
    npm ERR! gyp verb check python checking for Python executable "/usr/bin/python" in the PATH
    npm ERR! gyp verb `which` failed Error: not found: /usr/bin/python
    
    npm ERR! gyp ERR! configure error
    npm ERR! gyp ERR! stack Error: Can't find Python executable "/usr/bin/python", you can set the PYTHON env variable.
    
    ~> echo $PYTHON
    /usr/local/bin/python3
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gypIssues and PRs related to GYP and .gyp or .gypi build files.pythonPRs and issues that require attention from people who are familiar with Python.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions