From 61d4f354528ec44ecf74cbe3e21b56b1da9b5818 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 26 Aug 2026 21:24:44 +0200 Subject: [PATCH 1/2] dbt-extractor: add build-dbt-extractor.yml for riscv64 wheels dbt-extractor is a PyO3/maturin extension (Rust + the tree-sitter-jinja2 grammar) that dbt-core uses to extract refs/sources/configs from model files. Upstream publishes manylinux wheels for x86_64, i686, aarch64, armv7, s390x, ppc64le and ppc64, but not riscv64. Modelled on the linux/linux-cross jobs of upstream's release.yml, narrowed to riscv64 and run through cibuildwheel. pyo3 carries the `abi3-py39` feature, so maturin emits one cp39-abi3 wheel - the same single Linux wheel per arch upstream ships - built once on cp312 and reused (and tested) on cp313/cp314. musllinux is dropped: rustup.rs has no riscv64 musl toolchain. Upstream cuts releases without git tags, so the checkout is pinned to the 0.6.0 release commit; its tree is byte-identical to the PyPI sdist. The test step goes beyond upstream's `import dbt_extractor` smoke check and extracts from a model exercising refs, sources and configs. --- .github/workflows/build-dbt-extractor.yml | 112 ++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/build-dbt-extractor.yml diff --git a/.github/workflows/build-dbt-extractor.yml b/.github/workflows/build-dbt-extractor.yml new file mode 100644 index 000000000..3543b7e8f --- /dev/null +++ b/.github/workflows/build-dbt-extractor.yml @@ -0,0 +1,112 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the `linux`/`linux-cross` jobs of +# https://github.com/dbt-labs/dbt-extractor/blob/89d46724fc9c7dcd94a03f58342bc4f0d2b7a82e/.github/workflows/release.yml +name: Build dbt-extractor wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'dbt-extractor version to build (e.g. 0.6.0)' + required: true + default: '0.6.0' + pull_request: + paths: + - '.github/workflows/build-dbt-extractor.yml' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '0.6.0' }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + # `inputs.version` is empty on pull_request events; default to 0.6.0 there. + DBT_EXTRACTOR_VERSION: ${{ inputs.version || '0.6.0' }} + # Upstream cuts releases without git tags, so pin the release commit: this is + # "bump patch version, add changelog (#111)", whose tree is byte-identical to + # the 0.6.0 PyPI sdist. Update it alongside DBT_EXTRACTOR_VERSION. + DBT_EXTRACTOR_REF: 89d46724fc9c7dcd94a03f58342bc4f0d2b7a82e + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + build_wheels: + name: Build dbt-extractor ${{ inputs.version || '0.6.0' }} cp39-abi3-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 90 + + steps: + - name: Checkout dbt-extractor ${{ env.DBT_EXTRACTOR_VERSION }} + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + repository: dbt-labs/dbt-extractor + ref: ${{ env.DBT_EXTRACTOR_REF }} + persist-credentials: false + + - name: Build wheel + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + env: + # pyo3 is built with the `abi3-py39` feature, so maturin emits a single + # cp39-abi3 wheel whatever interpreter builds it - matching the one + # Linux wheel upstream publishes per arch. cibuildwheel compiles once + # for cp312 and then reuses that wheel for cp313/cp314 while still + # running the test phase on each. musllinux is excluded because + # rustup.rs ships no riscv64 musl toolchain (as in build-fastuuid.yml). + CIBW_BUILD: cp312-manylinux_riscv64 cp313-manylinux_riscv64 cp314-manylinux_riscv64 + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # dbt-extractor ships no [tool.cibuildwheel], so install the Rust + # toolchain its maturin backend needs in-container and put it on PATH. + CIBW_BEFORE_ALL_LINUX: >- + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + CIBW_ENVIRONMENT_LINUX: 'PATH="$PATH:$HOME/.cargo/bin"' + # Upstream only checks `import dbt_extractor` after building a wheel; + # extract from a model that exercises all three result kinds instead. + CIBW_TEST_COMMAND: >- + python -c "import dbt_extractor; + src = '''{{ config(materialized='table', tags=['a','b']) }} + select * from {{ ref('other_model') }} join {{ source('my_src','my_tbl') }}'''; + r = dbt_extractor.py_extract_from_source(src); + assert r['refs'] == [{'name': 'other_model'}], r; + assert r['sources'] == {('my_src','my_tbl')}, r; + assert r['configs'] == [('materialized','table'), ('tags',['a','b'])], r; + print('dbt_extractor OK:', r)" + + - name: Check the extension made it into the wheel + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + for whl in sys.argv[1:]: + names = zipfile.ZipFile(whl).namelist() + assert "dbt_extractor/dbt_extractor.abi3.so" in names, names + assert any(n.endswith(".dist-info/licenses/LICENSE") for n in names), names + print(whl, "ok") + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: dbt-extractor-${{ env.DBT_EXTRACTOR_VERSION }}-cp39-abi3-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish dbt-extractor ${{ inputs.version || '0.6.0' }} to GitLab + needs: [build_wheels] + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Publish wheels and open docs PR + uses: riseproject-dev/python-wheels/actions/publish-wheels@main + with: + artifact-pattern: dbt-extractor-${{ env.DBT_EXTRACTOR_VERSION }}-*-manylinux_riscv64 + gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }} + gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }} + gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }} + gh-token: ${{ secrets.GITHUB_TOKEN }} From e878d8cd62372d9ae530a0a640a2e4e98acd3cc1 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 26 Aug 2026 21:28:06 +0200 Subject: [PATCH 2/2] dbt-extractor: use the pip build frontend cibuildwheel's default `build` frontend runs `python -m build /project` with cwd=/project. dbt-extractor keeps a dev helper named build.py at its repo root, which then shadows the `build` module; it imports tree_sitter at module level, so the build dies with ModuleNotFoundError before maturin is ever reached. Reproduced in quay.io/pypa/manylinux_2_39_aarch64: the `build` frontend fails there and `pip wheel` builds the cp39-abi3 wheel cleanly. --- .github/workflows/build-dbt-extractor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-dbt-extractor.yml b/.github/workflows/build-dbt-extractor.yml index 3543b7e8f..d9a46c07f 100644 --- a/.github/workflows/build-dbt-extractor.yml +++ b/.github/workflows/build-dbt-extractor.yml @@ -59,6 +59,11 @@ jobs: # rustup.rs ships no riscv64 musl toolchain (as in build-fastuuid.yml). CIBW_BUILD: cp312-manylinux_riscv64 cp313-manylinux_riscv64 cp314-manylinux_riscv64 CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # cibuildwheel's default frontend runs `python -m build /project` with + # cwd=/project, and the repo root holds a dev helper named build.py + # that shadows the `build` module (it imports tree_sitter at top level, + # so the run dies before maturin is reached). pip is unaffected. + CIBW_BUILD_FRONTEND: pip # dbt-extractor ships no [tool.cibuildwheel], so install the Rust # toolchain its maturin backend needs in-container and put it on PATH. CIBW_BEFORE_ALL_LINUX: >-