Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 141 forks source link

C compiler chokes when compiling _speedups #293

Closed willvousden closed 10 years ago

willvousden commented 10 years ago

When installing pyScss on OS X, the C compiler chokes when trying to compile _speedups. Something similar also happens on a separate machine running Debian.

Here's the output from clang --version:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

And from pip install pyscss:

Downloading/unpacking pyscss
  Downloading pyScss-1.2.0.post3.tar.gz (94kB): 94kB downloaded
  Running setup.py (path:/Users/will/.virtualenvs/py3/build/pyscss/setup.py) egg_info for package pyscss
    /Users/will/.virtualenvs/py3/build/pyscss/scss/__init__.py:86: RuntimeWarning: Scanning acceleration disabled (_speedups not found)!
      RuntimeWarning

Requirement already satisfied (use --upgrade to upgrade): six in ./.virtualenvs/py3/lib/python3.4/site-packages (from pyscss)
Installing collected packages: pyscss
  Running setup.py install for pyscss
    building 'scss._speedups' extension
    clang -Wno-unused-result -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c scss/src/_speedups.c -o build/temp.macosx-10.9-x86_64-3.4/scss/src/_speedups.o
    scss/src/_speedups.c:16:1: error: unknown type name 'staticforward'
    staticforward PyTypeObject scss_BlockLocatorType;
    ^
    scss/src/_speedups.c:16:27: error: expected ';' after top level declarator
    staticforward PyTypeObject scss_BlockLocatorType;
                              ^
                              ;
    scss/src/_speedups.c:49:8: error: no member named 'ob_type' in 'scss_BlockLocator'
            self->ob_type->tp_free((PyObject*)self);
            ~~~~  ^
    scss/src/_speedups.c:116:23: error: use of undeclared identifier 'Py_TPFLAGS_HAVE_ITER'
            Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /* tp_flags */
                                 ^
    scss/src/_speedups.c:139:1: error: unknown type name 'staticforward'
    staticforward PyTypeObject scss_ScannerType;
    ^
    scss/src/_speedups.c:139:27: error: expected ';' after top level declarator
    staticforward PyTypeObject scss_ScannerType;
                              ^
                              ;
    scss/src/_speedups.c:182:11: warning: implicit declaration of function 'PyString_Check' is invalid in C99 [-Wimplicit-function-declaration]
                                                    if (PyString_Check(item)) {
                                                        ^
    scss/src/_speedups.c:183:45: warning: implicit declaration of function 'PyString_AsString' is invalid in C99 [-Wimplicit-function-declaration]
                                                            _restrictions[restrictions_sz].tok = PyString_AsString(item);
                                                                                                 ^
    scss/src/_speedups.c:183:43: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                                                            _restrictions[restrictions_sz].tok = PyString_AsString(item);
                                                                                               ^ ~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:267:34: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                                                    _patterns[patterns_sz].tok = PyString_AsString(item0);
                                                                               ^ ~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:268:35: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                                                    _patterns[patterns_sz].expr = PyString_AsString(item1);
                                                                                ^ ~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:314:34: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                                                    _patterns[patterns_sz].tok = PyString_AsString(item0);
                                                                               ^ ~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:315:35: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                                                    _patterns[patterns_sz].expr = PyString_AsString(item1);
                                                                                ^ ~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:331:28: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
                                    _ignore[ignore_sz].tok = PyString_AsString(item);
                                                           ^ ~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:360:10: warning: implicit declaration of function 'PyString_FromString' is invalid in C99 [-Wimplicit-function-declaration]
                    repr = PyString_FromString("");
                           ^
    scss/src/_speedups.c:360:8: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
                    repr = PyString_FromString("");
                         ^ ~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:363:4: warning: implicit declaration of function 'PyString_ConcatAndDel' is invalid in C99 [-Wimplicit-function-declaration]
                            PyString_ConcatAndDel(&repr, PyString_FromString("\n"));
                            ^
    scss/src/_speedups.c:365:33: warning: implicit declaration of function 'PyString_FromFormat' is invalid in C99 [-Wimplicit-function-declaration]
                            PyString_ConcatAndDel(&repr, PyString_FromFormat("  (@%d)  %s  =  ",
                                                         ^
    scss/src/_speedups.c:367:10: warning: implicit declaration of function 'PyString_FromStringAndSize' is invalid in C99 [-Wimplicit-function-declaration]
                            tmp = PyString_FromStringAndSize(p_token->string, p_token->string_sz);
                                  ^
    scss/src/_speedups.c:367:8: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
                            tmp = PyString_FromStringAndSize(p_token->string, p_token->string_sz);
                                ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:372:8: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
                    repr = PyString_FromString("None");
                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:445:8: error: no member named 'ob_type' in 'scss_Scanner'
            self->ob_type->tp_free((PyObject*)self);
            ~~~~  ^
    scss/src/_speedups.c:461:2: warning: suggest braces around initialization of subobject [-Wmissing-braces]
            PyObject_HEAD_INIT(NULL)
            ^~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/include/python3.4m/object.h:86:5: note: expanded from macro 'PyObject_HEAD_INIT'
        1, type },
        ^~~~~~~
    scss/src/_speedups.c:463:2: warning: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'char [13]' [-Wint-conversion]
            "scss.Scanner",                            /* tp_name */
            ^~~~~~~~~~~~~~
    scss/src/_speedups.c:466:2: warning: incompatible pointer types initializing 'printfunc' (aka 'int (*)(PyObject *, FILE *, int)') with an expression of type 'destructor' (aka 'void (*)(PyObject *)') [-Wincompatible-pointer-types]
            (destructor)scss_Scanner_dealloc,          /* tp_dealloc */
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:471:2: warning: incompatible pointer types initializing 'PyNumberMethods *' with an expression of type 'reprfunc' (aka 'PyObject *(*)(PyObject *)') [-Wincompatible-pointer-types]
            (reprfunc)scss_Scanner_repr,               /* tp_repr */
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:481:2: warning: incompatible integer to pointer conversion initializing 'const char *' with an expression of type 'unsigned long' [-Wint-conversion]
            Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /* tp_flags */
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/include/python3.4m/object.h:643:29: note: expanded from macro 'Py_TPFLAGS_DEFAULT'
    #define Py_TPFLAGS_DEFAULT  ( \
                                ^
    scss/src/_speedups.c:482:2: warning: incompatible pointer types initializing 'traverseproc' (aka 'int (*)(PyObject *, visitproc, void *)') with an expression of type 'char [16]' [-Wincompatible-pointer-types]
            "Scanner object.",                         /* tp_doc */
            ^~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:489:2: warning: incompatible pointer types initializing 'struct PyMemberDef *' with an expression of type 'PyMethodDef [5]' [-Wincompatible-pointer-types]
            scss_Scanner_methods,                      /* tp_methods */
            ^~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:497:2: warning: incompatible pointer types initializing 'allocfunc' (aka 'PyObject *(*)(struct _typeobject *, Py_ssize_t)') with an expression of type 'initproc' (aka 'int (*)(PyObject *, PyObject *, PyObject *)') [-Wincompatible-pointer-types]
            (initproc)scss_Scanner_init,               /* tp_init */
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    scss/src/_speedups.c:534:3: error: non-void function 'init_speedups' should return a value [-Wreturn-type]
                    return;
                    ^
    scss/src/_speedups.c:538:3: error: non-void function 'init_speedups' should return a value [-Wreturn-type]
                    return;
                    ^
    scss/src/_speedups.c:543:6: warning: implicit declaration of function 'Py_InitModule' is invalid in C99 [-Wimplicit-function-declaration]
            m = Py_InitModule("_speedups", scss_methods);
                ^
    scss/src/_speedups.c:543:4: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]
            m = Py_InitModule("_speedups", scss_methods);
              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    25 warnings and 9 errors generated.
    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Failure information, if any, is above.
    Retrying the build without the C extension now.

    /Users/will/.virtualenvs/py3/build/pyscss/scss/__init__.py:86: RuntimeWarning: Scanning acceleration disabled (_speedups not found)!
      RuntimeWarning

    Installing pyscss script to /Users/will/.virtualenvs/py3/bin
    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Plain-Python installation succeeded.
    ==========================================================================
Successfully installed pyscss
Cleaning up...
eevee commented 10 years ago

This is a known problem with the current release; it doesn't build against Python 3. Fixed in master. Hopefully making a new release sometime soonish.

ryneeverett commented 10 years ago

Correct me if I'm wrong, but it doesn't appear that the C extension compiles for python 3 in any release to date. Edit: It does build on the prerelease of 1.3.