[PATCH 3 of 4] policy: add cffi policy for PyPy
Maciej Fijalkowski
fijall at gmail.com
Wed Jun 8 03:59:38 EDT 2016
# HG changeset patch
# User Maciej Fijalkowski <fijall at gmail.com>
# Date 1465306558 -7200
# Tue Jun 07 15:35:58 2016 +0200
# Node ID 26a4063b4f1f36607dd673849449292ebc34a91d
# Parent 0cf6303b1018c063ec4ea732cb03dee674792fa8
policy: add cffi policy for PyPy
This adds cffi policy in the case where we don't want to use C modules,
but instead we're happy to rely on cffi (bundled with pypy)
diff -r 0cf6303b1018 -r 26a4063b4f1f mercurial/__init__.py
--- a/mercurial/__init__.py Tue Jun 07 14:44:04 2016 +0200
+++ b/mercurial/__init__.py Tue Jun 07 15:35:58 2016 +0200
@@ -17,11 +17,15 @@
# Rules for how modules can be loaded. Values are:
#
# c - require C extensions
-# allow - allow pure Python implementation when C loading fails
+# allow - allow cffi or pure Python implementation when C loading fails
+# cffi - required cffi versions (implemented within pure module)
+# cffi-allow - allow pure Python implementation if cffi version is missing
# py - only load pure Python modules
#
# By default, require the C extensions for performance reasons.
modulepolicy = 'c'
+policynoc = ('cffi', 'cffi-allow', 'py')
+policynocffi = ('c', 'py')
try:
from . import __modulepolicy__
modulepolicy = __modulepolicy__.modulepolicy
@@ -33,7 +37,7 @@
# 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'
+ modulepolicy = 'cffi'
# Our C extensions aren't yet compatible with Python 3. So use pure Python
# on Python 3 for now.
@@ -82,7 +86,7 @@
return zl
try:
- if modulepolicy == 'py':
+ if modulepolicy in policynoc:
raise ImportError()
zl = ziploader('mercurial')
@@ -109,7 +113,7 @@
stem = name.split('.')[-1]
try:
- if modulepolicy == 'py':
+ if modulepolicy in policynoc:
raise ImportError()
modinfo = imp.find_module(stem, mercurial.__path__)
More information about the Mercurial-devel
mailing list