# HG changeset patch # User Gregory Szorc # Date 2015-11-25 06:21:51 # Node ID d308a9ca9ed72b1923ed52e9a361a77d554705ea # Parent a40c84defd76412445ecb4c29e729bd510584bb9 mercurial: don't load C extensions from PyPy PyPy isn't compatible with Python C extensions. With this patch, the module load policy is automatically to "Python only" when run under PyPy. `hg` and other Python scripts importing mercurial.* modules will run from the source checkout or any installation when executed with PyPy. This should enable people to more easily experiment with PyPy and its potentially significant performance benefits over CPython! diff --git a/mercurial/__init__.py b/mercurial/__init__.py --- a/mercurial/__init__.py +++ b/mercurial/__init__.py @@ -24,6 +24,13 @@ modulepolicy = '@MODULELOADPOLICY@' if modulepolicy == '@' 'MODULELOADPOLICY' '@': modulepolicy = 'c' +# PyPy doesn't load C extensions. +# +# The canonical way to do this is to test platform.python_implementation(). +# But we don't import platform and don't bloat for it here. +if '__pypy__' in sys.builtin_module_names: + modulepolicy = 'py' + # Environment variable can always force settings. modulepolicy = os.environ.get('HGMODULEPOLICY', modulepolicy)