mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
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.
This commit is contained in:
parent
d54666f50a
commit
b4b94546a3
7
setup.py
7
setup.py
@ -212,10 +212,17 @@ if version:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user