From bd7cbd18feff34032671d8a404be9aa0eea721e9 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 18 Nov 2025 00:58:49 +0100 Subject: [PATCH 1/8] Clone / update basic repositories depending on presence --- generate.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/generate.py b/generate.py index 2a8292b56..3a15afca1 100644 --- a/generate.py +++ b/generate.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import json import concurrent.futures import itertools @@ -20,22 +22,29 @@ generation_time = datetime.now(timezone.utc) -def get_completion_progress() -> Iterator['LanguageProjectData']: +def get_completion_progress() -> Iterator[LanguageProjectData]: clones_dir = Path('clones') - Repo.clone_from( - 'https://github.com/python/devguide.git', - devguide_dir := Path(clones_dir, 'devguide'), - depth=1, - ) + if not (devguide_dir := Path(clones_dir, 'devguide')).exists(): + Repo.clone_from('https://github.com/python/devguide.git', devguide_dir, depth=1) + else: + Repo(devguide_dir).git.pull() latest_branch = branches_from_peps()[0] - Repo.clone_from( - 'https://github.com/python/cpython.git', - cpython_dir := Path(clones_dir, 'cpython'), - depth=1, - branch=latest_branch, - ) + if not (cpython_dir := Path(clones_dir, 'cpython')).exists(): + Repo.clone_from( + 'https://github.com/python/cpython.git', + cpython_dir, + depth=1, + branch=latest_branch, + ) + else: + Repo(cpython_dir).git.pull() subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True) - subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True) + try: + subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True) + except subprocess.CalledProcessError as e: + e.add_note( + 'Try pruning clones/cpython/Doc/venv and/or clones/cpython/Doc/build/doctrees-gettext.' + ) languages_built: dict[str, str] = { language: translated_name From 5246dbb424ef13982336e1eb6f2fdafa66510e75 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 18 Nov 2025 00:59:34 +0100 Subject: [PATCH 2/8] Remove quotes from type annotation --- generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate.py b/generate.py index 3a15afca1..84280a089 100644 --- a/generate.py +++ b/generate.py @@ -65,7 +65,7 @@ def get_project_data( repo: str | None, languages_built: dict[str, str], clones_dir: str, -) -> 'LanguageProjectData': +) -> LanguageProjectData: built = language.code in languages_built if repo: completion, branch, change = get_completion(clones_dir, repo) From f381efb86cc6b079b91e7a41600fb13f61e8a221 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 18 Nov 2025 01:18:32 +0100 Subject: [PATCH 3/8] Update repo depending on presence of translation repositories --- completion.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/completion.py b/completion.py index e8484e34e..155441c08 100644 --- a/completion.py +++ b/completion.py @@ -23,14 +23,20 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: clone_path = Path(clones_dir, 'translations', repo) for branch in branches_from_peps() + ['master', 'main']: try: - clone_repo = git.Repo.clone_from( - f'https://github.com/{repo}.git', clone_path, branch=branch - ) + if not clone_path.exists(): + clone_repo = git.Repo.clone_from( + f'https://github.com/{repo}.git', clone_path, branch=branch + ) + else: + (clone_repo := git.Repo(clone_path)).git.fetch() + clone_repo.git.switch(branch) + clone_repo.git.pull() except git.GitCommandError: - print(f'failed to clone {repo} {branch}') + print(f'failed to clone or switch to {repo} {branch}') branch = '' continue else: + print(f'successfully cloned or switched to {repo} {branch}') break path_for_merge = Path(clones_dir, 'rebased_translations', repo) completion = potodo.merge_and_scan_paths( From d66779a42f72b0b3cd7cc507bb7b756d324c944c Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 18 Nov 2025 01:20:40 +0100 Subject: [PATCH 4/8] Improve log --- completion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion.py b/completion.py index 155441c08..288f0cbe2 100644 --- a/completion.py +++ b/completion.py @@ -32,11 +32,11 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: clone_repo.git.switch(branch) clone_repo.git.pull() except git.GitCommandError: - print(f'failed to clone or switch to {repo} {branch}') + print(f'{repo} {branch}: failed to clone or switch to') branch = '' continue else: - print(f'successfully cloned or switched to {repo} {branch}') + print(f'{repo} {branch}: successfully cloned or switched to') break path_for_merge = Path(clones_dir, 'rebased_translations', repo) completion = potodo.merge_and_scan_paths( From 9b7930de6c39fca301fb332ff72b17c9f54a4d14 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 18 Nov 2025 01:27:24 +0100 Subject: [PATCH 5/8] Improve log --- completion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion.py b/completion.py index 288f0cbe2..0d38fb0c9 100644 --- a/completion.py +++ b/completion.py @@ -32,11 +32,11 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: clone_repo.git.switch(branch) clone_repo.git.pull() except git.GitCommandError: - print(f'{repo} {branch}: failed to clone or switch to') + print(f'failure: {branch} {repo}: clone or switch') branch = '' continue else: - print(f'{repo} {branch}: successfully cloned or switched to') + print(f'success: {branch} {repo}: clone or switch') break path_for_merge = Path(clones_dir, 'rebased_translations', repo) completion = potodo.merge_and_scan_paths( From 2a37f949ee6563f78c0fe5a05381f7250c681ac0 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 18 Nov 2025 21:14:55 +0100 Subject: [PATCH 6/8] Switch to a newer branch in CPython repository --- generate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generate.py b/generate.py index 84280a089..60926f30d 100644 --- a/generate.py +++ b/generate.py @@ -37,7 +37,9 @@ def get_completion_progress() -> Iterator[LanguageProjectData]: branch=latest_branch, ) else: - Repo(cpython_dir).git.pull() + (cpython_repo := Repo(cpython_dir)).git.fetch() + cpython_repo.git.switch(latest_branch) + cpython_repo.git.pull() subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True) try: subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True) From e4c4dbc7fbf3977acdcf95cc12a1610d118b2a71 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 19 Nov 2025 22:26:53 +0100 Subject: [PATCH 7/8] Clean venv and the build before running the gettext build on the CPython clone --- generate.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/generate.py b/generate.py index 60926f30d..88d05e8ad 100644 --- a/generate.py +++ b/generate.py @@ -40,13 +40,10 @@ def get_completion_progress() -> Iterator[LanguageProjectData]: (cpython_repo := Repo(cpython_dir)).git.fetch() cpython_repo.git.switch(latest_branch) cpython_repo.git.pull() + + subprocess.run(['make', '-C', cpython_dir / 'Doc', 'clean'], check=True) subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True) - try: - subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True) - except subprocess.CalledProcessError as e: - e.add_note( - 'Try pruning clones/cpython/Doc/venv and/or clones/cpython/Doc/build/doctrees-gettext.' - ) + subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True) languages_built: dict[str, str] = { language: translated_name From 19282f7b058303c042955ebbe618683aff2ef255 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 19 Nov 2025 22:41:09 +0100 Subject: [PATCH 8/8] Improve log --- completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion.py b/completion.py index 0d38fb0c9..9cbb21392 100644 --- a/completion.py +++ b/completion.py @@ -32,7 +32,7 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, str, float]: clone_repo.git.switch(branch) clone_repo.git.pull() except git.GitCommandError: - print(f'failure: {branch} {repo}: clone or switch') + print(f'failure: {branch} {repo}: clone or switch, continuing') branch = '' continue else: