stef / pbp

salty privacy
Other
53 stars 5 forks source link

cffi error #6

Closed TLINDEN closed 10 years ago

TLINDEN commented 10 years ago

Hi,

I installed pysodium and pbp from source using python setup.py build; sudo python setup.py install. Both showed no errors. When I try to start pbp the first time, this will be shown:

build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:156:20: error: sodium.h: No such file or directory
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_box_BEFORENMBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:162: error: 'crypto_box_BEFORENMBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:162: error: (Each undeclared identifier is reported only once
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:162: error: for each function it appears in.)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_box_BOXZEROBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:181: error: 'crypto_box_BOXZEROBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_box_NONCEBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:200: error: 'crypto_box_NONCEBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_box_PUBLICKEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:219: error: 'crypto_box_PUBLICKEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_box_SECRETKEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:238: error: 'crypto_box_SECRETKEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_box_ZEROBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:257: error: 'crypto_box_ZEROBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_generichash_BLOCKBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:276: error: 'crypto_generichash_BLOCKBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_generichash_BYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:295: error: 'crypto_generichash_BYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_generichash_BYTES_MIN':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:314: error: 'crypto_generichash_BYTES_MIN' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_generichash_KEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:333: error: 'crypto_generichash_KEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_generichash_KEYBYTES_MAX':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:352: error: 'crypto_generichash_KEYBYTES_MAX' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_generichash_KEYBYTES_MIN':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:371: error: 'crypto_generichash_KEYBYTES_MIN' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_scalarmult_curve25519_BYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:390: error: 'crypto_scalarmult_curve25519_BYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_secretbox_BOXZEROBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:409: error: 'crypto_secretbox_BOXZEROBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_secretbox_KEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:428: error: 'crypto_secretbox_KEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_secretbox_NONCEBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:447: error: 'crypto_secretbox_NONCEBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_secretbox_ZEROBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:466: error: 'crypto_secretbox_ZEROBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_sign_BYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:485: error: 'crypto_sign_BYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_sign_PUBLICKEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:504: error: 'crypto_sign_PUBLICKEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_sign_SECRETKEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:523: error: 'crypto_sign_SECRETKEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_stream_KEYBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:542: error: 'crypto_stream_KEYBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_const_crypto_stream_NONCEBYTES':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:561: error: 'crypto_stream_NONCEBYTES' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_f_crypto_generichash_final':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1085: error: 'crypto_generichash_state' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1085: error: 'x0' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_f_crypto_generichash_init':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1135: error: 'crypto_generichash_state' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1135: error: 'x0' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_f_crypto_generichash_update':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1191: error: 'crypto_generichash_state' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1191: error: 'x0' undeclared (first use in this function)
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: At top level:
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1920: warning: 'struct crypto_generichash_blake2b_state' declared inside parameter list
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1920: warning: its scope is only this definition or declaration, which is probably not what you want
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_check_struct_crypto_generichash_blake2b_state':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1923: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1924: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1925: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1926: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1927: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1928: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c: In function '_cffi_layout_struct_crypto_generichash_blake2b_state':
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1933: error: field 'y' has incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1935: error: invalid application of 'sizeof' to incomplete type 'struct crypto_generichash_blake2b_state' 
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1937: error: invalid use of undefined type 'struct crypto_generichash_blake2b_state'
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1938: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1939: error: invalid use of undefined type 'struct crypto_generichash_blake2b_state'
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1940: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1941: error: invalid use of undefined type 'struct crypto_generichash_blake2b_state'
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1942: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1943: error: invalid use of undefined type 'struct crypto_generichash_blake2b_state'
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1944: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1945: error: invalid use of undefined type 'struct crypto_generichash_blake2b_state'
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1946: error: dereferencing pointer to incomplete type
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1947: error: invalid use of undefined type 'struct crypto_generichash_blake2b_state'
build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__pycache__/_cffi__x6f20fc6x6947e85f.c:1948: error: dereferencing pointer to incomplete type
Traceback (most recent call last):
  File "/usr/local/bin/pbp", line 8, in <module>
    load_entry_point('pbp==0.2', 'console_scripts', 'pbp')()
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2221, in load_entry_point
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1954, in load
  File "build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pbp/main.py", line 5, in <module>
  File "build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pbp/publickey.py", line 2, in <module>
  File "build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/__init__.py", line 30, in <module>

  File "build/bdist.freebsd-9.0-RELEASE-p3-amd64/egg/pysodium/sodium.py", line 130, in <module>
  File "/usr/local/lib/python2.7/site-packages/cffi-0.8.1-py2.7-freebsd-9.0-RELEASE-p3-amd64.egg/cffi/api.py", line 339, in verify
    lib = self.verifier.load_library()
  File "/usr/local/lib/python2.7/site-packages/cffi-0.8.1-py2.7-freebsd-9.0-RELEASE-p3-amd64.egg/cffi/verifier.py", line 74, in load_library
    self._compile_module()
  File "/usr/local/lib/python2.7/site-packages/cffi-0.8.1-py2.7-freebsd-9.0-RELEASE-p3-amd64.egg/cffi/verifier.py", line 139, in _compile_module
    outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
  File "/usr/local/lib/python2.7/site-packages/cffi-0.8.1-py2.7-freebsd-9.0-RELEASE-p3-amd64.egg/cffi/ffiplatform.py", line 25, in compile
    outputfilename = _build(tmpdir, ext)
  File "/usr/local/lib/python2.7/site-packages/cffi-0.8.1-py2.7-freebsd-9.0-RELEASE-p3-amd64.egg/cffi/ffiplatform.py", line 50, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: CompileError: command 'cc' failed with exit status 1

It looks as if pbp tries to compile pysodium at runtime (???). It should have done this during build time, I'd say.

I retried it with:

CFLAGS=_I/usr/local/include LDFLAGS=-L/usr/local/lib python setup.py build

to no avail.

Any ideas?

TLINDEN commented 10 years ago

Update: I tried really hard, to tell cffi where to find the sodium includes and lib, but it didn't work. However, this nasty workaround helped in the end:

lrwxr-xr-x  1 root  wheel  25 Jan 19 19:41 /usr/include/sodium -> /usr/local/include/sodium
lrwxr-xr-x  1 root  wheel  27 Jan 19 19:42 /usr/include/sodium.h -> /usr/local/include/sodium.h
lrwxr-xr-x  1 root  wheel  26 Jan 19 19:44 /usr/lib/libsodium.a -> /usr/local/lib/libsodium.a
lrwxr-xr-x  1 root  wheel  27 Jan 19 19:44 /usr/lib/libsodium.la -> /usr/local/lib/libsodium.la
lrwxr-xr-x  1 root  wheel  27 Jan 19 19:44 /usr/lib/libsodium.so -> /usr/local/lib/libsodium.so
lrwxr-xr-x  1 root  wheel  29 Jan 19 19:42 /usr/lib/libsodium.so.7 -> /usr/local/lib/libsodium.so.7

So, I'd say, you should use something else than cffi, so that users without a full development installation or on other (linux-incompatible systems) can use pbp.

best regards, Tom

stef commented 10 years ago

thanks, will switch over to ctypes interface.

stef commented 10 years ago

i ported pysodium 0.6 over to bare ctypes, i hope this fixes this issue. see: https://github.com/stef/pysodium/commit/ae46955cbe32da03832e0ed995e27ed17199c58f

would be nice if you could confirm this: https://pypi.python.org/pypi/pysodium/0.6

thanks so much! happy hacking,s