Building v2.17.2 failed with fatal error: 'code.h' file not found

Hi
Excuse me.
I executed the command yb_build.sh release to compile version v2.17.2 of yugabyteDB, but failed due to a fatal error. The error message is as follows:

DEPRECATION: typed-ast is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for typed-ast ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for typed-ast did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      running install
      /Users/simon/Documents/yugabyte-db-2.17.2/build/venv-arm64/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.macosx-13-arm64-cpython-311
      creating build/lib.macosx-13-arm64-cpython-311/typed_ast
      copying typed_ast/conversions.py -> build/lib.macosx-13-arm64-cpython-311/typed_ast
      copying typed_ast/__init__.py -> build/lib.macosx-13-arm64-cpython-311/typed_ast
      copying typed_ast/ast3.py -> build/lib.macosx-13-arm64-cpython-311/typed_ast
      copying typed_ast/ast27.py -> build/lib.macosx-13-arm64-cpython-311/typed_ast
      creating build/lib.macosx-13-arm64-cpython-311/typed_ast/tests
      copying ast3/tests/test_basics.py -> build/lib.macosx-13-arm64-cpython-311/typed_ast/tests
      running build_ext
      building '_ast27' extension
      creating build/temp.macosx-13-arm64-cpython-311
      creating build/temp.macosx-13-arm64-cpython-311/ast27
      creating build/temp.macosx-13-arm64-cpython-311/ast27/Custom
      creating build/temp.macosx-13-arm64-cpython-311/ast27/Parser
      creating build/temp.macosx-13-arm64-cpython-311/ast27/Python
      clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/opt/homebrew/opt/openjdk@11/include -Iast27/Include -I/Users/simon/Documents/yugabyte-db-2.17.2/build/venv-arm64/include -I/opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c ast27/Custom/typed_ast.c -o build/temp.macosx-13-arm64-cpython-311/ast27/Custom/typed_ast.o
      In file included from ast27/Custom/typed_ast.c:3:
      ast27/Custom/../Include/compile.h:5:10: fatal error: 'code.h' file not found
      #include "code.h"
               ^~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

Maybe it was running setup.py install for typed-ast, but it did not run successfully.
So far, I don’t know how to solve it.
May I ask if you can provide a solution or suggestion?

Hi @ZhenNan2016

What version of OS and python are you using?
Does it help if you install wheel package first?

cc @svarnau

Hi @dorian_yugabyte
OS: macOS Ventura 13.1
The Python version on my macOS is 3.9.6, but I see that when compiling yugabyteDB, there will be its own Python directory, which is yugabyte-db-2.17.2/build/venv-arm64/lib/python3.11.

Does it need to install wheel package first ?
I installed the relevant package according to the following link, but it was not mentioned above that the wheel package needs to be installed

When I execute the command pip3 install wheel to prepare to install the wheel package, I am prompted that Requirement already satisfied. The details are as follows:

Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: wheel in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (0.37.0)

By the way, executing pip3 install typed-ast separately does not cause any exceptions and can be installed normally.

cc @svarnau

I think this has something to do with which python gets picked up in the mac/M1 environment.
cc: @mbautin @jason @Frits_Hoogland

1 Like

Hi @svarnau
Excuse me.
They (@mbautin @jason @Frits_Hoogland) haven’t answered this question.
Is there anyone else who can consult and solve this problem?
Thank you very much.

To verify any issues with the source code tagged with v2.17.2.0, I checked out that tag and build it on my Mac M1 version: 13.3.1. It gets past the Python building, and now is compiling the c++ files.

I am a bit confused about what I see, because the messages with the error indicating python version 3.11 is used? On my machine it’s python 3.9.

(venv-arm64/lib/python3.11)

1 Like

May I ask if the v2.17.2.0 you compiled have passed the compilation?

I just executed yb_build.sh release, and it generated the directory ‘build/venv-arm64/lib/python3.11’ in the ‘build’ directory. Do it need to set anything config?

Hi @Frits_Hoogland
I cleaned up Python in my macOS environment and kept it at only 3.9.6. It gets past the Python building, and it can compile the c++ files.

However, there are some C files that fail compilation and will prompt as follows:
/-------------------------------------------------------------------------------

COMPILATION FAILED
build/release-clang-dynamic-arm64-ninja/src/yb/yql/cql/ql/parser/parser_gram.y.cc:10916:9: error: variable ‘yynerrs_’ set but not used [-Werror,-Wunused-but-set-variable]
int yynerrs_ = 0;
    ^

1 error generated.

Actually, the yyners_ is useful.
Have you encountered this compilation error?

Great!
That is a known issue that you’re seeing.
Can you add —clang15 as argument to the yb_build command, then it should work!

1 Like

Yes, I use yb_build.sh --clang15 release, and it can compile and run normally now.
Thank very much.