Mercurial > hg
changeset 28431:a7e3b72cf756
setup: show how to set the module policy for imports
This is not technically needed, since mercurial.__version__
does not exist as a native module, but, without this style wrappings,
if something else had a native flavor, the module loader would get
upset.
In principle, the `env` object is trying to set HGMODULEPOLICY for
children, so, conceptually we should set it for this in-process
child.
author | timeless <timeless@mozdev.org> |
---|---|
date | Tue, 12 Jan 2016 04:45:29 +0000 |
parents | 17b85d739b62 |
children | 2377c4ac4eec |
files | setup.py |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Wed Mar 09 15:47:01 2016 +0000 +++ b/setup.py Tue Jan 12 04:45:29 2016 +0000 @@ -212,10 +212,17 @@ f.write('version = "%s"\n' % version) try: + oldpolicy = os.environ.get('HGMODULEPOLICY', None) + os.environ['HGMODULEPOLICY'] = 'py' from mercurial import __version__ version = __version__.version except ImportError: version = 'unknown' +finally: + if oldpolicy is None: + del os.environ['HGMODULEPOLICY'] + else: + os.environ['HGMODULEPOLICY'] = oldpolicy class hgbuild(build): # Insert hgbuildmo first so that files in mercurial/locale/ are found