mercurial/__init__.py
changeset 29266 b3a677c82a35
parent 28513 859af6e78368
child 29490 b4d117cee636
equal deleted inserted replaced
29265:3f9e68864ccc 29266:b3a677c82a35
    10 import imp
    10 import imp
    11 import os
    11 import os
    12 import sys
    12 import sys
    13 import zipimport
    13 import zipimport
    14 
    14 
       
    15 from . import (
       
    16     policy
       
    17 )
       
    18 
    15 __all__ = []
    19 __all__ = []
    16 
    20 
    17 # Rules for how modules can be loaded. Values are:
    21 modulepolicy = policy.policy
    18 #
       
    19 #    c - require C extensions
       
    20 #    allow - allow pure Python implementation when C loading fails
       
    21 #    py - only load pure Python modules
       
    22 #
       
    23 # By default, require the C extensions for performance reasons.
       
    24 modulepolicy = 'c'
       
    25 try:
       
    26     from . import __modulepolicy__
       
    27     modulepolicy = __modulepolicy__.modulepolicy
       
    28 except ImportError:
       
    29     pass
       
    30 
       
    31 # PyPy doesn't load C extensions.
       
    32 #
       
    33 # The canonical way to do this is to test platform.python_implementation().
       
    34 # But we don't import platform and don't bloat for it here.
       
    35 if '__pypy__' in sys.builtin_module_names:
       
    36     modulepolicy = 'py'
       
    37 
       
    38 # Our C extensions aren't yet compatible with Python 3. So use pure Python
       
    39 # on Python 3 for now.
       
    40 if sys.version_info[0] >= 3:
       
    41     modulepolicy = 'py'
       
    42 
       
    43 # Environment variable can always force settings.
       
    44 modulepolicy = os.environ.get('HGMODULEPOLICY', modulepolicy)
       
    45 
    22 
    46 # Modules that have both Python and C implementations. See also the
    23 # Modules that have both Python and C implementations. See also the
    47 # set of .py files under mercurial/pure/.
    24 # set of .py files under mercurial/pure/.
    48 _dualmodules = set([
    25 _dualmodules = set([
    49     'mercurial.base85',
    26     'mercurial.base85',