diff --git a/.github/workflows/clingo.yml b/.github/workflows/clingo.yml index becead6..f60ac5b 100644 --- a/.github/workflows/clingo.yml +++ b/.github/workflows/clingo.yml @@ -4,7 +4,7 @@ on: push: branches: - main - tags: + tags: - v0.** pull_request: branches: @@ -21,18 +21,23 @@ env: PYTHONUNBUFFERED: 1 jobs: - macos_clingo: + macos_build: runs-on: ${{ matrix.runner[0] }} strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] # runner + macOS deployment target - runner: [["macos-13", "10.13"], ["macos-14", "11"]] + runner: [["macos-14", "14"], ["macos-15", "15"], ["macos-26", "26"]] exclude: - - python-version: "3.6" - runner: ["macos-14", "11"] - - python-version: "3.7" - runner: ["macos-14", "11"] + - python-version: "3.8" + runner: ["macos-15", "15"] + - python-version: "3.8" + runner: ["macos-26", "26"] + - python-version: "3.9" + runner: ["macos-26", "26"] + permissions: + contents: read + packages: write env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.runner[1] }} steps: @@ -41,7 +46,12 @@ jobs: with: repository: spack/spack path: spack - ref: d36452cf4e70fa1da8b9db43921850872b82ced9 + ref: 734c5db2121b01c373eed6538e452f18887e9e44 + - uses: actions/checkout@v4 + with: + repository: spack/spack-packages + path: spack-packages + ref: a5b98e6b7e411a499f310e048c1d2e39d1004519 # See https://github.com/actions/setup-python/issues/960 - name: Workaround for broken Python versions from setup-python run: brew install gettext zlib @@ -50,93 +60,99 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install clingo-bootstrap run: | - pip install --upgrade pip brew install bison export PATH="$(brew --prefix bison):$PATH" . spack/share/spack/setup-env.sh - spack external find --not-buildable cmake bison + spack config add "config:install_tree:padded_length:256" + spack repo set --destination "$PWD/spack-packages" builtin + spack external find cmake bison spack python clingo/install_clingo.py spack buildcache push --unsigned ./binary-mirror clingo-bootstrap - - uses: actions/upload-artifact@v3 + + - uses: actions/upload-artifact@v5 with: - name: clingo_binary_mirror + name: clingo_binary_mirror-${{ matrix.runner[0] }}-${{ matrix.python-version }} path: binary-mirror - manylinux2014: - runs-on: ["self-hosted", "Linux"] - outputs: - spack_manylinux_tag: ${{ fromJSON(steps.docker_meta.outputs.json).tags[0] }} + manylinux2014_build: + runs-on: "ubuntu-latest" + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] + arch: ["amd64", "arm64", "ppc64le"] permissions: + contents: read packages: write - steps: - uses: actions/checkout@v4 - - # Setup tags to be used for docker images - - uses: docker/metadata-action@v5 - id: docker_meta + - uses: docker/setup-qemu-action@v3 + if: ${{ matrix.arch != 'amd64' }} with: - images: ghcr.io/${{ github.repository_owner }}/clingo_manylinux2014 + platforms: linux/${{ matrix.arch }} + + - uses: docker/setup-buildx-action@v3 - # Login to Github Packages - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ github.token }} - - uses: docker/setup-qemu-action@v3 - id: qemu - with: - platforms: linux/ppc64le,linux/arm64 - - - uses: docker/setup-buildx-action@v3 + - if: ${{ matrix.python-version == '3.14' }} + run: echo "BASE_IMAGE=quay.io/pypa/manylinux2014:2025.11.11-1" >> $GITHUB_ENV + - if: ${{ matrix.python-version != '3.14' }} + run: echo "BASE_IMAGE=ghcr.io/spack/manylinux2014:v2024-10-16" >> $GITHUB_ENV - # Build and eventually push to registry - uses: docker/build-push-action@v5 + id: build with: file: ./clingo/Dockerfile.manylinux2014 - platforms: linux/arm64,linux/ppc64le,linux/amd64 - cache-from: | - ghcr.io/${{ github.repository_owner }}/clingo_manylinux2014:main - ${{ steps.docker_meta.outputs.tags }} + platforms: linux/${{ matrix.arch }} + tags: ghcr.io/${{ github.repository }}/clingo-build:py${{ matrix.python-version }}-${{ matrix.arch }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/clingo-build:py${{ matrix.python-version }}-${{ matrix.arch }} cache-to: type=inline - pull: ${{ github.event_name == 'pull_request' }} push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + load: true + build-args: | + BASE_IMAGE=${{ env.BASE_IMAGE }} + PYTHON_VERSION=${{ matrix.python-version }} - upload-manylinux2014: - runs-on: ubuntu-latest - needs: [ manylinux2014 ] - env: - SPACK_MANYLINUX2014_TAG: ${{ needs.manylinux2014.outputs.spack_manylinux_tag }} - steps: - - uses: actions/checkout@v4 - - run: ./copy_mirror_manylinux2014.sh - - uses: actions/upload-artifact@v3 + - run: | + docker create --name clingo-c --platform linux/${{ matrix.arch }} ${{ steps.build.outputs.imageid }} + docker cp "clingo-c:/root/binary-mirror" binary-mirror + + - uses: actions/upload-artifact@v5 with: - name: clingo_binary_mirror + name: clingo_binary_mirror-linux-${{ matrix.arch }}-${{ matrix.python-version }} path: binary-mirror clingo_json: runs-on: ubuntu-latest - needs: [ upload-manylinux2014, macos_clingo ] + needs: [ macos_build, manylinux2014_build ] steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: spack/spack path: spack - ref: d36452cf4e70fa1da8b9db43921850872b82ced9 - - uses: actions/download-artifact@v3 + ref: 734c5db2121b01c373eed6538e452f18887e9e44 + - uses: actions/checkout@v4 with: - name: clingo_binary_mirror - - run: ./spack/bin/spack python ./generate_bootstrap_json.py clingo - - uses: actions/upload-artifact@v3 + repository: spack/spack-packages + path: spack-packages + ref: a5b98e6b7e411a499f310e048c1d2e39d1004519 + + - uses: actions/download-artifact@v6 + + - run: | + . spack/share/spack/setup-env.sh + spack repo set --destination "$PWD/spack-packages" builtin + spack python ./generate_bootstrap_json.py clingo + + - uses: actions/upload-artifact@v5 with: name: clingo_manifest path: clingo.json diff --git a/.github/workflows/gnupg.yml b/.github/workflows/gnupg.yml index 3bb3670..fb77859 100644 --- a/.github/workflows/gnupg.yml +++ b/.github/workflows/gnupg.yml @@ -4,7 +4,7 @@ on: push: branches: - main - tags: + tags: - v0.** pull_request: branches: @@ -21,7 +21,7 @@ env: PYTHONUNBUFFERED: 1 jobs: - macos_gnupg: + macos_build: runs-on: ${{ matrix.runner[0] }} strategy: # List of: @@ -30,8 +30,9 @@ jobs: # 3. macOS deployment target matrix: runner: [ - ["macos-13", "x86_64", "10.13"], # highsierra - ["macos-14", "aarch64", "11"] # bigsur + ["macos-14", "aarch64", "14"], + ["macos-15", "aarch64", "15"], + ["macos-26", "aarch64", "26"] ] env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.runner[2] }} @@ -41,7 +42,12 @@ jobs: with: repository: spack/spack path: spack - ref: d36452cf4e70fa1da8b9db43921850872b82ced9 + ref: 734c5db2121b01c373eed6538e452f18887e9e44 + - uses: actions/checkout@v4 + with: + repository: spack/spack-packages + path: spack-packages + ref: a5b98e6b7e411a499f310e048c1d2e39d1004519 - name: Install gnupg run: | brew install gawk perl @@ -49,90 +55,91 @@ jobs: # Disables internationalization to avoid linking to # libintl on MacOS, since that will make the binary # non portable - git -C spack apply "$PWD/gnupg/patches/gnupg_macos.patch" + git -C spack-packages apply "$PWD/gnupg/patches/gnupg_macos.patch" . spack/share/spack/setup-env.sh + spack repo set --destination "$PWD/spack-packages" builtin + + rm -rf $(spack location -p podman) + spack external find --not-buildable gawk perl spack config add "config:install_tree:padded_length:256" + spack install gnupg target=${{ matrix.runner[1] }} spack buildcache push --unsigned ./binary-mirror gnupg - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v5 with: - name: gnupg_binary_mirror + name: gnupg_binary_mirror-${{ matrix.runner[0] }}-${{ matrix.runner[1] }} path: binary-mirror - manylinux2014: - runs-on: ["self-hosted", "Linux"] - outputs: - spack_manylinux_tag: ${{ fromJSON(steps.docker_meta.outputs.json).tags[0] }} - + manylinux2014_build: + runs-on: "ubuntu-latest" + strategy: + matrix: + arch: ["amd64", "arm64", "ppc64le"] + permissions: + contents: read + packages: write steps: - uses: actions/checkout@v4 - - # Setup tags to be used for docker images - - uses: docker/metadata-action@v5 - id: docker_meta - with: - images: ghcr.io/${{ github.repository_owner }}/gnupg_manylinux2014 - - # Login to Github Packages - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/setup-qemu-action@v3 - id: qemu + if: ${{ matrix.arch != 'amd64' }} with: - platforms: linux/ppc64le,linux/arm64,linux/amd64 + platforms: linux/${{ matrix.arch }} - uses: docker/setup-buildx-action@v3 - # Build and eventually push to registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - uses: docker/build-push-action@v5 + id: build with: file: ./gnupg/Dockerfile.manylinux2014 - platforms: linux/arm64,linux/ppc64le,linux/amd64 - pull: ${{ github.event_name == 'pull_request' }} - cache-from: | - ghcr.io/${{ github.repository_owner }}/gnupg_manylinux2014:main - ${{ steps.docker_meta.outputs.tags }} + platforms: linux/${{ matrix.arch }} + tags: ghcr.io/${{ github.repository }}/gnupg-build:${{ matrix.arch }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/gnupg-build:${{ matrix.arch }} cache-to: type=inline push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + load: true - upload-manylinux2014: - runs-on: ubuntu-latest - needs: [ manylinux2014 ] - env: - SPACK_MANYLINUX2014_TAG: ${{ needs.manylinux2014.outputs.spack_manylinux_tag }} + - run: | + docker create --name gnupg-c --platform linux/${{ matrix.arch }} ${{ steps.build.outputs.imageid }} + docker cp "gnupg-c:/root/binary-mirror" binary-mirror - steps: - - uses: actions/checkout@v4 - - run: ./copy_mirror_manylinux2014.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v5 with: - name: gnupg_binary_mirror + name: gnupg_binary_mirror-linux-${{ matrix.arch }} path: binary-mirror gnupg_json: runs-on: ubuntu-latest - needs: [ upload-manylinux2014, macos_gnupg ] + needs: [ macos_build, manylinux2014_build ] steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: spack/spack path: spack - ref: d36452cf4e70fa1da8b9db43921850872b82ced9 - - uses: actions/download-artifact@v3 + ref: 734c5db2121b01c373eed6538e452f18887e9e44 + - uses: actions/checkout@v4 with: - name: gnupg_binary_mirror - - run: ./spack/bin/spack python ./generate_bootstrap_json.py gnupg - - uses: actions/upload-artifact@v3 + repository: spack/spack-packages + path: spack-packages + ref: a5b98e6b7e411a499f310e048c1d2e39d1004519 + - uses: actions/download-artifact@v6 + + - run: | + . spack/share/spack/setup-env.sh + spack repo set --destination "$PWD/spack-packages" builtin + spack python ./generate_bootstrap_json.py gnupg + + - uses: actions/upload-artifact@v5 with: name: gnupg_manifest path: gnupg.json diff --git a/.github/workflows/patchelf.yml b/.github/workflows/patchelf.yml index 72f17ce..614f6e6 100644 --- a/.github/workflows/patchelf.yml +++ b/.github/workflows/patchelf.yml @@ -4,7 +4,7 @@ on: push: branches: - main - tags: + tags: - v0.** pull_request: branches: @@ -21,78 +21,73 @@ env: PYTHONUNBUFFERED: 1 jobs: - - manylinux2014: - runs-on: ubuntu-20.04 - outputs: - spack_manylinux_tag: ${{ fromJSON(steps.docker_meta.outputs.json).tags[0] }} - + manylinux2014_build: + runs-on: "ubuntu-latest" + strategy: + matrix: + arch: ["amd64", "arm64", "ppc64le"] + permissions: + contents: read + packages: write steps: - uses: actions/checkout@v4 - - # Setup tags to be used for docker images - - uses: docker/metadata-action@v5 - id: docker_meta - with: - images: ghcr.io/${{ github.repository_owner }}/patchelf_manylinux2014 - - # Login to Github Packages - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/setup-qemu-action@v3 - id: qemu + if: ${{ matrix.arch != 'amd64' }} with: - platforms: linux/ppc64le,linux/arm64,linux/amd64 + platforms: linux/${{ matrix.arch }} - uses: docker/setup-buildx-action@v3 - # Build and eventually push to registry + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - uses: docker/build-push-action@v5 + id: build with: file: ./patchelf/Dockerfile.manylinux2014 - platforms: linux/arm64,linux/ppc64le,linux/amd64 - pull: ${{ github.event_name == 'pull_request' }} - cache-from: | - ghcr.io/${{ github.repository_owner }}/patchelf_manylinux2014:main - ${{ steps.docker_meta.outputs.tags }} + platforms: linux/${{ matrix.arch }} + tags: ghcr.io/${{ github.repository }}/patchelf-build:${{ matrix.arch }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/patchelf-build:${{ matrix.arch }} cache-to: type=inline push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + load: true - upload-manylinux2014: - runs-on: ubuntu-latest - needs: [ manylinux2014 ] - env: - SPACK_MANYLINUX2014_TAG: ${{ needs.manylinux2014.outputs.spack_manylinux_tag }} + - run: | + docker create --name patchelf-c --platform linux/${{ matrix.arch }} ${{ steps.build.outputs.imageid }} + docker cp "patchelf-c:/root/binary-mirror" binary-mirror - steps: - - uses: actions/checkout@v4 - - run: ./copy_mirror_manylinux2014.sh - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v5 with: - name: patchelf_binary_mirror + name: patchelf_binary_mirror-linux-${{ matrix.arch }} path: binary-mirror patchelf_json: runs-on: ubuntu-latest - needs: [ upload-manylinux2014 ] + needs: [ manylinux2014_build ] steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: repository: spack/spack path: spack - ref: d36452cf4e70fa1da8b9db43921850872b82ced9 - - uses: actions/download-artifact@v3 + ref: 734c5db2121b01c373eed6538e452f18887e9e44 + - uses: actions/checkout@v4 with: - name: patchelf_binary_mirror - - run: ./spack/bin/spack python ./generate_bootstrap_json.py patchelf - - uses: actions/upload-artifact@v3 + repository: spack/spack-packages + path: spack-packages + ref: a5b98e6b7e411a499f310e048c1d2e39d1004519 + - uses: actions/download-artifact@v6 + + - run: | + . spack/share/spack/setup-env.sh + spack repo set --destination "$PWD/spack-packages" builtin + spack python ./generate_bootstrap_json.py patchelf + + - uses: actions/upload-artifact@v5 with: name: patchelf_manifest path: patchelf.json diff --git a/clingo/Dockerfile.manylinux2014 b/clingo/Dockerfile.manylinux2014 index 257183f..fa771c4 100644 --- a/clingo/Dockerfile.manylinux2014 +++ b/clingo/Dockerfile.manylinux2014 @@ -1,4 +1,7 @@ -FROM ghcr.io/spack/manylinux2014:v2024-10-16 +ARG BASE_IMAGE=ghcr.io/spack/manylinux2014:v2024-10-16 +FROM ${BASE_IMAGE} + +ARG PYTHON_VERSION RUN tar -C /opt/_internal -xvf /opt/_internal/static-libs-for-embedding-only.tar.xz @@ -10,23 +13,30 @@ ENV PATH="/root/spack/bin/:$PATH" \ PYTHONUNBUFFERED=1 # Clone the repo and install Spack -RUN git clone https://github.com/spack/spack.git && \ - git -C spack checkout -b docker-reference d36452cf4e70fa1da8b9db43921850872b82ced9 +RUN mkdir /root/spack && \ + cd /root/spack && \ + git init . && \ + git fetch --depth=1 https://github.com/spack/spack.git 734c5db2121b01c373eed6538e452f18887e9e44:docker-reference && \ + git checkout docker-reference + +RUN mkdir /root/spack-packages && \ + cd /root/spack-packages && \ + git init . && \ + git fetch --depth=1 https://github.com/spack/spack-packages.git a5b98e6b7e411a499f310e048c1d2e39d1004519:docker-reference && \ + git checkout docker-reference -# Set externals, locate compilers -RUN spack external find -j 1 --not-buildable bison cmake +RUN spack repo set --destination /root/spack-packages builtin +RUN spack external find bison cmake RUN spack compiler find RUN spack config add "config:install_tree:padded_length:256" COPY clingo/install_clingo.py /root/install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp36-cp36m/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp37-cp37m/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp38-cp38/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp39-cp39/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp310-cp310/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp311-cp311/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp312-cp312/bin/python3 spack python install_clingo.py -RUN SPACK_PYTHON=/opt/python/cp313-cp313/bin/python3 spack python install_clingo.py +RUN ls /opt/python/ + +RUN export PY_PATH=$(printf '%s' "$PYTHON_VERSION" | \ + awk -F. '{maj=$1; min=$2; suf=(maj*10+min<=37)?"m":""; printf "cp%d%d-cp%d%d%s\n", maj, min, maj, min, suf}') \ + && SPACK_PYTHON=/opt/python/${PY_PATH}/bin/python3 spack python install_clingo.py + +RUN spack buildcache push --unsigned ./binary-mirror clingo-bootstrap -RUN spack buildcache push --unsigned ./binary-mirror $(spack --color=never find --hashes clingo-bootstrap) diff --git a/clingo/install_clingo.py b/clingo/install_clingo.py old mode 100644 new mode 100755 index 7f0e9b2..1ccb404 --- a/clingo/install_clingo.py +++ b/clingo/install_clingo.py @@ -1,8 +1,8 @@ #!/usr/bin/env spack-python -import archspec.cpu import spack.bootstrap.config import spack.main +import spack.vendor.archspec.cpu if __name__ == "__main__": install = spack.main.SpackCommand("install") @@ -12,4 +12,6 @@ f"Installing clingo-bootstrap with Python: " f"{spack.bootstrap.config.spec_for_current_python()}" ) - install(f"clingo-bootstrap@spack +optimized ~docs target={archspec.cpu.host().family}") + install( + f"clingo-bootstrap@spack +optimized ~docs target={spack.vendor.archspec.cpu.host().family}" + ) diff --git a/generate_bootstrap_json.py b/generate_bootstrap_json.py index aafc4af..a1b50e7 100755 --- a/generate_bootstrap_json.py +++ b/generate_bootstrap_json.py @@ -1,54 +1,88 @@ #!/usr/bin/env spack-python """Produce a bootstrap json file for a selected package""" +import sys import glob -import hashlib import json -import os -import sys +import gzip +from pathlib import Path +from typing import List, Dict import spack.deptypes as dt import spack.spec -import spack.traverse -# Each entry in clingo.json has the following keys: -# -# "spec": root spec to be matched -# "binaries": list of tuples (pkg name, dag hash, sha256 sum) +def generate_json(pkg: str, deps=dt.NONE, python: bool = False) -> None: + """ + Generate a bootstrap JSON file for the specified package. -def sha256(path): - fn = hashlib.sha256() - with open(path, "rb") as f: - fn.update(f.read()) - return fn.hexdigest() + Args: + pkg: Package name to generate bootstrap file for + deps: Dependency types to include + python: Whether to reformat Python version in spec format + """ + # clingo-bootstrap is a special case where the pkg name doesn't + # match what we expect as the output json filename and CI/CD stack + name = "clingo-bootstrap" if pkg == "clingo" else pkg + # Find all manifest files in the v3 binary cache + matches = glob.glob( + f"./{pkg}_binary_mirror*/v3/manifests/spec/*/*.spec.manifest.json" + ) -def tarball_hash(path: str): - # extract hash from /path/to/<...>-.spack - name, _ = os.path.splitext(os.path.basename(path)) - return name.split("-")[-1] + shas: Dict[str, str] = {} + specs: List[spack.spec.Spec] = [] + for manifest_path in matches: + with open(manifest_path, "r") as f: + manifest = json.load(f) -def run(pkg: str, deps=dt.NONE, python: bool = False): - name = "clingo-bootstrap" if pkg == "clingo" else pkg - shas = { - tarball_hash(tarball): sha256(tarball) - for tarball in glob.glob("./build_cache/**/*.spack", recursive=True) - } + spec_sha = None + install_sha = None - specs = [ - spack.spec.Spec.from_specfile(f) for f in glob.glob("./build_cache/*.json") if name in f - ] + for manifest_obj in manifest.get("data"): + media_type = manifest_obj.get("mediaType") + if media_type == "application/vnd.spack.spec.v5+json": + spec_sha = manifest_obj.get("checksum") + + elif media_type == "application/vnd.spack.install.v2.tar+gzip": + install_sha = manifest_obj.get("checksum") + + if not (spec_sha and install_sha): + print("Warning: unable to find spec and install checksums in manifest:") + print(f"\n {manifest_path}\n") + continue + + # Extract cache base path from manifest path + base_path = Path(manifest_path).parents[4] + + blob_path = base_path / "blobs" / "sha256" / spec_sha[:2] / spec_sha + try: + with gzip.open(blob_path) as f: + spec = spack.spec.Spec.from_dict(json.load(f)) + + except (IOError, ValueError, json.JSONDecodeError) as e: + print(f"Error loading spec from {blob_path}: {e}") + continue + + shas[spec.dag_hash()] = install_sha + if spec.name == name: + specs.append(spec) - assert len(specs) > 0, f"No specs found for {name}" + if not specs: + raise ValueError(f"No specs found for {pkg}") fmt = "{name}{@version}{%compiler.name} platform={platform} target={target}" + # Define format function based on whether Python version should be included if python: - fmt_spec = lambda s: f"{s.format(fmt)} ^python@{s.dependencies('python')[0].version}" + + def fmt_spec(s): + return f"{s.format(fmt)} ^python@{s.dependencies('python')[0].version}" else: - fmt_spec = lambda s: s.format(fmt) + + def fmt_spec(s): + return s.format(fmt) mirror_info = [ { @@ -62,21 +96,36 @@ def run(pkg: str, deps=dt.NONE, python: bool = False): for s in specs ] - # sort as strings, cause Spec instances with deps don't sort properly + # Sort as strings, cause Spec instances with deps don't sort properly mirror_info.sort(key=lambda x: x["spec"]) + # Write output JSON file with open(f"./{pkg}.json", "w") as f: json.dump({"verified": mirror_info}, f, sort_keys=True, indent=2) -if __name__ == "__main__": - assert len(sys.argv) == 2, f"Usage: {sys.argv[0]} " - pkg = sys.argv[1] +def main() -> None: + """Parse command line arguments and run generation.""" + if len(sys.argv) != 2: + print(f"Usage: {sys.argv[0]} ") + sys.exit(1) + + # Valid bootstrap package options # unfortunately we refer to clingo-bootstrap by alias "clingo" - assert pkg in ("clingo", "gnupg", "patchelf") - run( + pkgs = ("clingo", "gnupg", "patchelf") + + pkg = sys.argv[1] + if pkg not in pkgs: + print(f"Error: {sys.argv[1]} is not one of {pkgs}") + sys.exit(1) + + generate_json( pkg, # clingo is special: statically links libstdc++ and other deps are loaded by interpreter deps=dt.NONE if pkg == "clingo" else dt.LINK | dt.RUN, - python=pkg == "clingo", + python=(pkg == "clingo"), ) + + +if __name__ == "__main__": + main() diff --git a/gnupg/Dockerfile.manylinux2014 b/gnupg/Dockerfile.manylinux2014 index 7bcc10d..be6433b 100644 --- a/gnupg/Dockerfile.manylinux2014 +++ b/gnupg/Dockerfile.manylinux2014 @@ -1,4 +1,4 @@ -FROM ghcr.io/spack/manylinux2014:v2024-10-16 +FROM quay.io/pypa/manylinux2014:2025.11.11-1 WORKDIR /root ENV PATH="/root/spack/bin/:$PATH" \ @@ -8,14 +8,22 @@ ENV PATH="/root/spack/bin/:$PATH" \ PYTHONUNBUFFERED=1 # Clone the repo and install Spack -RUN git clone https://github.com/spack/spack.git && \ - git -C spack checkout -b docker-reference d36452cf4e70fa1da8b9db43921850872b82ced9 +RUN mkdir /root/spack && \ + cd /root/spack && \ + git init . && \ + git fetch --depth=1 https://github.com/spack/spack.git 734c5db2121b01c373eed6538e452f18887e9e44:docker-reference && \ + git checkout docker-reference -# Set externals, locate compilers +RUN mkdir /root/spack-packages && \ + cd /root/spack-packages && \ + git init . && \ + git fetch --depth=1 https://github.com/spack/spack-packages.git a5b98e6b7e411a499f310e048c1d2e39d1004519:docker-reference && \ + git checkout docker-reference + +RUN spack repo set --destination /root/spack-packages builtin RUN spack external find --not-buildable gawk perl RUN spack compiler find RUN spack config add "config:install_tree:padded_length:256" -RUN spack python -c "import archspec.cpu;print(archspec.cpu.host().family)" > target.txt -RUN spack install gnupg "target=$(cat target.txt)" +RUN spack install gnupg "target=$(spack arch --family --target)" RUN spack buildcache push --unsigned ./binary-mirror gnupg diff --git a/gnupg/patches/gnupg_macos.patch b/gnupg/patches/gnupg_macos.patch index f1e6c12..dc9c4db 100644 --- a/gnupg/patches/gnupg_macos.patch +++ b/gnupg/patches/gnupg_macos.patch @@ -1,7 +1,7 @@ diff --git a/var/spack/repos/builtin/packages/gnupg/package.py b/var/spack/repos/builtin/packages/gnupg/package.py index 859389b850..a6d00f2884 100644 ---- a/var/spack/repos/builtin/packages/gnupg/package.py -+++ b/var/spack/repos/builtin/packages/gnupg/package.py +--- a/repos/spack_repo/builtin/packages/gnupg/package.py ++++ b/repos/spack_repo/builtin/packages/gnupg/package.py @@ -85,6 +85,7 @@ def configure_args(self): f"--with-zlib={self.spec['zlib-api'].prefix}", "--without-tar", @@ -12,8 +12,8 @@ index 859389b850..a6d00f2884 100644 if self.spec.satisfies("@2:"): diff --git a/var/spack/repos/builtin/packages/libgpg-error/package.py b/var/spack/repos/builtin/packages/libgpg-error/package.py index 6b78a25423..e1e905fd9b 100644 ---- a/var/spack/repos/builtin/packages/libgpg-error/package.py -+++ b/var/spack/repos/builtin/packages/libgpg-error/package.py +--- a/repos/spack_repo/builtin/packages/libgpg_error/package.py ++++ b/repos/spack_repo/builtin/packages/libgpg_error/package.py @@ -51,6 +51,8 @@ def configure_args(self): "--enable-static", "--enable-shared", diff --git a/patchelf/Dockerfile.manylinux2014 b/patchelf/Dockerfile.manylinux2014 index 758f2fe..eeaab56 100644 --- a/patchelf/Dockerfile.manylinux2014 +++ b/patchelf/Dockerfile.manylinux2014 @@ -1,4 +1,4 @@ -FROM ghcr.io/spack/manylinux2014:v2024-10-16 +FROM quay.io/pypa/manylinux2014:2025.11.11-1 WORKDIR /root ENV PATH="/root/spack/bin/:$PATH" \ @@ -8,14 +8,21 @@ ENV PATH="/root/spack/bin/:$PATH" \ PYTHONUNBUFFERED=1 # Clone the repo and install Spack -RUN git clone https://github.com/spack/spack.git && \ - git -C spack checkout -b docker-reference d36452cf4e70fa1da8b9db43921850872b82ced9 +RUN mkdir /root/spack && \ + cd /root/spack && \ + git init . && \ + git fetch --depth=1 https://github.com/spack/spack.git 734c5db2121b01c373eed6538e452f18887e9e44:docker-reference && \ + git checkout docker-reference -# Set externals, locate compilers -RUN spack external find --not-buildable cmake +RUN mkdir /root/spack-packages && \ + cd /root/spack-packages && \ + git init . && \ + git fetch --depth=1 https://github.com/spack/spack-packages.git a5b98e6b7e411a499f310e048c1d2e39d1004519:docker-reference && \ + git checkout docker-reference + +RUN spack repo set --destination /root/spack-packages builtin RUN spack compiler find RUN spack config add "config:install_tree:padded_length:256" -RUN spack python -c "import archspec.cpu;print(archspec.cpu.host().family)" > target.txt -RUN spack install patchelf "target=$(cat target.txt)" +RUN spack install patchelf "target=$(spack arch --family --target)" RUN spack buildcache push --unsigned ./binary-mirror patchelf