setup.py
changeset 8629 8e69a22f6792
parent 8628 4dd06ab9217c
child 8648 ca443bac7ed4
equal deleted inserted replaced
8628:4dd06ab9217c 8629:8e69a22f6792
    98     pass
    98     pass
    99 
    99 
   100 version = None
   100 version = None
   101 
   101 
   102 if os.path.isdir('.hg'):
   102 if os.path.isdir('.hg'):
   103     # execute hg out of this directory with a custom environment which
   103     # Execute hg out of this directory with a custom environment which
   104     # includes the pure Python modules in mercurial/pure
   104     # includes the pure Python modules in mercurial/pure. We also take
   105     pypath = os.environ.get('PYTHONPATH', '')
   105     # care to not use any hgrc files and do no localization.
   106     purepath = os.path.join('mercurial', 'pure')
   106     pypath = ['mercurial', os.path.join('mercurial', 'pure')]
   107     os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
   107     env = {'PYTHONPATH': os.pathsep.join(pypath),
   108     os.environ['HGRCPATH'] = '' # do not read any config file
   108            'HGRCPATH': '',
       
   109            'LANGUAGE': 'C'}
   109     cmd = [sys.executable, 'hg', 'id', '-i', '-t']
   110     cmd = [sys.executable, 'hg', 'id', '-i', '-t']
   110 
   111 
   111     out, err = subprocess.Popen(cmd, stdout=subprocess.PIPE,
   112     p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
   112                                 stderr=subprocess.PIPE).communicate()
   113                          stderr=subprocess.PIPE, env=env)
   113     os.environ['PYTHONPATH'] = pypath
   114     out, err = p.communicate()
   114 
   115 
   115     # If root is executing setup.py, but the repository is owned by
   116     # If root is executing setup.py, but the repository is owned by
   116     # another user (as in "sudo python setup.py install") we will get
   117     # another user (as in "sudo python setup.py install") we will get
   117     # trust warnings since the .hg/hgrc file is untrusted. That is
   118     # trust warnings since the .hg/hgrc file is untrusted. That is
   118     # fine, we don't want to load it anyway.
   119     # fine, we don't want to load it anyway.