Mercurial > hg
comparison setup.py @ 51438:05eba178da45 stable
branching: merge default into stable for 6.7rc0
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 23 Feb 2024 15:10:44 +0100 |
parents | f816ca29a285 |
children | ee132657647d |
comparison
equal
deleted
inserted
replaced
51399:46fed351e451 | 51438:05eba178da45 |
---|---|
219 class hgcommand: | 219 class hgcommand: |
220 def __init__(self, cmd, env): | 220 def __init__(self, cmd, env): |
221 self.cmd = cmd | 221 self.cmd = cmd |
222 self.env = env | 222 self.env = env |
223 | 223 |
224 def __repr__(self): | |
225 return f"<hgcommand cmd={self.cmd} env={self.env}>" | |
226 | |
224 def run(self, args): | 227 def run(self, args): |
225 cmd = self.cmd + args | 228 cmd = self.cmd + args |
226 returncode, out, err = runcmd(cmd, self.env) | 229 returncode, out, err = runcmd(cmd, self.env) |
227 err = filterhgerr(err) | 230 err = filterhgerr(err) |
228 if err: | 231 if err: |
293 | 296 |
294 if os.name != 'nt' or not os.path.exists("hg.exe"): | 297 if os.name != 'nt' or not os.path.exists("hg.exe"): |
295 if attempt(hgcmd + check_cmd, hgenv): | 298 if attempt(hgcmd + check_cmd, hgenv): |
296 return hgcommand(hgcmd, hgenv) | 299 return hgcommand(hgcmd, hgenv) |
297 | 300 |
298 # Fall back to trying the local hg installation. | 301 # Fall back to trying the local hg installation (pure python) |
302 repo_hg = os.path.join(os.path.dirname(__file__), 'hg') | |
299 hgenv = localhgenv() | 303 hgenv = localhgenv() |
300 hgcmd = [sys.executable, 'hg'] | 304 hgcmd = [sys.executable, repo_hg] |
305 if attempt(hgcmd + check_cmd, hgenv): | |
306 return hgcommand(hgcmd, hgenv) | |
307 # Fall back to trying the local hg installation (whatever we can) | |
308 hgenv = localhgenv(pure_python=False) | |
309 hgcmd = [sys.executable, repo_hg] | |
301 if attempt(hgcmd + check_cmd, hgenv): | 310 if attempt(hgcmd + check_cmd, hgenv): |
302 return hgcommand(hgcmd, hgenv) | 311 return hgcommand(hgcmd, hgenv) |
303 | 312 |
304 eprint("/!\\") | 313 eprint("/!\\") |
305 eprint(r"/!\ Unable to find a working hg binary") | 314 eprint(r"/!\ Unable to find a working hg binary") |
317 else: | 326 else: |
318 eprint(r"/!\ exception: ", res[1]) | 327 eprint(r"/!\ exception: ", res[1]) |
319 return None | 328 return None |
320 | 329 |
321 | 330 |
322 def localhgenv(): | 331 def localhgenv(pure_python=True): |
323 """Get an environment dictionary to use for invoking or importing | 332 """Get an environment dictionary to use for invoking or importing |
324 mercurial from the local repository.""" | 333 mercurial from the local repository.""" |
325 # Execute hg out of this directory with a custom environment which takes | 334 # Execute hg out of this directory with a custom environment which takes |
326 # care to not use any hgrc files and do no localization. | 335 # care to not use any hgrc files and do no localization. |
327 env = { | 336 env = { |
328 'HGMODULEPOLICY': 'py', | |
329 'HGRCPATH': '', | 337 'HGRCPATH': '', |
330 'LANGUAGE': 'C', | 338 'LANGUAGE': 'C', |
331 'PATH': '', | 339 'PATH': '', |
332 } # make pypi modules that use os.environ['PATH'] happy | 340 } # make pypi modules that use os.environ['PATH'] happy |
341 if pure_python: | |
342 env['HGMODULEPOLICY'] = 'py' | |
333 if 'LD_LIBRARY_PATH' in os.environ: | 343 if 'LD_LIBRARY_PATH' in os.environ: |
334 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] | 344 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
335 if 'SystemRoot' in os.environ: | 345 if 'SystemRoot' in os.environ: |
336 # SystemRoot is required by Windows to load various DLLs. See: | 346 # SystemRoot is required by Windows to load various DLLs. See: |
337 # https://bugs.python.org/issue13524#msg148850 | 347 # https://bugs.python.org/issue13524#msg148850 |
1819 'license': 'COPYING', | 1829 'license': 'COPYING', |
1820 'readme': 'contrib/packaging/macosx/Readme.html', | 1830 'readme': 'contrib/packaging/macosx/Readme.html', |
1821 'welcome': 'contrib/packaging/macosx/Welcome.html', | 1831 'welcome': 'contrib/packaging/macosx/Welcome.html', |
1822 }, | 1832 }, |
1823 }, | 1833 }, |
1824 **extra | 1834 **extra, |
1825 ) | 1835 ) |