
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 <robin@reportlab.com> wrote:

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.
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.
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 <lac@openend.se> wrote:
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:
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.
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

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 <robin@reportlab.com> wrote:

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.
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.
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 <lac@openend.se> wrote:
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:
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.
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