compilation fails under Macos

Create issue
Issue #356 new
Former user created an issue

Failed to build regex Installing collected packages: toml, attrs, pathspec, typed-ast, regex, click, appdirs, black Running setup.py install for regex: started Running setup.py install for regex: finished with status 'error'

Errors: ERROR: Command errored out with exit status 1: command: /Users/ssbarnea/.cache/pre-commit/repo4uyheutp/py_env-python3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/setup.py'"'"'; file='"'"'/private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-wheel-z1i93hb8 --python-tag cp37 cwd: /private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/ Complete output (71 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.15-x86_64-3.7 creating build/lib.macosx-10.15-x86_64-3.7/regex copying regex_3/init.py -> build/lib.macosx-10.15-x86_64-3.7/regex copying regex_3/regex.py -> build/lib.macosx-10.15-x86_64-3.7/regex copying regex_3/_regex_core.py -> build/lib.macosx-10.15-x86_64-3.7/regex copying regex_3/test_regex.py -> build/lib.macosx-10.15-x86_64-3.7/regex warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.15-x86_64-3.7
  creating build/temp.macosx-10.15-x86_64-3.7/regex_3
  clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/usr/local/include -L/usr/local/lib -I/usr/local/opt/openssl/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/usr/local/include -L/usr/local/lib -I/usr/local/opt/openssl/include -I/usr/local/include -L/usr/local/lib -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl/include -I/usr/local/opt/nss/include -I/usr/local/opt/libarchive/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ -I/Users/ssbarnea/.pyenv/versions/3.7.5/include/python3.7m -c regex_3/_regex.c -o build/temp.macosx-10.15-x86_64-3.7/regex_3/_regex.o
  clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
  clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
  clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
  regex_3/_regex.c:2109:25: error: use of undeclared identifier 'PyExc_TimeoutError'; did you mean 'PyExc_ImportError'?
          PyErr_SetString(PyExc_TimeoutError, "regex timed out");
                          ^~~~~~~~~~~~~~~~~~
                          PyExc_ImportError
  /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyerrors.h:134:24: note: 'PyExc_ImportError' declared here
  PyAPI_DATA(PyObject *) PyExc_ImportError;
                         ^
  regex_3/_regex.c:20118:24: warning: implicit declaration of function 'PyBytes_FromObject' is invalid in C99 [-Wimplicit-function-declaration]
              new_item = PyBytes_FromObject(item);
                         ^
  regex_3/_regex.c:20118:22: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
              new_item = PyBytes_FromObject(item);
                       ^ ~~~~~~~~~~~~~~~~~~~~~~~~
  regex_3/_regex.c:27102:5: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
      PyModuleDef_HEAD_INIT,
      ^
  regex_3/_regex.c:27101:27: error: variable has incomplete type 'struct PyModuleDef'
  static struct PyModuleDef regex_module = {
                            ^
  regex_3/_regex.c:27101:15: note: forward declaration of 'struct PyModuleDef'
  static struct PyModuleDef regex_module = {
                ^
  regex_3/_regex.c:27171:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27173:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27175:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27177:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27179:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27183:9: warning: implicit declaration of function 'PyModule_Create' is invalid in C99 [-Wimplicit-function-declaration]
      m = PyModule_Create(&regex_module);
          ^
  regex_3/_regex.c:27185:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27210:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
          return NULL;
          ^      ~~~~
  regex_3/_regex.c:27213:5: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
      return m;
      ^      ~
  3 warnings and 11 errors generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
    ERROR: Command errored out with exit status 1:
     command: /Users/ssbarnea/.cache/pre-commit/repo4uyheutp/py_env-python3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-record-y9xim1s9/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ssbarnea/.cache/pre-commit/repo4uyheutp/py_env-python3/include/site/python3.7/regex
         cwd: /private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/
    Complete output (71 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-3.7
    creating build/lib.macosx-10.15-x86_64-3.7/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/regex
    copying regex_3/regex.py -> build/lib.macosx-10.15-x86_64-3.7/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.15-x86_64-3.7/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.15-x86_64-3.7/regex
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.15-x86_64-3.7
    creating build/temp.macosx-10.15-x86_64-3.7/regex_3
    clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/usr/local/include -L/usr/local/lib -I/usr/local/opt/openssl/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/usr/local/include -L/usr/local/lib -I/usr/local/opt/openssl/include -I/usr/local/include -L/usr/local/lib -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl/include -I/usr/local/opt/nss/include -I/usr/local/opt/libarchive/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ -I/Users/ssbarnea/.pyenv/versions/3.7.5/include/python3.7m -c regex_3/_regex.c -o build/temp.macosx-10.15-x86_64-3.7/regex_3/_regex.o
    clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
    clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
    clang: warning: argument unused during compilation: '-L/usr/local/lib' [-Wunused-command-line-argument]
    regex_3/_regex.c:2109:25: error: use of undeclared identifier 'PyExc_TimeoutError'; did you mean 'PyExc_ImportError'?
            PyErr_SetString(PyExc_TimeoutError, "regex timed out");
                            ^~~~~~~~~~~~~~~~~~
                            PyExc_ImportError
    /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyerrors.h:134:24: note: 'PyExc_ImportError' declared here
    PyAPI_DATA(PyObject *) PyExc_ImportError;
                           ^
    regex_3/_regex.c:20118:24: warning: implicit declaration of function 'PyBytes_FromObject' is invalid in C99 [-Wimplicit-function-declaration]
                new_item = PyBytes_FromObject(item);
                           ^
    regex_3/_regex.c:20118:22: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
                new_item = PyBytes_FromObject(item);
                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~
    regex_3/_regex.c:27102:5: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
        PyModuleDef_HEAD_INIT,
        ^
    regex_3/_regex.c:27101:27: error: variable has incomplete type 'struct PyModuleDef'
    static struct PyModuleDef regex_module = {
                              ^
    regex_3/_regex.c:27101:15: note: forward declaration of 'struct PyModuleDef'
    static struct PyModuleDef regex_module = {
                  ^
    regex_3/_regex.c:27171:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27173:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27175:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27177:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27179:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27183:9: warning: implicit declaration of function 'PyModule_Create' is invalid in C99 [-Wimplicit-function-declaration]
        m = PyModule_Create(&regex_module);
            ^
    regex_3/_regex.c:27185:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27210:9: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
            return NULL;
            ^      ~~~~
    regex_3/_regex.c:27213:5: error: void function 'PyInit__regex' should not return a value [-Wreturn-type]
        return m;
        ^      ~
    3 warnings and 11 errors generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ssbarnea/.cache/pre-commit/repo4uyheutp/py_env-python3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-install-5cd982da/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/br/99tfdvcs3vvfwdk69z7f0xmc0000gn/T/pip-record-y9xim1s9/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ssbarnea/.cache/pre-commit/repo4uyheutp/py_env-python3/include/site/python3.7/regex Check the logs for full command output.

Check the log at /Users/ssbarnea/.cache/pre-commit/pre-commit.log ERROR: InvocationError for command /Users/ssbarnea/os/molecule/.tox/lint/bin/python -m pre_commit run --all (exited with code 1)

Comments (4)

  1. Matthew Barnett repo owner

    There appear to be references to both Python 2.7 (the system Python?) and Python 3.7. Is that normal on MacOS?

    At a guess I’d say it’s trying to build for Python 3, but on Python 2.7.

  2. Matthew Barnett repo owner

    FYI, I believe the recommended way to use Python on MacOS is to use “homebrew”.

  3. Sorin Ionuț Sbârnea

    It is normal to have multiple versions of Python on MacOS. I was able to workaround this error by removing -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/` from CPPFLAGS

    Still, doing this may break other stuff that required it. I am not convinced that was a local config error.

    In fact my hope was that installing regex on MacOS would not require any binary compilation.

  4. Eli Schwartz

    It is quite normal to have multiple versions of python on Windows and Linux too. That’s not what this discussion is about.

    Is it normal for MacOS to add the header includes for multiple versions of python in the same project build?

    Is it normal for Python3 pip on MacOS to add the python2 header includes with a higher priority than Python3?

    You say you fixed the problem by removing the include path from your CPPFLAGS. In that case it is absolutely a user config issue. You should not add unrelated header includes for all projects by adding them to CPPFLAGS in your .bashrc or whatever… you should add the header includes needed for a given project only to that project. There many excellent frameworks for teaching a project about its dependencies; use one of them. (autotools, meson, cmake can all detect python installations and write out e.g. Makefiles embedding the right path; for standalone use, pkg-config exists.)

  5. Log in to comment