decalage2 / ViperMonkey

A VBA parser and emulation engine to analyze malicious macros.
1.04k stars 185 forks source link

pypy2.7-7.3.8 build error (regex Py_UCS1 issue) #119

Open fpt opened 2 years ago

fpt commented 2 years ago

Describe the bug Using pypy2.7-7.3.8, error occurs when installing packages.

To Reproduce Steps to reproduce the behavior:

  1. On MacOS, using pip, install pypy2.7-7.3.8
  2. pypy -m pip install -U pip
  3. pypy -m pip install -U -r requirements.txt
  4. See error

Error

    Running setup.py install for regex ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/bin/pypy -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-install-81lCru/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-install-81lCru/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/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-record-ZcFO4Z/install-record.txt --single-version-externally-managed --compile --install-headers /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include/regex
         cwd: /private/var/folders/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-install-81lCru/regex/
    Complete output (90 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.7-x86_64-2.7
    creating build/lib.macosx-10.7-x86_64-2.7/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.7-x86_64-2.7/regex
    copying regex_3/regex.py -> build/lib.macosx-10.7-x86_64-2.7/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.7-x86_64-2.7/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.7-x86_64-2.7/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.7-x86_64-2.7
    creating build/temp.macosx-10.7-x86_64-2.7/regex_3
    cc -pthread -arch x86_64 -DNDEBUG -O2 -fPIC -I/Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include -c regex_3/_regex.c -o build/temp.macosx-10.7-x86_64-2.7/regex_3/_regex.o
    regex_3/_regex.c:755:23: error: expected expression
        return *((Py_UCS1*)text + pos);
                          ^
    regex_3/_regex.c:755:15: error: use of undeclared identifier 'Py_UCS1'
        return *((Py_UCS1*)text + pos);
                  ^
    regex_3/_regex.c:760:16: error: expected expression
        *((Py_UCS1*)text + pos) = (Py_UCS1)ch;
                   ^
    regex_3/_regex.c:760:8: error: use of undeclared identifier 'Py_UCS1'
        *((Py_UCS1*)text + pos) = (Py_UCS1)ch;
           ^
    regex_3/_regex.c:760:32: error: use of undeclared identifier 'Py_UCS1'
        *((Py_UCS1*)text + pos) = (Py_UCS1)ch;
                                   ^
    regex_3/_regex.c:765:21: error: expected expression
        return (Py_UCS1*)text + pos;
                        ^
    regex_3/_regex.c:765:13: error: use of undeclared identifier 'Py_UCS1'
        return (Py_UCS1*)text + pos;
                ^
    regex_3/_regex.c:770:23: error: expected expression
        return *((Py_UCS2*)text + pos);
                          ^
    regex_3/_regex.c:770:15: error: use of undeclared identifier 'Py_UCS2'
        return *((Py_UCS2*)text + pos);
                  ^
    regex_3/_regex.c:775:16: error: expected expression
        *((Py_UCS2*)text + pos) = (Py_UCS2)ch;
                   ^
    regex_3/_regex.c:775:8: error: use of undeclared identifier 'Py_UCS2'
        *((Py_UCS2*)text + pos) = (Py_UCS2)ch;
           ^
    regex_3/_regex.c:775:32: error: use of undeclared identifier 'Py_UCS2'
        *((Py_UCS2*)text + pos) = (Py_UCS2)ch;
                                   ^
    regex_3/_regex.c:780:21: error: expected expression
        return (Py_UCS2*)text + pos;
                        ^
    regex_3/_regex.c:780:13: error: use of undeclared identifier 'Py_UCS2'
        return (Py_UCS2*)text + pos;
                ^
    regex_3/_regex.c:2103:25: error: use of undeclared identifier 'PyExc_TimeoutError'; did you mean 'PyPyExc_ImportError'?
            PyErr_SetString(PyExc_TimeoutError, "regex timed out");
                            ^~~~~~~~~~~~~~~~~~
                            PyPyExc_ImportError
    /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include/pypy_decl.h:1118:23: note: 'PyPyExc_ImportError' declared here
    PyAPI_DATA(PyObject*) PyExc_ImportError;
                          ^
    /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include/pypy_decl.h:1117:27: note: expanded from macro 'PyExc_ImportError'
    #define PyExc_ImportError PyPyExc_ImportError
                              ^
    regex_3/_regex.c:3468:9: error: unknown type name 'Py_UCS1'; did you mean 'Py_UCS4'?
            Py_UCS1* text_ptr;
            ^~~~~~~
            Py_UCS4
    /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include/cpyext_unicodeobject.h:1:22: note: 'Py_UCS4' declared here
    typedef unsigned int Py_UCS4;
                         ^
    regex_3/_regex.c:3469:9: error: unknown type name 'Py_UCS1'; did you mean 'Py_UCS4'?
            Py_UCS1* limit_ptr;
            ^~~~~~~
            Py_UCS4
    /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include/cpyext_unicodeobject.h:1:22: note: 'Py_UCS4' declared here
    typedef unsigned int Py_UCS4;
                         ^
    regex_3/_regex.c:3471:29: error: expected expression
            text_ptr = (Py_UCS1*)text + text_pos;
                                ^
    regex_3/_regex.c:3471:21: error: use of undeclared identifier 'Py_UCS1'
            text_ptr = (Py_UCS1*)text + text_pos;
                        ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'cc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/bin/pypy -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-install-81lCru/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-install-81lCru/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/4m/xkgpvd8n00g8vdlgtrv65wm80000gq/T/pip-record-ZcFO4Z/install-record.txt --single-version-externally-managed --compile --install-headers /Users/youichi.fujimoto/.pyenv/versions/pypy2.7-7.3.8/include/regex Check the logs for full command output.

Workaround

tomaaarsen's solution of this thread worked. https://github.com/nltk/nltk/issues/2931

Edit requirements.txt as following:

regex<2022.1.18