- edited description
C API and PEP8 conflicts with build
Current state of building and installing for Python 3:
nefarious:pyme-py3 ben$ sudo make
python3 gpgme-h-clean.py /opt/local/include/gpgme.h >gpgme.h
swig -python -I/opt/local/include -I/usr/local/include -I/usr/include gpgme.i
gpgme.h:568: Warning 451: Setting a const char * variable may leak memory.
mv pygpgme.py pyme/pygpgme.py
python3 setup.py build -b build
Must specify an input file. Use -help for available options.
make[1]: Nothing to be done for `swig'.
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.4
creating build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/__init__.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/callbacks.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/core.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/errors.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/pygpgme.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/util.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
copying pyme/version.py -> build/lib.macosx-10.9-x86_64-3.4/pyme
creating build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/event.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/import.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/md.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/pk.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/protocol.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/sigsum.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/status.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
copying pyme/constants/validity.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants
creating build/lib.macosx-10.9-x86_64-3.4/pyme/constants/data
copying pyme/constants/data/__init__.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants/data
copying pyme/constants/data/encoding.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants/data
creating build/lib.macosx-10.9-x86_64-3.4/pyme/constants/keylist
copying pyme/constants/keylist/__init__.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants/keylist
copying pyme/constants/keylist/mode.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants/keylist
creating build/lib.macosx-10.9-x86_64-3.4/pyme/constants/sig
copying pyme/constants/sig/__init__.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants/sig
copying pyme/constants/sig/mode.py -> build/lib.macosx-10.9-x86_64-3.4/pyme/constants/sig
running build_ext
building 'pyme._pygpgme' extension
creating build/temp.macosx-10.9-x86_64-3.4
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/src/pyme-py3 -I/opt/local/include -I/usr/local/include -I/usr/local/include/python3.4m -c gpgme_wrap.c -o build/temp.macosx-10.9-x86_64-3.4/gpgme_wrap.o
gpgme_wrap.c:3816:14: warning: comparison of unsigned expression < 0 is always
false [-Wtautological-compare]
if (arg3 < 0) {
~~~~ ^ ~
gpgme_wrap.c:3831:17: warning: implicit declaration of function
'PyString_FromStringAndSize' is invalid in C99
[-Wimplicit-function-declaration]
resultobj = PyString_FromStringAndSize(arg2,result);
^
gpgme_wrap.c:3831:15: warning: incompatible integer to pointer conversion
assigning to 'PyObject *' (aka 'struct _object *') from 'int'
[-Wint-conversion]
resultobj = PyString_FromStringAndSize(arg2,result);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_wrap.c:6601:21: warning: '_py_obsolete_class' is deprecated
[-Wdeprecated-declarations]
if (arg1) (arg1)->_py_obsolete_class = arg2;
^
/usr/local/src/pyme-py3/gpgme.h:689:16: note: '_py_obsolete_class' has been
explicitly marked deprecated here
unsigned int _py_obsolete_class _GPGME_DEPRECATED_OUTSIDE_GPGME;
^
gpgme_wrap.c:6623:36: warning: '_py_obsolete_class' is deprecated
[-Wdeprecated-declarations]
result = (unsigned int) ((arg1)->_py_obsolete_class);
^
/usr/local/src/pyme-py3/gpgme.h:689:16: note: '_py_obsolete_class' has been
explicitly marked deprecated here
unsigned int _py_obsolete_class _GPGME_DEPRECATED_OUTSIDE_GPGME;
^
gpgme_wrap.c:10945:14: warning: comparison of unsigned expression < 0 is always
false [-Wtautological-compare]
if (arg3 < 0) {
~~~~ ^ ~
gpgme_wrap.c:10962:15: warning: incompatible integer to pointer conversion
assigning to 'PyObject *' (aka 'struct _object *') from 'int'
[-Wint-conversion]
resultobj = PyString_FromStringAndSize(arg2,result);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_wrap.c:13706:21: warning: '_py_obsolete_class' is deprecated
[-Wdeprecated-declarations]
if (arg1) (arg1)->_py_obsolete_class = arg2;
^
/usr/local/src/pyme-py3/gpgme.h:1337:16: note: '_py_obsolete_class' has been
explicitly marked deprecated here
unsigned int _py_obsolete_class _GPGME_DEPRECATED_OUTSIDE_GPGME;
^
gpgme_wrap.c:13728:36: warning: '_py_obsolete_class' is deprecated
[-Wdeprecated-declarations]
result = (unsigned int) ((arg1)->_py_obsolete_class);
^
/usr/local/src/pyme-py3/gpgme.h:1337:16: note: '_py_obsolete_class' has been
explicitly marked deprecated here
unsigned int _py_obsolete_class _GPGME_DEPRECATED_OUTSIDE_GPGME;
^
gpgme_wrap.c:19535:21: warning: 'err' is deprecated [-Wdeprecated-declarations]
if (arg1) (arg1)->err = arg2;
^
/usr/local/src/pyme-py3/gpgme.h:1799:17: note: 'err' has been explicitly marked
deprecated here
gpgme_error_t err _GPGME_DEPRECATED_OUTSIDE_GPGME;
^
gpgme_wrap.c:19557:22: warning: 'err' is deprecated [-Wdeprecated-declarations]
result = ((arg1)->err);
^
/usr/local/src/pyme-py3/gpgme.h:1799:17: note: 'err' has been explicitly marked
deprecated here
gpgme_error_t err _GPGME_DEPRECATED_OUTSIDE_GPGME;
^
11 warnings generated.
gcc -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/src/pyme-py3 -I/opt/local/include -I/usr/local/include -I/usr/local/include/python3.4m -c helpers.c -o build/temp.macosx-10.9-x86_64-3.4/helpers.o
helpers.c:48:18: warning: implicit declaration of function 'PyInt_AsLong' is
invalid in C99 [-Wimplicit-function-declaration]
err_status = PyInt_AsLong(error);
^
helpers.c:82:28: warning: implicit declaration of function 'PyString_FromString'
is invalid in C99 [-Wimplicit-function-declaration]
PyTuple_SetItem(args, 0, PyString_FromString(uid_hint));
^
helpers.c:82:28: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'PyObject *' (aka 'struct _object *')
[-Wint-conversion]
PyTuple_SetItem(args, 0, PyString_FromString(uid_hint));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/python3.4m/tupleobject.h:46:67: note: passing argument to
parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
helpers.c:83:28: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'PyObject *' (aka 'struct _object *')
[-Wint-conversion]
PyTuple_SetItem(args, 1, PyString_FromString(passphrase_info));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/python3.4m/tupleobject.h:46:67: note: passing argument to
parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
helpers.c:98:17: warning: implicit declaration of function 'PyString_AsString'
is invalid in C99 [-Wimplicit-function-declaration]
write(fd, PyString_AsString(retval), PyString_Size(retval));
^
helpers.c:98:44: warning: implicit declaration of function 'PyString_Size' is
invalid in C99 [-Wimplicit-function-declaration]
write(fd, PyString_AsString(retval), PyString_Size(retval));
^
helpers.c:98:17: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'const void *' [-Wint-conversion]
write(fd, PyString_AsString(retval), PyString_Size(retval));
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/unistd.h:490:33: note: passing argument to parameter here
ssize_t write(int, const void *, size_t) __DARWIN_ALIAS_C(write);
^
helpers.c:132:28: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'PyObject *' (aka 'struct _object *')
[-Wint-conversion]
PyTuple_SetItem(args, 0, PyString_FromString(what));
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/python3.4m/tupleobject.h:46:67: note: passing argument to
parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
helpers.c:133:28: warning: implicit declaration of function 'PyInt_FromLong' is
invalid in C99 [-Wimplicit-function-declaration]
PyTuple_SetItem(args, 1, PyInt_FromLong((long) type));
^
helpers.c:133:28: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'PyObject *' (aka 'struct _object *')
[-Wint-conversion]
PyTuple_SetItem(args, 1, PyInt_FromLong((long) type));
^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/python3.4m/tupleobject.h:46:67: note: passing argument to
parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
helpers.c:134:28: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'PyObject *' (aka 'struct _object *')
[-Wint-conversion]
PyTuple_SetItem(args, 2, PyInt_FromLong((long) current));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/python3.4m/tupleobject.h:46:67: note: passing argument to
parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
helpers.c:135:28: warning: incompatible integer to pointer conversion passing
'int' to parameter of type 'PyObject *' (aka 'struct _object *')
[-Wint-conversion]
PyTuple_SetItem(args, 3, PyInt_FromLong((long) total));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/python3.4m/tupleobject.h:46:67: note: passing argument to
parameter here
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
^
12 warnings generated.
gcc -bundle -undefined dynamic_lookup build/temp.macosx-10.9-x86_64-3.4/gpgme_wrap.o build/temp.macosx-10.9-x86_64-3.4/helpers.o -L/usr/local/lib -o build/lib.macosx-10.9-x86_64-3.4/pyme/_pygpgme.so -L/opt/local/lib -lgpgme -L/usr/local/lib -lassuan -lgpg-error
nefarious:pyme-py3 ben$ sudo make install
python3 setup.py build -b build
Must specify an input file. Use -help for available options.
make[1]: Nothing to be done for `swig'.
running build
running build_py
running build_ext
python3 setup.py install --skip-build
Must specify an input file. Use -help for available options.
make[1]: Nothing to be done for `swig'.
running install
running install_lib
creating /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/__init__.py -> /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/_pygpgme.so -> /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/callbacks.py -> /usr/local/lib/python3.4/site-packages/pyme
creating /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/__init__.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
creating /usr/local/lib/python3.4/site-packages/pyme/constants/data
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/data/__init__.py -> /usr/local/lib/python3.4/site-packages/pyme/constants/data
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/data/encoding.py -> /usr/local/lib/python3.4/site-packages/pyme/constants/data
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/event.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/import.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
creating /usr/local/lib/python3.4/site-packages/pyme/constants/keylist
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/keylist/__init__.py -> /usr/local/lib/python3.4/site-packages/pyme/constants/keylist
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/keylist/mode.py -> /usr/local/lib/python3.4/site-packages/pyme/constants/keylist
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/md.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/pk.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/protocol.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
creating /usr/local/lib/python3.4/site-packages/pyme/constants/sig
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/sig/__init__.py -> /usr/local/lib/python3.4/site-packages/pyme/constants/sig
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/sig/mode.py -> /usr/local/lib/python3.4/site-packages/pyme/constants/sig
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/sigsum.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/status.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/constants/validity.py -> /usr/local/lib/python3.4/site-packages/pyme/constants
copying build/lib.macosx-10.9-x86_64-3.4/pyme/core.py -> /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/errors.py -> /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/pygpgme.py -> /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/util.py -> /usr/local/lib/python3.4/site-packages/pyme
copying build/lib.macosx-10.9-x86_64-3.4/pyme/version.py -> /usr/local/lib/python3.4/site-packages/pyme
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/__init__.py to __init__.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/callbacks.py to callbacks.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/__init__.py to __init__.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/data/__init__.py to __init__.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/data/encoding.py to encoding.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/event.py to event.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/import.py to import.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/keylist/__init__.py to __init__.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/keylist/mode.py to mode.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/md.py to md.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/pk.py to pk.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/protocol.py to protocol.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/sig/__init__.py to __init__.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/sig/mode.py to mode.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/sigsum.py to sigsum.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/status.py to status.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/constants/validity.py to validity.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/core.py to core.cpython-34.pyc
Sorry: TabError: inconsistent use of tabs and spaces in indentation (core.py, line 106)
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/errors.py to errors.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/pygpgme.py to pygpgme.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/util.py to util.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/pyme/version.py to version.cpython-34.pyc
running install_egg_info
Writing /usr/local/lib/python3.4/site-packages/pyme-0.9.0-py3.4.egg-info
nefarious:pyme-py3 ben$ cd
nefarious:~ ben$ py3
Python 3.4.3 (default, Mar 11 2015, 20:57:53)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyme
>>> dir(pyme)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> from pyme import core, constants, error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/site-packages/pyme/core.py", line 106
if key:
^
TabError: inconsistent use of tabs and spaces in indentation
>>> dir(pyme.core)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'core'
>>> dir(pyme.__all__
... )
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> dir(pyme)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>>
>>> ^D
nefarious:~ ben$
Comments (5)
-
reporter -
reporter On the off chance that anyone other than Martin and I actually read this thing, the error above is actually a good sign, since it shows that porting pyme to Python 3 is not impossible and it can build. This point was reached after only a few hours of porting work.
-
reporter All the Python errors have been fixed, now I just need to know how to correctly call swig to support Python 3 so that the auto-generated component actually loads and then it should work (though those C warnings are likely to persist).
-
reporter Solved much of the above problems, but this has revealed real conflicts in the C code regarding aspects of Python 2 which do not exist in Python 3:
>>> from pyme import core Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/site-packages/pyme/core.py", line 21, in <module> from . import pygpgme File "/usr/local/lib/python3.4/site-packages/pyme/pygpgme.py", line 28, in <module> _pygpgme = swig_import_helper() File "/usr/local/lib/python3.4/site-packages/pyme/pygpgme.py", line 24, in swig_import_helper _mod = imp.load_module('_pygpgme', fp, pathname, description) File "/usr/local/lib/python3.4/imp.py", line 243, in load_module return load_dynamic(name, filename, file) ImportError: dlopen(/usr/local/lib/python3.4/site-packages/pyme/_pygpgme.so, 2): Symbol not found: _PyInt_AsLong Referenced from: /usr/local/lib/python3.4/site-packages/pyme/_pygpgme.so Expected in: flat namespace in /usr/local/lib/python3.4/site-packages/pyme/_pygpgme.so >>>
The _PyInt_AsLong symbol clearly refers to the old long integer numbers used in Python 2 and which are no longer necessary in Python 3.
There may be other, as yet undiscovered errors.
-
reporter - edited description
- changed status to closed
PyME was successfully ported to Python 3 not long after this report was made and now lives on as the official Python bindings for GPGME. Yay for me.
- Log in to comment