S4 icon indicating copy to clipboard operation
S4 copied to clipboard

S4 Python API not ported to python3 properly

Open soamaven opened this issue 8 years ago • 5 comments

Seems like there are a few issues with using the S4 library in python3 (specifically 3.4, but likely all python3.x). Seems like the compilation issues come mostly from the PyString and PyInt calls. Seems like it might be a quick fix to main_python.c if someone really wants to use python3 (i think just change PyString_* to PyUnicode_* or PyBytes_* and PyInt_* to PyLong_*, i forked to give this a try one day, but really py3c should be used for bidirectional compatibility between python2<->python3.3+), but i'll stick with 2.7 for now probably Error Below: >>> import S4 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /usr/lib64/python3.4/site-packages/S4.cpython-34m.so: undefined symbol: PyString_AsStringAndSize

soamaven avatar Apr 30 '16 20:04 soamaven

Have you (or anyone else) had any luck fixing this? I have been able to get the extension working in Python 2.7, but not Python 3.x...

phoebe-p avatar Jun 07 '17 15:06 phoebe-p

I have managed to build the extension for Python 3.4 and 3.6 using the changes to main_python.c suggested by @soamaven above -- see this fork.

phoebe-p avatar Jun 26 '17 13:06 phoebe-p

@phoebe-p that was simpler that I thought it would be! Looks like you made the source incompatible with python2.7 though. May be as simple as adding some more pre-processor if-else statements to account for #if PY_MAJOR_VERSION < 3 properly

soamaven avatar Jul 13 '17 00:07 soamaven

Actually from the changes you had to make, it seems that the preprocessor logic is bad. You hacked around that by just making sure the compiler used the py3 syntax. We may be able to just rework it to have it working on both python versions and pull it into the main repo.

soamaven avatar Jul 13 '17 01:07 soamaven

Sure, I wasn't trying to preserve compatibility with Python2 since I was just trying to get it to work for myself in Py3!

phoebe-p avatar Jul 13 '17 13:07 phoebe-p