
Hi, i'd like an easy way to test for a) are we running on pypy? b) what is the pypy version. c) access pypy internals such as transparent proxies. Today, it is possible to check for a) via "'__pypy__' in sys.builtin_module_names" and for b) with "sys.pypy_version_info >= (x,y)". There are also a couple of other 'sys.pypy_*' variables. c) can be done by (trying to) import __pypy__. What about rather doing a single clean 'sys.pypy' module namespace such that we can do: a) hasattr(sys, 'pypy') b) sys.pypy.version_info >= (x,y) c) expose the __pypy__ builtin module as sys.pypy? Semantically, the sys module already presents an interaction API with the interpreter. Doing a single namespace looks more elegant to me than of cluttering sys with an artifical 'pypy_*' prefixed namespace and having to (try-except)import __pypy__. best, holger

Hi Holger, On Mon, May 17, 2010 at 11:38:47AM +0200, holger krekel wrote:
You don't have to put the "import __pypy__" in a try-except, if you already checked that "__pypy__" in sys.builtin_module_names. But your solution looks clean, and the point a) becomes shorter too :-) I would like to avoid having the semi-internal interface of PyPy change nearly as much as, say, the one from the py lib one (and I'm not exagerating there: there are *6* different versions of "try: from py.internal.stuff import x" in my own conftest.py :-) . That said, your suggestion seems nice enough. Comments from others? A bientot, Armin.

Hi Holger, On Mon, May 17, 2010 at 11:38:47AM +0200, holger krekel wrote:
You don't have to put the "import __pypy__" in a try-except, if you already checked that "__pypy__" in sys.builtin_module_names. But your solution looks clean, and the point a) becomes shorter too :-) I would like to avoid having the semi-internal interface of PyPy change nearly as much as, say, the one from the py lib one (and I'm not exagerating there: there are *6* different versions of "try: from py.internal.stuff import x" in my own conftest.py :-) . That said, your suggestion seems nice enough. Comments from others? A bientot, Armin.
participants (2)
-
Armin Rigo
-
holger krekel