Fixes for PyPy
cover Fixes for PyPy
From: Christopher Larson <[email protected]>
These reduce the dependence upon CPython, allowing bitbake to run under PyPy. There doesn't seem to be much performance improvement, but still likely worthwhile.
Please review the following changes for suitability for inclusion. If you have any objections or suggestions for improvement, please respond to the patches. If you agree with the changes, please provide your Acked-by.
The following changes since commit 309f5907a3661821e041ed14645b5d165007b058:
bitbake: Switch to post release version (2016-04-29 07:41:34 +0100)
are available in the git repository at:
https://github.com/kergoth/bitbake pypy-fixup
https://github.com/kergoth/bitbake/tree/pypy-fixup
Christopher Larson (3):
bb.build: handle __builtins__ as a module
bb.event: handle __builtins__ as a module
bb.data_smart: use iter() for __len__
lib/bb/build.py | 9 +++++++-- lib/bb/data_smart.py | 2 +- lib/bb/event.py | 11 ++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-)
Signature · 1 line
2.8.0
PATCH 1/3 bb.build: handle __builtins__ as a module
From: Christopher Larson <[email protected]>
Fixes pypy support.
--- lib/bb/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/bb/build.py +7 -2
@@ -61,8 +61,13 @@ def reset_cache(): # in all namespaces, hence we add them to __builtins__. # If we do not do this and use the exec globals, they will # not be available to subfunctions. -__builtins__['bb'] = bb -__builtins__['os'] = os +if hasattr(__builtins__, '__setitem__'): + builtins = __builtins__ +else: + builtins = __builtins__.__dict__ + +builtins['bb'] = bb +builtins['os'] = os class FuncFailed(Exception): def __init__(self, name = None, logfile = None):
Signature · 1 line
2.8.0
PATCH 2/3 bb.event: handle __builtins__ as a module
From: Christopher Larson <[email protected]>
Fixes pypy support.
--- lib/bb/event.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
lib/bb/event.py +8 -3
@@ -72,11 +72,16 @@ _catchall_handlers = {} _eventfilter = None _uiready = False +if hasattr(__builtins__, '__setitem__'): + builtins = __builtins__ +else: + builtins = __builtins__.__dict__ + def execute_handler(name, handler, event, d): event.data = d addedd = False - if 'd' not in __builtins__: - __builtins__['d'] = d + if 'd' not in builtins: + builtins['d'] = d addedd = True try: ret = handler(event)
@@ -94,7 +99,7 @@ def execute_handler(name, handler, event, d): finally: del event.data if addedd: - del __builtins__['d'] + del builtins['d'] def fire_class_handlers(event, d): if isinstance(event, logging.LogRecord):
Signature · 1 line
2.8.0
PATCH 3/3 bb.data_smart: use iter() for __len__
In reply to Christopher LarsonFrom: Christopher Larson <[email protected]>
It seems the frozenset constructor in pypy runs len(), so we can't pass the DataSmart instance directly to it, instead pass the iterator. Fixes pypy support.
--- lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/data_smart.py +1 -1
@@ -917,7 +917,7 @@ class DataSmart(MutableMapping): yield k def __len__(self): - return len(frozenset(self)) + return len(frozenset(iter(self))) def __getitem__(self, item): value = self.getVar(item, False)
Signature · 1 line
2.8.0