mirror of
https://github.com/docling-project/docling-parse.git
synced 2026-05-17 13:10:49 +00:00
1ef8e22aca
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
376 lines
16 KiB
YAML
376 lines
16 KiB
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
publish:
|
|
type: boolean
|
|
description: "If true, the packages will be published."
|
|
default: false
|
|
|
|
concurrency:
|
|
group: wheels-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.publish }}
|
|
cancel-in-progress: ${{ !inputs.publish }}
|
|
|
|
env:
|
|
CMAKE_BUILD_TYPE: Release
|
|
|
|
jobs:
|
|
build_sdist:
|
|
name: Build sdist artifacts
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Install uv and set the python version
|
|
uses: astral-sh/setup-uv@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- name: Build sdist
|
|
run: |
|
|
uv build
|
|
ls ./dist
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: python-package-distributions-sdist
|
|
path: dist/
|
|
|
|
build_wheels:
|
|
name: Build wheel for py${{ matrix.python-version }} ${{ matrix.os.platform_id }}
|
|
runs-on: ${{ matrix.os.name }}
|
|
|
|
strategy:
|
|
# Ensure that a wheel builder finishes even if another fails
|
|
# list of github vm: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
|
fail-fast: false
|
|
matrix:
|
|
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
|
|
os:
|
|
- name: "ubuntu-24.04"
|
|
platform: "linux"
|
|
platform_id: "manylinux_x86_64"
|
|
|
|
- name: "ubuntu-24.04-arm"
|
|
platform: "linux"
|
|
platform_id: "manylinux_aarch64"
|
|
|
|
- name: "macos-14"
|
|
platform: "macos"
|
|
min_macos_version: "14"
|
|
platform_id: "macosx_arm64"
|
|
|
|
- name: "windows-2025"
|
|
platform: "windows"
|
|
platform_id: "win_amd64"
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv and set the python version
|
|
uses: astral-sh/setup-uv@v5
|
|
id: py
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Set up custom PATH and set py version to cpXYZ [windows]
|
|
if: ${{matrix.os.platform_id == 'win_amd64'}}
|
|
shell: pwsh
|
|
run: |
|
|
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "C:\Users\runneradmin\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "C:\nasm" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
$version = "${{ matrix.python-version }}"
|
|
$cp_version = "cp$($version -replace '\.', '')"
|
|
Add-Content -Path $env:GITHUB_ENV -Value "python_cp_version=$cp_version"
|
|
|
|
- name: Convert python version to cpXYZ
|
|
if: ${{matrix.os.platform_id != 'win_amd64'}}
|
|
run: |
|
|
version=${{ matrix.python-version }}
|
|
cp_version="cp${version//.}"
|
|
echo "python_cp_version=$cp_version" >> $GITHUB_ENV
|
|
|
|
- name: Build wheels [macos-x86_64]
|
|
if: ${{matrix.os.platform_id == 'macosx_x86_64'}}
|
|
env:
|
|
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
|
|
CIBW_ARCHS: x86_64
|
|
CIBW_ARCHS_MACOS: x86_64
|
|
CIBW_PLATFORM: macos
|
|
CIBW_SKIP: "pp* *-musllinux_* *_i686* *_s390* *arm64* *pypy*"
|
|
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
|
|
CIBW_BUILD_VERBOSITY: 3
|
|
CMAKE_OSX_ARCHITECTURES: x86_64
|
|
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
|
|
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.min_macos_version }}.0"
|
|
ARCHFLAGS: -arch x86_64
|
|
BUILD_THREADS: "1"
|
|
PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0"
|
|
run: |
|
|
PY_CACHE_TAG=$(uv run python -c 'import sys;print(sys.implementation.cache_tag)')
|
|
echo "Building wheel ${CIBW_BUILD} ${{ env.CIBW_BUILD }}"
|
|
echo "Building cp: ${{ env.python_cp_version }}"
|
|
echo "Building cache_tag: ${PY_CACHE_TAG}"
|
|
echo "Building platform_id: ${{ matrix.os.platform_id }}"
|
|
echo "Building with BUILD_THREADS: ${BUILD_THREADS:-not set}"
|
|
uv run python --version
|
|
uv run python --version | grep ${{ matrix.python-version }}
|
|
cat ./pyproject.toml
|
|
uv pip install --group build
|
|
rm -rf ./build || true
|
|
python -m cibuildwheel --output-dir ./wheelhouse
|
|
echo "step 1"
|
|
ls -l wheelhouse
|
|
uv run wheel tags --remove --platform-tag macosx_${{ matrix.os.min_macos_version }}_0_x86_64 ./wheelhouse/*.whl
|
|
rm -f ./wheelhouse/*arm64.whl
|
|
echo "step 2"
|
|
ls -l wheelhouse
|
|
uv run delocate-wheel --require-archs x86_64 -v ./wheelhouse/*.whl
|
|
echo "step 3"
|
|
ls -l wheelhouse
|
|
for file in ./wheelhouse/*.whl; do
|
|
echo "Inspecting $file"
|
|
uv run python -m zipfile --list "$file"
|
|
echo "Checking if .so is contained in the wheel"
|
|
uv run python -m zipfile --list "$file" | grep \\.so
|
|
echo "Checking if the correct python version is contained in the wheel"
|
|
uv run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
|
|
done
|
|
mkdir -p ./dist
|
|
cp wheelhouse/*.whl ./dist/
|
|
|
|
# there is an error with the tagging of wheels for macosx-arm64
|
|
# see note: https://cibuildwheel.readthedocs.io/en/stable/faq/
|
|
# see here: https://gist.github.com/anderssonjohan/49f07e33fc5cb2420515a8ac76dc0c95#file-build-pendulum-wheels-yml-L39-L53
|
|
- name: Build wheels [macos-arm64]
|
|
if: ${{matrix.os.platform_id == 'macosx_arm64'}}
|
|
env:
|
|
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
|
|
CIBW_ARCHS: arm64
|
|
CIBW_ARCHS_MACOS: arm64
|
|
CIBW_PLATFORM: macos
|
|
CIBW_SKIP: "pp* *-musllinux_* *_i686* *x86_64* *_s390* *pypy*"
|
|
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
|
|
CIBW_BUILD_VERBOSITY: 3
|
|
CMAKE_OSX_ARCHITECTURES: arm64
|
|
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # do not run delocate-wheel before the re-tag
|
|
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.min_macos_version }}.0"
|
|
ARCHFLAGS: -arch arm64
|
|
BUILD_THREADS: "4"
|
|
PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0"
|
|
CUDA_VISIBLE_DEVICES: "cpu"
|
|
run: |
|
|
PY_CACHE_TAG=$(uv run python -c 'import sys;print(sys.implementation.cache_tag)')
|
|
echo "Building wheel ${CIBW_BUILD} ${{ env.CIBW_BUILD }}"
|
|
echo "Building cp: ${{ env.python_cp_version }}"
|
|
echo "Building cache_tag: ${PY_CACHE_TAG}"
|
|
echo "Building platform_id: ${{ matrix.os.platform_id }}"
|
|
echo "Building with BUILD_THREADS: ${BUILD_THREADS:-not set}"
|
|
uv run python --version
|
|
uv run python --version | grep ${{ matrix.python-version }}
|
|
cat ./pyproject.toml
|
|
uv pip install --group build
|
|
rm -rf ./build || true
|
|
python -m cibuildwheel --output-dir ./wheelhouse
|
|
echo "step 1"
|
|
ls -l wheelhouse
|
|
uv run wheel tags --remove --platform-tag macosx_${{ matrix.os.min_macos_version }}_0_arm64 ./wheelhouse/*.whl
|
|
rm -f ./wheelhouse/*x86_64.whl
|
|
echo "step 2"
|
|
ls -l wheelhouse
|
|
uv run delocate-wheel --require-archs arm64 -v ./wheelhouse/*.whl
|
|
echo "step 3"
|
|
ls -l wheelhouse
|
|
for file in ./wheelhouse/*.whl; do
|
|
echo "Inspecting $file"
|
|
uv run python -m zipfile --list "$file"
|
|
echo "Checking if .so is contained in the wheel"
|
|
uv run python -m zipfile --list "$file" | grep \\.so
|
|
echo "Checking if the correct python version is contained in the wheel"
|
|
uv run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
|
|
done
|
|
mkdir -p ./dist
|
|
cp wheelhouse/*.whl ./dist/
|
|
|
|
- name: Set up QEMU [linux]
|
|
if: startsWith(matrix.os.name, 'ubuntu')
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Build wheels [linux]
|
|
if: startsWith(matrix.os.name, 'ubuntu')
|
|
env:
|
|
CIBW_BUILD: ${{ env.python_cp_version }}-${{ matrix.os.platform_id }}
|
|
CIBW_ARCHS: auto x86_64 aarch64
|
|
CIBW_PLATFORM: linux
|
|
CIBW_SKIP: "pp* *musllinux_* *_i686* *_s390* *pypy*"
|
|
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
|
|
CIBW_BUILD_VERBOSITY: 3
|
|
# Multi-threading: pass BUILD_THREADS into the cibuildwheel Docker container.
|
|
# Comment out the next line to disable parallel builds.
|
|
CIBW_ENVIRONMENT_PASS_LINUX: "BUILD_THREADS"
|
|
BUILD_THREADS: "4"
|
|
run: |
|
|
PY_CACHE_TAG=$(uv run python -c 'import sys;print(sys.implementation.cache_tag)')
|
|
echo "Building cp: ${{ env.python_cp_version }}"
|
|
echo "Building cache_tag: ${PY_CACHE_TAG}"
|
|
echo "Building platform_id: ${{ matrix.os.platform_id }}"
|
|
echo "Building with BUILD_THREADS: ${BUILD_THREADS:-not set}"
|
|
uv run python --version
|
|
uv run python --version | grep ${{ matrix.python-version }}
|
|
cat ./pyproject.toml
|
|
uv pip install --group build
|
|
rm -rf ./build || true
|
|
python -m cibuildwheel --output-dir ./wheelhouse
|
|
ls -l ./wheelhouse
|
|
for file in ./wheelhouse/*.whl; do
|
|
echo "Inspecting $file"
|
|
uv run python -m zipfile --list "$file"
|
|
echo "Checking if .so is contained in the wheel"
|
|
uv run python -m zipfile --list "$file" | grep \\.so
|
|
echo "Checking if the correct python version is contained in the wheel"
|
|
uv run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
|
|
done
|
|
mkdir -p ./dist
|
|
cp wheelhouse/*.whl ./dist/
|
|
|
|
- name: Set up MSYS2 [windows]
|
|
if: ${{matrix.os.platform_id == 'win_amd64'}}
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
update: true
|
|
install: >
|
|
mingw-w64-x86_64-toolchain
|
|
mingw-w64-x86_64-gcc-libs
|
|
|
|
- name: Set up external-libs [windows]
|
|
if: ${{matrix.os.platform_id == 'win_amd64'}}
|
|
shell: pwsh
|
|
run: |
|
|
Copy-Item -Path "C:/mingw64/bin/libgcc_s_seh-1.dll" -Destination ".\docling_parse"
|
|
Copy-Item -Path "C:/mingw64/bin/libstdc++-6.dll" -Destination ".\docling_parse"
|
|
Copy-Item -Path "C:/mingw64/bin/libwinpthread-1.dll" -Destination ".\docling_parse"
|
|
New-Item -Path 'C:\windows-libs' -ItemType Directory -Force
|
|
Invoke-WebRequest -Uri 'https://github.com/qpdf/external-libs/releases/download/release-2024-06-07/qpdf-external-libs-bin.zip' -OutFile 'C:\windows-libs\qpdf-external-libs-bin.zip'
|
|
Expand-Archive -Path 'C:\windows-libs\qpdf-external-libs-bin.zip' -DestinationPath 'C:\windows-libs' -Force
|
|
Get-ChildItem -Path 'C:\windows-libs' -Recurse
|
|
|
|
- name: Set up NASM assembler [windows]
|
|
if: ${{matrix.os.platform_id == 'win_amd64'}}
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -Path 'C:\nasm' -ItemType Directory -Force
|
|
Invoke-WebRequest -Uri 'https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip' -OutFile 'C:\nasm-2.16.03-win64.zip'
|
|
Expand-Archive -Path 'C:\nasm-2.16.03-win64.zip' -DestinationPath 'C:\nasm-temp' -Force
|
|
Copy-Item -Path 'C:\nasm-temp\nasm-2.16.03\nasm.exe' -Destination 'C:\nasm\nasm.exe'
|
|
Remove-Item -Path 'C:\nasm-2.16.03-win64.zip' -Force
|
|
Remove-Item -Path 'C:\nasm-temp' -Recurse -Force
|
|
nasm -v
|
|
|
|
- name: Build wheels
|
|
if: ${{matrix.os.platform_id == 'win_amd64'}}
|
|
env:
|
|
CIBW_PLATFORM: windows
|
|
CIBW_BUILD_VERBOSITY: 3
|
|
CIBW_ARCHS: AMD64
|
|
CIBW_SKIP: "pp*"
|
|
CIBW_PROJECT_REQUIRES_PYTHON: "~=${{ matrix.python-version }}.0"
|
|
PKG_CONFIG_PATH: "C:/msys64/usr/lib/pkgconfig"
|
|
PKG_CONFIG_EXECUTABLE: "C:/mingw64/bin/pkg-config.exe"
|
|
CMAKE_PREFIX_PATH: "C:/msys64/mingw64;C:/mingw64;C:/windows-libs/external-libs"
|
|
CMAKE_LIBRARY_PATH: "C:/msys64/mingw64/lib;C:/mingw64/lib;C:/windows-libs/external-libs/lib-mingw64"
|
|
CMAKE_INCLUDE_PATH: "C:/msys64/mingw64/include;C:/mingw64/include;C:/windows-libs/external-libs/include"
|
|
CMAKE_GENERATOR: "MSYS Makefiles"
|
|
BUILD_THREADS: 4
|
|
ASM_NASM: "C:/nasm/nasm.exe"
|
|
shell: pwsh
|
|
run: |
|
|
if (Test-Path "C:\Strawberry\") {
|
|
Remove-Item -Recurse -Force "C:\Strawberry\"
|
|
}
|
|
$env:CMAKE_ARGS = "-DZLIB_LIBRARY=C:/windows-libs/external-libs/lib-mingw64/libz.a -DZLIB_INCLUDE_DIR=C:/windows-libs/external-libs/include -DJPEG_LIBRARY=C:/windows-libs/external-libs/lib-mingw64/libjpeg.a -DJPEG_INCLUDE_DIR=C:/windows-libs/external-libs/include"
|
|
uv pip install --group build
|
|
if (Test-Path ".\build") {
|
|
Remove-Item -Recurse -Force ".\build"
|
|
}
|
|
uv run python -m cibuildwheel --output-dir .\wheelhouse
|
|
Get-ChildItem -Path .\wheelhouse -Filter *.whl | Format-List
|
|
Get-ChildItem -Path .\wheelhouse -Filter *.whl | ForEach-Object {
|
|
$file = $_.FullName
|
|
Write-Output "Inspecting $file"
|
|
uv run python -m zipfile --list "$file"
|
|
}
|
|
if (-not (Test-Path -Path .\dist)) {
|
|
New-Item -Path .\dist -ItemType Directory
|
|
}
|
|
Copy-Item -Path .\wheelhouse\*.whl -Destination .\dist\
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: python-package-distributions-py${{ matrix.python-version }}-${{ matrix.os.platform_id }}
|
|
path: dist/
|
|
|
|
publish-packages:
|
|
name: >-
|
|
Publish Python 🐍 distribution 📦 to PyPI
|
|
if: inputs.publish && startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
|
|
needs:
|
|
- build_sdist
|
|
- build_wheels
|
|
runs-on: ubuntu-24.04
|
|
environment:
|
|
name: pypi
|
|
url: https://pypi.org/p/docling-parse
|
|
permissions:
|
|
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
contents: write # IMPORTANT: mandatory for adding artifacts to GitHub Releases
|
|
steps:
|
|
- name: Download all the dists
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
merge-multiple: true
|
|
path: dist/
|
|
- name: List dist/
|
|
run: |
|
|
ls ./dist
|
|
- name: Remove non-manylinux Linux wheels if found
|
|
run: |
|
|
rm -f ./dist/*-linux_x86_64.whl
|
|
- name: List dist/
|
|
run: |
|
|
ls ./dist
|
|
- name: Sign the dists with Sigstore
|
|
uses: sigstore/gh-action-sigstore-python@v3.0.0
|
|
with:
|
|
release-signing-artifacts: false
|
|
inputs: >-
|
|
./dist/*.tar.gz
|
|
./dist/*.whl
|
|
- name: List dist/
|
|
run: |
|
|
ls ./dist
|
|
- name: Upload artifact signatures to GitHub Release
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
# Upload to GitHub Release using the `gh` CLI.
|
|
# `dist/` contains the built packages, and the
|
|
# sigstore-produced signatures and certificates.
|
|
run: >-
|
|
gh release upload
|
|
'${{ github.ref_name }}' dist/**
|
|
--repo '${{ github.repository }}'
|
|
# PyPI does not accept .sigstore artifacts and
|
|
# gh-action-pypi-publish has no option to ignore them.
|
|
- name: Remove sigstore signatures before uploading to PyPI
|
|
run: rm ./dist/*.sigstore.json
|
|
- name: Publish distribution 📦 to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
# currently not working with reusable workflows
|
|
attestations: false
|