I hope this is the right place to ask, but if not just tell me to go away. At the request of a user I'm trying to get reportlab up to scratch for pypy. I have some fairly insignificant bugs in the tests related to Cpython-pypy differences and one C extension that crashes. Firstly what is the best way to approach debugging an extension segfault. Do I need to build pypy with debugging turned on or can I just build the extension like that? Are there any guidelines for making c extensions pypy friendly? Secondly how to cope with some fairly simple testing problems. One of my extensions appears to work, but clearly attempting to verify reference counts is failing ie from sys import getrefcount, _getframe doesn't work. I suppose there's no real point in trying to figure out refcounts for pypy. I have some errors related to co_filename eg
if os.path.splitext(obj.__code__.co_filename)[0]==modBn: AttributeError: 'builtin-code' object has no attribute 'co_filename'
but it's not clear to me if it's even possible to get the filename. Lastly what is the right way to get the platform as pypy not cpython? -- Robin Becker
as far as I remember, C extension in reportlab is optional. Just
disable it. If it's there for speedups, it's very likely it slows
things down on pypy.
Reference count is a fake thing on pypy, don't use it if you can help it.
builtin codes have no filename, you have to somehow deal with it. I
think the problem comes from a fact that on cpython builtin functions
don't have code.
On Mon, Nov 23, 2015 at 2:47 PM, Robin Becker
I hope this is the right place to ask, but if not just tell me to go away.
At the request of a user I'm trying to get reportlab up to scratch for pypy. I have some fairly insignificant bugs in the tests related to Cpython-pypy differences and one C extension that crashes.
Firstly what is the best way to approach debugging an extension segfault. Do I need to build pypy with debugging turned on or can I just build the extension like that?
Are there any guidelines for making c extensions pypy friendly?
Secondly how to cope with some fairly simple testing problems. One of my extensions appears to work, but clearly attempting to verify reference counts is failing
ie from sys import getrefcount, _getframe
doesn't work. I suppose there's no real point in trying to figure out refcounts for pypy.
I have some errors related to co_filename eg
if os.path.splitext(obj.__code__.co_filename)[0]==modBn: AttributeError: 'builtin-code' object has no attribute 'co_filename'
but it's not clear to me if it's even possible to get the filename.
Lastly what is the right way to get the platform as pypy not cpython? -- Robin Becker _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
Lastly what is the right way to get the platform as pypy not cpython? -- Robin Becker
Maciej already answered the other stuff. I had pypy working with reportlab a long time ago just by not using the C extensions at all. Detecting pypy is a bit harder. https://www.python.org/dev/peps/pep-0421/#version-format was supposed to fix things lac@smartwheels:~$ python3.5 Python 3.5.0rc1 (default, Aug 12 2015, 14:57:46) [GCC 5.2.1 20150808] on linux Type "help", "copyright", "credits" or "license" for more information.
import sys sys.implementation namespace(_multiarch='x86_64-linux-gnu', cache_tag='cpython-35', hexversion=50659521, name='cpython', version=sys.version_info(major=3, minor=5, micro=0, releaselevel='candidate', serial=1))
Okay, you could fish around in that and get what you are looking for. But Python 2.7.10 (default, Jul 1 2015, 10:54:53) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import sys sys.implementation Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'implementation'
This won't. So I just try to import __pypy__ If it succeeds, I have pypy, and if it doesn't I assume CPython. Laura
Hi Laura, hi Robin,
On Mon, Nov 23, 2015 at 4:30 PM, Laura Creighton
Lastly what is the right way to get the platform as pypy not cpython?
Detecting pypy is a bit harder.
No, no: the official way since many years is if "__pypy__" in sys.builtin_module_names: A bientôt, Armin.
Thanks Maciej, On 23/11/2015 14:45, Maciej Fijalkowski wrote:
as far as I remember, C extension in reportlab is optional. Just disable it. If it's there for speedups, it's very likely it slows things down on pypy.
I know that reportlab can run without the _rl_accel extension, but the one that's seg faulting is _renderPM which we use to create pix maps (ie raw rgb images). I don't have a python alternative for that so some RL features are unsupported. For PDF only pypy seems to work fine.
Reference count is a fake thing on pypy, don't use it if you can help it.
I think the reference counts are just used to try and see that the _rl_accel.pyd is doing the right thing wrt refcounts.
builtin codes have no filename, you have to somehow deal with it. I think the problem comes from a fact that on cpython builtin functions don't have code.
the test that fails is just trying to check doctests. ......... A bit of googling tells me I should be using platform.python_implementation() to check for pypy. -- Robin Becker
participants (4)
-
Armin Rigo
-
Laura Creighton
-
Maciej Fijalkowski
-
Robin Becker