diff --git a/.github/workflows/build-docvortex.yml b/.github/workflows/build-docvortex.yml new file mode 100644 index 000000000000..863a4bc6a2ef --- /dev/null +++ b/.github/workflows/build-docvortex.yml @@ -0,0 +1,171 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# Based on upstream's wheel builder: +# https://github.com/myhloli/DocVortex/blob/v0.6.11/.github/workflows/native-wheels.yml +# docvortex is a PyO3/Rust extension built with setuptools-rust (not maturin): +# setup.py already sets py_limited_api itself, so no CIBW_CONFIG_SETTINGS is +# needed to get the abi3 wheel (contrast build-bcrypt.yml). Upstream refuses to +# build at all under free-threaded CPython (setup.py raises on +# Py_GIL_DISABLED), so there is no cp*t job here either. +name: Build docvortex wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'Version glob to (re)build; empty builds every version of docs/packages/docvortex.yaml not released yet' + required: false + default: '' + pull_request: + branches: [main] + paths: + - '.github/workflows/build-docvortex.yml' + - 'docs/packages/docvortex.yaml' + push: + branches: [main] + paths: + - '.github/workflows/build-docvortex.yml' + - 'docs/packages/docvortex.yaml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + with: + package: docvortex + version: ${{ inputs.version }} + + build_wheels: + needs: [setup] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + name: Build docvortex ${{ matrix.version }} cp311-abi3-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 90 + env: + DOCVORTEX_VERSION: ${{ matrix.version }} + + steps: + - name: Checkout docvortex ${{ env.DOCVORTEX_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: myhloli/DocVortex + ref: v${{ env.DOCVORTEX_VERSION }} + persist-credentials: false + + - name: Build and test wheel + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + env: + CIBW_ARCHS: riscv64 + # The wheel is cp311-abi3, so it is compiled on cp311 (gotcha 96). + # Its runtime dependency onnxruntime has no cp311 riscv64 wheel on + # PyPI or pypi.riseproject.dev (cp312+ only), so the cp311 install + # before the tests cannot resolve. cibuildwheel reuses the same abi3 + # wheel for cp312 and tests it there; skip only the cp311 test + # (gotcha 216). + CIBW_BUILD: 'cp311-* cp312-*' + CIBW_SKIP: '*-musllinux_*' + CIBW_TEST_SKIP: 'cp311-*' + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + CIBW_BEFORE_ALL_LINUX: >- + export CARGO_HOME=/opt/docvortex-cargo RUSTUP_HOME=/opt/docvortex-rustup; + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs + | sh -s -- -y --profile minimal --default-toolchain 1.98.1 + CIBW_ENVIRONMENT_LINUX: >- + PATH="/opt/docvortex-cargo/bin:$PATH" + CARGO_HOME=/opt/docvortex-cargo + RUSTUP_HOME=/opt/docvortex-rustup + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ + # PyPI's newest pillow/numpy can be sdist-only on riscv64 while our + # registry still hosts the previous release's wheel (gotcha 354). + CIBW_TEST_ENVIRONMENT: PIP_PREFER_BINARY=1 + # Upstream pins pypdfium2==5.13.0 because its golden fixtures + # (tests/fixtures/native_pdf_06_golden.json.gz) were generated with + # it, i.e. with PDFium 153.0.7999 from pdfium-binaries. The riscv64 + # 5.13.0 wheel on PyPI is instead a source build of the older PDFium + # 151.0.7913, whose FPDFText_GetFontWeight derives the weight from + # the font descriptor's StemV (250/440 instead of the golden's 400), + # failing test_real_font_and_geometry_bridge_parity[caibao1,demo2]. + # The riscv64 5.14.0 wheel bundles PDFium 156.0.8076, which matches + # the golden data (the whole suite also passes on x86_64 with + # 5.14.0), and is what `pypdfium2>=5.13.0,<6` resolves to anyway. + CIBW_TEST_REQUIRES: pytest psutil pypdfium2==5.14.0 + CIBW_TEST_COMMAND: >- + python {project}/tools/verify_native_wheel.py {project}/demo/pdfs/demo1.pdf && + python -m pytest + {project}/tests/test_native_parity.py + {project}/tests/test_rule_graphics_acceleration.py + {project}/tests/test_rule_text_acceleration.py + {project}/tests/test_rule_pixel_form_acceleration.py + {project}/tests/test_rule_layout_batch_acceleration.py + {project}/tests/test_rule_numeric_graphics_acceleration.py + {project}/tests/test_rule_fill_bands_acceleration.py + {project}/tests/test_native_statistics.py + {project}/tests/test_native_round3.py + {project}/tests/test_native_round4.py + {project}/tests/test_native_round5.py + {project}/tests/test_native_round6.py + {project}/tests/test_native_round7.py + {project}/tests/test_pdfium_bridge.py + {project}/tests/test_pdf_object_bridge.py + {project}/tests/test_pdf_classify_page_loading.py + {project}/tests/test_pdf_classify_resource_graph.py + {project}/tests/test_pdf_drawing_lines_extraction.py + {project}/tests/test_pdf_native_graphics_components.py + {project}/tests/unittest/test_flash_pdf_auxiliary_text.py + {project}/tests/test_pdf_snapshot.py + {project}/tests/test_native_inline_styles.py + {project}/tests/test_native_bitmap_crops.py + {project}/tests/test_pdf_render_session.py + {project}/tests/test_native_font_runtime.py + {project}/tests/test_native_text_pipeline.py + {project}/tests/test_native_text_snapshot.py + {project}/tests/test_native_classification.py + {project}/tests/test_native_image_text_classification.py + {project}/tests/unittest/test_pdf_classify_image_text.py + {project}/tests/unittest/test_flash_pdf_char_geometry.py + {project}/tests/test_native_table_candidates.py + {project}/tests/test_native_candidate_boundaries.py + {project}/tests/test_native_annotation_geometry.py + {project}/tests/unittest/test_native_pdf_table_demo_manifest.py + {project}/tests/test_pdf_analysis_api.py + {project}/tests/test_pdf_cpu_evidence.py + -q && + python {project}/tools/verify_native_wheel.py {project}/demo/pdfs/demo2.pdf && + python {project}/tools/verify_nonpdf_wheel.py --output {project}/build/nonpdf-cp311 --run-tests + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: docvortex-${{ env.DOCVORTEX_VERSION }}-cp311-abi3-manylinux_riscv64 + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish docvortex ${{ matrix.version }} + needs: [setup, build_wheels] + if: needs.setup.outputs.versions != '[]' + strategy: + fail-fast: false + matrix: + version: ${{ fromJSON(needs.setup.outputs.versions) }} + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + secrets: + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + with: + artifact-pattern: docvortex-${{ matrix.version }}-*-manylinux_riscv64 diff --git a/docs/packages/docvortex.yaml b/docs/packages/docvortex.yaml new file mode 100644 index 000000000000..838af25eecb7 --- /dev/null +++ b/docs/packages/docvortex.yaml @@ -0,0 +1,5 @@ +package-name: docvortex +source-code: https://github.com/myhloli/DocVortex +license: MIT AND Apache-2.0 AND BSD-3-Clause +versions: +- version: 0.6.11