diff --git a/.github/actions/setup-poetry/action.yml b/.github/actions/setup-poetry/action.yml index e374f039..77a1324e 100644 --- a/.github/actions/setup-poetry/action.yml +++ b/.github/actions/setup-poetry/action.yml @@ -10,13 +10,16 @@ runs: - name: Install poetry run: pipx install poetry==1.8.3 shell: bash - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 + id: py with: python-version: ${{ inputs.python-version }} update-environment: false cache: 'poetry' - name: Setup poetry env with correct python - run: poetry env use python3 + run: | + poetry env use ${{ steps.py.outputs.python-path }} + poetry run python --version shell: bash - name: Install only dependencies and not the package itself run: poetry install --all-extras --no-root diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index def46d2e..3a90d738 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -14,7 +14,7 @@ jobs: # 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.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12"] os: - name: "ubuntu-latest" @@ -51,11 +51,21 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 + id: py with: python-version: ${{ matrix.python-version }} + update-environment: false - name: Install Poetry - run: python -m pip install poetry==1.8.3 + run: | + which python + python --version + which python3 + python3 --version + echo "pythonpath: ${{ steps.py.outputs.python-path }}" + ${{ steps.py.outputs.python-path }} --version + pipx install poetry==1.8.3 + poetry env use ${{ steps.py.outputs.python-path }} - name: Set up custom PATH and set py version to cpXYZ [windows] if: ${{matrix.os.platform_id == 'win_amd64'}} @@ -97,9 +107,15 @@ jobs: CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0" ARCHFLAGS: -arch x86_64 BUILD_THREADS: "4" + PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0" run: | - echo "Building wheel ${CIBW_BUILD}" + PY_CACHE_TAG=$(poetry 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 }}" poetry run python --version + poetry run python --version | grep ${{ matrix.python-version }} poetry install --no-root --only=build cat ./pyproject.toml poetry run python -m cibuildwheel --output-dir wheelhouse @@ -115,6 +131,10 @@ jobs: for file in ./wheelhouse/*.whl; do echo "Inspecting $file" poetry run python -m zipfile --list "$file" + echo "Checking if .so is contained in the wheel" + poetry run python -m zipfile --list "$file" | grep \\.so + echo "Checking if the correct python version is contained in the wheel" + poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG} done mkdir -p ./dist cp wheelhouse/*.whl ./dist/ @@ -137,9 +157,16 @@ jobs: CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0" ARCHFLAGS: -arch arm64 BUILD_THREADS: "4" + PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0" + CUDA_VISIBLE_DEVICES: "cpu" run: | - echo "Building wheel ${CIBW_BUILD}" + PY_CACHE_TAG=$(poetry 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 }}" poetry run python --version + poetry run python --version | grep ${{ matrix.python-version }} poetry install --no-root --only=build cat ./pyproject.toml poetry run python -m cibuildwheel --output-dir wheelhouse @@ -155,6 +182,10 @@ jobs: for file in ./wheelhouse/*.whl; do echo "Inspecting $file" poetry run python -m zipfile --list "$file" + echo "Checking if .so is contained in the wheel" + poetry run python -m zipfile --list "$file" | grep \\.so + echo "Checking if the correct python version is contained in the wheel" + poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG} done mkdir -p ./dist cp wheelhouse/*.whl ./dist/ @@ -183,8 +214,12 @@ jobs: CIBW_BUILD_VERBOSITY: 3 BUILD_THREADS: "8" run: | - echo "Building wheel ${CIBW_BUILD}" + PY_CACHE_TAG=$(poetry 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 }}" poetry run python --version + poetry run python --version | grep ${{ matrix.python-version }} poetry install --no-root --only=build cat ./pyproject.toml poetry run python -m cibuildwheel --output-dir ./wheelhouse @@ -192,6 +227,10 @@ jobs: for file in ./wheelhouse/*.whl; do echo "Inspecting $file" poetry run python -m zipfile --list "$file" + echo "Checking if .so is contained in the wheel" + poetry run python -m zipfile --list "$file" | grep \\.so + echo "Checking if the correct python version is contained in the wheel" + poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG} done mkdir -p ./dist cp wheelhouse/*.whl ./dist/ @@ -256,9 +295,9 @@ jobs: - name: publish wheels (dry run) run: | - poetry publish --dry-run --no-interaction -vvv + poetry publish --skip-existing --dry-run --no-interaction -vvv - name: publish wheels (on publishing) [for releases only] if: ${{ startsWith(github.ref, 'refs/tags/') }} run: | - poetry publish --no-interaction -vvv + poetry publish --skip-existing --no-interaction -vvv diff --git a/CMakeLists.txt b/CMakeLists.txt index d9da5908..86924747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.12..3.26) project(docling_parse VERSION 1.0.0 LANGUAGES CXX C) #set(CMAKE_VERBOSE_MAKEFILE off) @@ -147,7 +147,7 @@ target_link_libraries(parse ${LIB_LINK}) # *************************** # https://pybind11.readthedocs.io/en/stable/compiling.html -find_package (Python COMPONENTS Interpreter Development) +# https://pybind11.readthedocs.io/en/stable/compiling.html#configuration-variables find_package(pybind11 CONFIG REQUIRED) pybind11_add_module(docling_parse "${TOPLEVEL_PREFIX_PATH}/app/pybind_parse.cpp") diff --git a/build.py b/build.py index 9bf71558..0f943ce2 100644 --- a/build.py +++ b/build.py @@ -41,11 +41,11 @@ def run(cmd: List[str], cwd: str="./"): def build_local(num_threads: int): print("python prefix: ", sys.exec_prefix) + print("python executable: ", sys.executable) config_cmd = [ "cmake", "-B", f"{BUILD_DIR}", - f"-DPython_ROOT_DIR={sys.exec_prefix}", - f"-DPython3_ROOT_DIR={sys.exec_prefix}", + f"-DPYTHON_EXECUTABLE={sys.executable}", ] config_cmd.extend(get_pybind11_cmake_args()) success = run(config_cmd, cwd=ROOT_DIR)