community: [gyp_installer] Usage of GYP's Command Expansions leads to an AttributeError exception

CC @uilianries @SSE4

Notes

This is seems to be caused by the next piece of code: https://github.com/bincrafters/gyp/blob/cc91d1b0dc0375a9087974a8fd09fe9539a6ab3e/pylib/gyp/input.py#L898-L905

The problem is universal_newlines=True. The Python3 documentation states next:

If encoding or errors are specified, or text is true, the file objects stdin, stdout and stderr are opened in text mode with the specified encoding and errors, as described above in Frequently Used Arguments. The universal_newlines argument is equivalent to text and is provided for backwards compatibility. By default, file objects are opened in binary mode.

Note that there’s also many universal_newlines=True in the other places, introduced in by the bincrafters/gyp@067a33bc1dd132136fc118dcb45a7b2ce61c47b9.

Also note that there’s much more Python3 compatibility fixes appeared in the official repo, so it’s maybe have sense to rebase onto it (not replacing with it!) the Bincrafters version (moreover, their version seems to retain compatibility with Python2).

Steps to reproduce

Run on Linux: python3 gyp/gyp_main.py --depth=. --format=gypd lemme_die.gyp Contents of lemme_die.gyp:

{
    'conditions': [
      [ '"<!(uname -m)" == "i686"', {

      }],
    ],
}

Logs

Exception: 'str' object has no attribute 'decode'
Traceback (most recent call last):
  File "share/gyp/pylib/gyp/input.py", line 487, in CallLoadTargetBuildFile
    includes, depth, check, False)
  File "share/gyp/pylib/gyp/input.py", line 408, in LoadTargetBuildFile
    build_file_data, PHASE_EARLY, variables, build_file_path)
  File "share/gyp/pylib/gyp/input.py", line 1286, in ProcessVariablesAndConditionsInDict
    build_file)
  File "share/gyp/pylib/gyp/input.py", line 1301, in ProcessVariablesAndConditionsInList
    ProcessVariablesAndConditionsInDict(item, phase, variables, build_file)
  File "share/gyp/pylib/gyp/input.py", line 1260, in ProcessVariablesAndConditionsInDict
    ProcessConditionsInDict(the_dict, phase, variables, build_file)
  File "share/gyp/pylib/gyp/input.py", line 1139, in ProcessConditionsInDict
    variables, build_file)
  File "share/gyp/pylib/gyp/input.py", line 1260, in ProcessVariablesAndConditionsInDict
    ProcessConditionsInDict(the_dict, phase, variables, build_file)
  File "share/gyp/pylib/gyp/input.py", line 1133, in ProcessConditionsInDict
    build_file)
  File "share/gyp/pylib/gyp/input.py", line 1057, in EvalCondition
    cond_expr, true_dict, false_dict, phase, variables, build_file)
  File "share/gyp/pylib/gyp/input.py", line 1071, in EvalSingleCondition
    build_file)
  File "share/gyp/pylib/gyp/input.py", line 904, in ExpandVariables
    p_stdout = p_stdout.decode()
AttributeError: 'str' object has no attribute 'decode'

Package and Environment Details

  • Package Name/Version: gyp_installer/20190423
  • Operating System+version: Linux Xubuntu 18.04.2 LTS
  • Compiler+version: gcc-7.4
  • Conan version: conan 1.16.1
  • Python version: Python 3.6.8

Conan configuration

[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=7
os=Linux
os_build=Linux

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Google is barely maintaining GYP, it’s pretty much dead for them as they have moved on to other build systems.

The Node.js community has still several discussion ongoing about the future of their build system, but in the short term they are likely going to migrate to another fork which has Python 3 support, see: https://github.com/nodejs/node/pull/26620

So we could use https://github.com/refack/GYP

okay then, let’s try to migrate to node-gyp, for me it looks like the best option for now