The current r4146 svn of pymol doesn't build on x86_64-apple-darwin15 against either python 3.4.3 or 3.5.0 due to unresolved symbols....
gcc -bundle -L/sw/lib/python3.5/config-3.5m -lpython3.5m -L/sw/lib -L/sw/lib -L/sw/lib -Wno-c++11-extensions build/temp.macosx-10.11-x86_64-3.5/contrib/champ/champ.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/champ_module.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/chiral.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/err2.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/feedback2.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/list.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/os_memory.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/sort.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/strblock.o build/temp.macosx-10.11-x86_64-3.5/contrib/champ/vla.o -L/sw/lib -o build/lib.macosx-10.11-x86_64-3.5/chempy/champ/_champ.cpython-35m-darwin.so Undefined symbols for architecture x86_64: "_PyCObject_AsVoidPtr", referenced from: __memory_dump in champ_module.o _insert_pattern_string in champ_module.o _insert_model in champ_module.o _pattern_free in champ_module.o _pattern_clear_tags in champ_module.o _pattern_get_cycle in champ_module.o _pattern_get_class in champ_module.o ... "_PyCObject_Check", referenced from: __memory_dump in champ_module.o _insert_pattern_string in champ_module.o _insert_model in champ_module.o _pattern_free in champ_module.o _pattern_clear_tags in champ_module.o _pattern_get_cycle in champ_module.o _pattern_get_class in champ_module.o ... "_PyCObject_FromVoidPtr", referenced from: __new in champ_module.o "_PyInt_AsLong", referenced from: _ChampModelToPat in champ.o "_PyInt_Check", referenced from: _ChampModelToPat in champ.o "_PyInt_FromLong", referenced from: _pattern_get_cycle in champ_module.o _pattern_get_class in champ_module.o _pattern_get_tags in champ_module.o _pattern_get_tag_masks in champ_module.o _pattern_get_ext_indices_with_tags in champ_module.o _list_get_pattern_indices in champ_module.o _match_1v1_map in champ_module.o ... "_PyNumber_Int", referenced from: _ChampModelToPat in champ.o "_PyString_AsString", referenced from: _PConvPyObjectToStrMaxClean in champ.o _list_prepend_pattern_strings in champ_module.o "_PyString_Check", referenced from: _PConvPyObjectToStrMaxClean in champ.o "_PyString_FromString", referenced from: _pattern_get_codes in champ_module.o _pattern_get_string in champ_module.o _pattern_get_atom_symbols in champ_module.o _pattern_get_atom_names in champ_module.o _list_get_pattern_strings in champ_module.o "_Py_InitModule", referenced from: _init_champ in champ_module.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
These unresolved symbols can be fixed with the following change...
--- pymol-1.8.0.0/contrib/champ/os_python.h.orig 2015-12-12 10:11:29.000000000 -0500 +++ pymol-1.8.0.0/contrib/champ/os_python.h 2015-12-12 10:12:11.000000000 -0500 @@ -18,6 +18,30 @@ #include"Python.h" +#if PY_MAJOR_VERSION >= 3 +# define PyInt_Check PyLong_Check +# define PyInt_FromLong PyLong_FromLong +# define PyInt_AsLong PyLong_AsLong +# define PyInt_AS_LONG PyLong_AS_LONG + +# define PyNumber_Int PyNumber_Long + +# define PyString_Check PyUnicode_Check +# define PyString_Size PyUnicode_GetLength +# define PyString_FromString PyUnicode_FromString +# define PyString_FromStringAndSize PyUnicode_FromStringAndSize +# define PyString_InternFromString PyUnicode_InternFromString +# define PyString_AsString PyUnicode_AsUTF8 +# define PyString_AS_STRING PyUnicode_AsUTF8 + +# define PyCObject_AsVoidPtr(capsule) PyCapsule_GetPointer(capsule, "name") +# define PyCObject_FromVoidPtr(p, d) PyCapsule_New(p, "name", (PyCapsule_Destructor) d) +# define PyCObject_Check PyCapsule_CheckExact + +# define PyEval_EvalCode(o, ...) PyEval_EvalCode((PyObject*)o, __VA_ARGS__) +#endif + + #endif --- pymol-1.8.0.0/contrib/champ/champ_module.c.orig 2015-12-12 10:23:55.000000000 -0500 +++ pymol-1.8.0.0/contrib/champ/champ_module.c 2015-12-12 10:30:58.000000000 -0500 @@ -1051,6 +1051,17 @@ void init_champ(void); void init_champ(void) { +#if PY_MAJOR_VERSION < 3 Py_InitModule("_champ", champ_methods); +#else + static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, + "_champ", NULL, -1, champ_methods }; + PyObject * _champ = PyModule_Create(&moduledef); + if (_champ) { + PyDict_SetItemString(PyImport_GetModuleDict(), "_champ", champ_methods); + Py_DECREF(_champ); + } +#endif + }
and is also attached as pymol-python3.patch.
Note that failure of the APBS Tools plugin to run under python 3.5.x appears to related to...
https://bugs.python.org/issue23466
and isn't fixed in python 3.5.1. Fortunately, python 3.4.3 doesn't trigger this bug.
The proposed patch produces the warning...
so I guess it needs further adjustment.
Is is valid to just use a cast such as...
PyDict_SetItemString(PyImport_GetModuleDict(), "_champ", (PyObject *)champ_methods);
which suppress the warning?
fixed in svn rev 4147