[pypy-issue] Issue #2737: pyhash fails to build with pypy (pypy/pypy)

Corentin Chary issues-reply at bitbucket.org
Fri Jan 19 01:43:59 EST 2018


New issue 2737: pyhash fails to build with pypy
https://bitbucket.org/pypy/pypy/issues/2737/pyhash-fails-to-build-with-pypy

Corentin Chary:

See https://github.com/flier/pyfasthash/issues/20#issuecomment-358857011


```
$ pip install pyhash
Collecting pyhash
  Using cached pyhash-0.8.2.tar.gz
Building wheels for collected packages: pyhash
  Running setup.py bdist_wheel for pyhash ... error
  Complete output from command /home/cchary/dev/graphite/carbon/venv/bin/pypy -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-MsOBgl/pyhash/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 /tmp/tmpInZIz0pip-wheel- --python-tag pp258:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying pyhash.py -> build/lib.linux-x86_64-2.7
  running build_ext
  building '_pyhash' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/src
  creating build/temp.linux-x86_64-2.7/src/fnv
  creating build/temp.linux-x86_64-2.7/src/smhasher
  creating build/temp.linux-x86_64-2.7/src/lookup3
  creating build/temp.linux-x86_64-2.7/src/SuperFastHash
  cc -pthread -DNDEBUG -O2 -fPIC -DBOOST_PYTHON_STATIC_LIB -I/home/cchary/dev/graphite/carbon/venv/include -c src/Hash.cpp -o build/temp.linux-x86_64-2.7/src/Hash.o -DSUPPORT_INT128=1 -msse4.2 -maes
  In file included from src/Hash.cpp:1:0:
  src/Hash.h: In function ‘PyObject* internal::convert(const T&) [with T = __int128 unsigned; PyObject = _object]’:
  src/Hash.h:72:36: error: invalid conversion from ‘const unsigned char*’ to ‘unsigned char*’ [-fpermissive]
       return ::_PyLong_FromByteArray((const unsigned char*) &value, sizeof(uint128_t), /*little_endian*/ 1, /*is_signed*/ 0);
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /home/cchary/dev/graphite/carbon/venv/include/Python.h:141:0,
                   from /usr/include/boost/python/detail/wrap_python.hpp:151,
                   from /usr/include/boost/python/detail/prefix.hpp:13,
                   from /usr/include/boost/python/args.hpp:8,
                   from /usr/include/boost/python.hpp:11,
                   from src/Hash.h:3,
                   from src/Hash.cpp:1:
  /usr/lib/pypy/include/pypy_decl.h:1047:24: note:   initializing argument 1 of ‘PyObject* _PyPyLong_FromByteArray(unsigned char*, long unsigned int, int, int)’
   PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(unsigned char *arg0, Unsigned arg1, int arg2, int arg3);
                          ^
  In file included from src/Hash.cpp:1:0:
  src/Hash.h: In function ‘T extract_hash_value(PyObject*) [with T = __int128 unsigned; PyObject = _object]’:
  src/Hash.h:152:5: error: ‘_PyLong_AsByteArray’ was not declared in this scope
       _PyLong_AsByteArray((PyLongObject *)obj, (unsigned char *) &value, sizeof(uint128_t), /*little_endian*/ 1, /*is_signed*/ 0);
       ^~~~~~~~~~~~~~~~~~~
  src/Hash.h:152:5: note: suggested alternative: ‘_PyLong_FromByteArray’
       _PyLong_AsByteArray((PyLongObject *)obj, (unsigned char *) &value, sizeof(uint128_t), /*little_endian*/ 1, /*is_signed*/ 0);
       ^~~~~~~~~~~~~~~~~~~
       _PyLong_FromByteArray
  In file included from src/Hash.cpp:1:0:
  src/Hash.h: In static member function ‘static boost::python::api::object Hasher<T>::CallWithArgs(boost::python::tuple, boost::python::dict)’:
  src/Hash.h:237:50: error: there are no arguments to ‘PyUnicode_AsUTF16String’ that depend on a template parameter, so a declaration of ‘PyUnicode_AsUTF16String’ must be available [-fpermissive]
         py::object utf16 = py::object(py::handle<>(PyUnicode_AsUTF16String(arg.ptr())));
                                                    ^~~~~~~~~~~~~~~~~~~~~~~
  src/Hash.h:237:50: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
  src/Hash.h: In instantiation of ‘static boost::python::api::object Hasher<T>::CallWithArgs(boost::python::tuple, boost::python::dict) [with T = city_hash_t<__int128 unsigned>]’:
  src/CityHash.h:155:57:   required from here
  src/Hash.h:237:73: error: ‘PyUnicode_AsUTF16String’ was not declared in this scope
         py::object utf16 = py::object(py::handle<>(PyUnicode_AsUTF16String(arg.ptr())));
                                                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
  src/Hash.h:237:73: note: suggested alternative: ‘PyUnicode_AsUTF8String’

```

Looks like the first error could be fixed in pypy (the missing `const`).
The second comes from the fact that `Py_UNICODE_WIDE` is defined even if UTF16 function do not seem to be implemented




More information about the pypy-issue mailing list