hgdemandimport/__init__.py
changeset 43076 2372284d9457
parent 37889 670eb4fa1b86
child 44841 40120de810ba
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
    28     '_hashlib',
    28     '_hashlib',
    29     # ImportError during pkg_resources/__init__.py:fixup_namespace_package
    29     # ImportError during pkg_resources/__init__.py:fixup_namespace_package
    30     '_imp',
    30     '_imp',
    31     '_xmlplus',
    31     '_xmlplus',
    32     'fcntl',
    32     'fcntl',
    33     'nt', # pathlib2 tests the existence of built-in 'nt' module
    33     'nt',  # pathlib2 tests the existence of built-in 'nt' module
    34     'win32com.gen_py',
    34     'win32com.gen_py',
    35     'win32com.shell', # 'appdirs' tries to import win32com.shell
    35     'win32com.shell',  # 'appdirs' tries to import win32com.shell
    36     '_winreg', # 2.7 mimetypes needs immediate ImportError
    36     '_winreg',  # 2.7 mimetypes needs immediate ImportError
    37     'pythoncom',
    37     'pythoncom',
    38     # imported by tarfile, not available under Windows
    38     # imported by tarfile, not available under Windows
    39     'pwd',
    39     'pwd',
    40     'grp',
    40     'grp',
    41     # imported by profile, itself imported by hotshot.stats,
    41     # imported by profile, itself imported by hotshot.stats,
    44     # this trips up many extension authors
    44     # this trips up many extension authors
    45     'gtk',
    45     'gtk',
    46     # setuptools' pkg_resources.py expects "from __main__ import x" to
    46     # setuptools' pkg_resources.py expects "from __main__ import x" to
    47     # raise ImportError if x not defined
    47     # raise ImportError if x not defined
    48     '__main__',
    48     '__main__',
    49     '_ssl', # conditional imports in the stdlib, issue1964
    49     '_ssl',  # conditional imports in the stdlib, issue1964
    50     '_sre', # issue4920
    50     '_sre',  # issue4920
    51     'rfc822',
    51     'rfc822',
    52     'mimetools',
    52     'mimetools',
    53     'sqlalchemy.events', # has import-time side effects (issue5085)
    53     'sqlalchemy.events',  # has import-time side effects (issue5085)
    54     # setuptools 8 expects this module to explode early when not on windows
    54     # setuptools 8 expects this module to explode early when not on windows
    55     'distutils.msvc9compiler',
    55     'distutils.msvc9compiler',
    56     '__builtin__',
    56     '__builtin__',
    57     'builtins',
    57     'builtins',
    58     'urwid.command_map', # for pudb
    58     'urwid.command_map',  # for pudb
    59 }
    59 }
    60 
    60 
    61 _pypy = '__pypy__' in sys.builtin_module_names
    61 _pypy = '__pypy__' in sys.builtin_module_names
    62 
    62 
    63 if _pypy:
    63 if _pypy:
    69 # Re-export.
    69 # Re-export.
    70 isenabled = demandimport.isenabled
    70 isenabled = demandimport.isenabled
    71 disable = demandimport.disable
    71 disable = demandimport.disable
    72 deactivated = demandimport.deactivated
    72 deactivated = demandimport.deactivated
    73 
    73 
       
    74 
    74 def enable():
    75 def enable():
    75     # chg pre-imports modules so do not enable demandimport for it
    76     # chg pre-imports modules so do not enable demandimport for it
    76     if ('CHGINTERNALMARK' not in os.environ
    77     if (
    77         and os.environ.get('HGDEMANDIMPORT') != 'disable'):
    78         'CHGINTERNALMARK' not in os.environ
       
    79         and os.environ.get('HGDEMANDIMPORT') != 'disable'
       
    80     ):
    78         demandimport.enable()
    81         demandimport.enable()