diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 7fe84c8..2a952e7 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -35,14 +35,6 @@ jobs: - name: Install Python dependencies run: | - pip install git+https://github.com/gardenlinux/glrd.git@v4.1.0 - # Install python-gardenlinux-lib from the same commit the aggregation - # documents (see repos-config.json). This keeps the installed gardenlinux - # module in sync with the fetched source so Sphinx autodoc can import - # gardenlinux.* (e.g. oci -> podman, distro_version -> semver) and generate - # the CLI/API reference pages. Pinning an older release tag here drops - # those deps and breaks the python-gardenlinux-lib-cli reference. - pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@4da13c46b04d531d0bccfb5cb882f8581564af3b pip install -r requirements.txt - name: Run aggregate diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 40fd866..76aa258 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,14 +34,6 @@ jobs: - name: Install Python dependencies run: | - pip install git+https://github.com/gardenlinux/glrd.git@v4.1.0 - # Install python-gardenlinux-lib from the same commit the aggregation - # documents (see repos-config.json). This keeps the installed gardenlinux - # module in sync with the fetched source so Sphinx autodoc can import - # gardenlinux.* (e.g. oci -> podman, distro_version -> semver) and generate - # the CLI/API reference pages. Pinning an older release tag here drops - # those deps and breaks the python-gardenlinux-lib-cli reference. - pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@4da13c46b04d531d0bccfb5cb882f8581564af3b pip install -r requirements.txt - name: Run tests diff --git a/Makefile b/Makefile index 8573fd2..d07a970 100644 --- a/Makefile +++ b/Makefile @@ -39,14 +39,6 @@ help: install: @echo "Installing dependencies..." pnpm install - pip install git+https://github.com/gardenlinux/glrd.git@v4.1.0 - # Install python-gardenlinux-lib from the same commit the aggregation - # documents (see repos-config.json). This keeps the installed gardenlinux - # module in sync with the fetched source so Sphinx autodoc can import - # gardenlinux.* (e.g. oci -> podman, distro_version -> semver) and generate - # the CLI/API reference pages. Pinning an older release tag here drops - # those deps and breaks the python-gardenlinux-lib-cli reference. - pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@4da13c46b04d531d0bccfb5cb882f8581564af3b pip install -r requirements.txt # Documentation Aggregation diff --git a/requirements.txt b/requirements.txt index fc6389f..97b6c41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,8 +3,8 @@ black isort pytest pyyaml -# glrd @ git+https://github.com/gardenlinux/glrd.git@v4.2.0 -# gardenlinux @ git+https://github.com/gardenlinux/python-gardenlinux-lib.git@4da13c46b04d531d0bccfb5cb882f8581564af3b +glrd @ git+https://github.com/gardenlinux/glrd.git@v5.0.0 +gardenlinux @ git+https://github.com/gardenlinux/python-gardenlinux-lib.git@0.10.24 sphinx sphinx-markdown-builder sphinx-rtd-theme diff --git a/src/aggregate.py b/src/aggregate.py index d9d2e47..f8eb85d 100755 --- a/src/aggregate.py +++ b/src/aggregate.py @@ -14,7 +14,6 @@ from aggregation import DocsFetcher, copy_targeted_docs, load_config, save_config from aggregation.flavor_matrix import generate_flavor_matrix_docs from aggregation.github_api import GitHubAPIError, list_repo_releases -from aggregation.install_pins import sync_install_pins from aggregation.release_notes import generate_release_notes_docs from aggregation.releases import generate_release_docs from aggregation.structure import verify_internal_links @@ -281,13 +280,6 @@ def main() -> int: save_config(str(config_path), repos) print(f"\n✓ Config updated: {config_path}") - # Keep python-gardenlinux-lib install pins in sync with the lock so - # the aggregation environments install the same commit they document - # (see aggregation.install_pins for the full rationale). - pgl_commit = resolved_commits.get("python-gardenlinux-lib") - if pgl_commit: - sync_install_pins(project_root, pgl_commit) - # Generate flavor matrix documentation after all repos are aggregated # Use the gardenlinux temp dir (still available inside the with block) if gardenlinux_temp_dir and gardenlinux_temp_dir.exists(): diff --git a/src/aggregation/install_pins.py b/src/aggregation/install_pins.py deleted file mode 100644 index 6715954..0000000 --- a/src/aggregation/install_pins.py +++ /dev/null @@ -1,81 +0,0 @@ -"""Keep python-gardenlinux-lib install pins in sync with repos-config.json. - -``repos-config.json`` is the single source of truth for the commit that the -aggregation pipeline fetches and Sphinx-builds. The environments that run the -aggregation must install the *same* commit so Sphinx autodoc can import that -source's transitive dependencies (e.g. ``oci`` -> ``podman``, -``distro_version`` -> ``semver``) and generate the CLI/API reference pages. -Installing an older release tag drops those deps and breaks the -``python-gardenlinux-lib-cli`` reference during the VitePress build. - -This module rewrites the ``pip install git+.../python-gardenlinux-lib.git@`` -pin in every file that installs the library, using the commit locked in -``repos-config.json``. It is called from ``aggregate.py`` after the lock file is -regenerated (``--update-locks``) so the install pins never drift from the lock. -""" - -import re -from pathlib import Path -from typing import List - -REPO_NAME = "python-gardenlinux-lib" - -# Files whose python-gardenlinux-lib install pin must match repos-config.json. -# Paths are relative to the project root. -INSTALL_PIN_FILES = ( - "requirements.txt", - "Makefile", - ".github/workflows/docs-checks.yml", - ".github/workflows/tests.yml", -) - -# Matches the git ref (tag or commit) after the python-gardenlinux-lib URL. -_INSTALL_RE = re.compile( - r"(git\+https://github\.com/gardenlinux/python-gardenlinux-lib\.git@)[^\s\"']+" -) - - -def sync_install_pins( - project_root: Path, - commit: str, - files: List[str] | None = None, -) -> bool: - """Rewrite python-gardenlinux-lib install pins to *commit*. - - Args: - project_root: Repository root containing the install files. - commit: Commit hash locked in repos-config.json. - files: Optional override of the relative file paths to update - (defaults to :data:`INSTALL_PIN_FILES`). - - Returns: - ``True`` if any file was modified, ``False`` otherwise. - """ - targets = files if files is not None else INSTALL_PIN_FILES - - print(f"Syncing {REPO_NAME} install pins to {commit}") - changed = False - - for rel in targets: - path = project_root / rel - if not path.exists(): - print(f" Skipped (not found): {rel}") - continue - - original = path.read_text(encoding="utf-8") - updated, count = _INSTALL_RE.subn(rf"\g<1>{commit}", original) - - if count == 0: - print(f" Skipped (no install pin): {rel}") - continue - if updated == original: - print(f" Already up to date: {rel}") - continue - - path.write_text(updated, encoding="utf-8") - print(f" Updated {count} pin(s): {rel}") - changed = True - - if not changed: - print("No install pins needed updating.") - return changed diff --git a/src/aggregation/sphinx_builder.py b/src/aggregation/sphinx_builder.py index a9539be..8402b16 100644 --- a/src/aggregation/sphinx_builder.py +++ b/src/aggregation/sphinx_builder.py @@ -67,6 +67,29 @@ def build_sphinx_markdown( print(f" [sphinx] Building Markdown documentation from {docs_source}") + # Step 0: Install the fetched repo so that transitive deps (e.g. podman, + # semver) required by the locked source are available to Sphinx autodoc. + # This ensures the installed package always exactly matches the locked + # source, regardless of what is pinned in requirements.txt. + print(f" [sphinx] Installing package from fetched repo: {repo_dir}") + pip_result = subprocess.run( + [sys.executable, "-m", "pip", "install", str(repo_dir)], + capture_output=True, + text=True, + ) + if pip_result.stdout: + for line in pip_result.stdout.splitlines(): + print(f" [sphinx] {line}") + if pip_result.stderr: + for line in pip_result.stderr.splitlines(): + print(f" [sphinx] {line}") + if pip_result.returncode != 0: + print( + f" [sphinx] pip install failed (exit {pip_result.returncode})", + file=sys.stderr, + ) + return False + with tempfile.TemporaryDirectory() as tmp: build_dir = Path(tmp) / "build" build_dir.mkdir()