From 45ef9011c29b342f0c61e3ebe430ffff09e65501 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 12 Sep 2022 14:17:50 -0400 Subject: [PATCH] update-manpages: force use of active interp Since the repo wrapper uses #!/usr/bin/python, use the python3 that this wrapper is actively using. Change-Id: I03d1e54418d18a504eec628e549b4cc233621c45 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/345294 Reviewed-by: LaMont Jones Tested-by: Mike Frysinger --- release/update-manpages | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/release/update-manpages b/release/update-manpages index ddbce0cc..d619cf0b 100755 --- a/release/update-manpages +++ b/release/update-manpages @@ -59,18 +59,26 @@ def main(argv): version = RepoSourceVersion() cmdlist = [['help2man', '-N', '-n', f'repo {cmd} - manual page for repo {cmd}', '-S', f'repo {cmd}', '-m', 'Repo Manual', f'--version-string={version}', - '-o', MANDIR.joinpath(f'repo-{cmd}.1.tmp'), TOPDIR.joinpath('repo'), + '-o', MANDIR.joinpath(f'repo-{cmd}.1.tmp'), './repo', '-h', f'help {cmd}'] for cmd in subcmds.all_commands] cmdlist.append(['help2man', '-N', '-n', 'repository management tool built on top of git', '-S', 'repo', '-m', 'Repo Manual', f'--version-string={version}', - '-o', MANDIR.joinpath('repo.1.tmp'), TOPDIR.joinpath('repo'), + '-o', MANDIR.joinpath('repo.1.tmp'), './repo', '-h', '--help-all']) with tempfile.TemporaryDirectory() as tempdir: - repo_dir = Path(tempdir) / '.repo' + tempdir = Path(tempdir) + repo_dir = tempdir / '.repo' repo_dir.mkdir() (repo_dir / 'repo').symlink_to(TOPDIR) + # Create a repo wrapper using the active Python executable. We can't pass + # this directly to help2man as it's too simple, so insert it via shebang. + data = (TOPDIR / 'repo').read_text(encoding='utf-8') + tempbin = tempdir / 'repo' + tempbin.write_text(f'#!{sys.executable}\n' + data, encoding='utf-8') + tempbin.chmod(0o755) + # Run all cmd in parallel, and wait for them to finish. with multiprocessing.Pool() as pool: pool.map(partial(worker, cwd=tempdir, check=True), cmdlist)