Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: python version in wheels #31

Merged
merged 26 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ea993d8
fix: avoid failure when sdist is already pushed
dolfim-ibm Oct 1, 2024
bf55785
add failure if python version is not matching
dolfim-ibm Oct 1, 2024
e1b3453
verbose print
dolfim-ibm Oct 1, 2024
a0545d5
print simple grep
dolfim-ibm Oct 1, 2024
b72a01f
grep proper variable
dolfim-ibm Oct 1, 2024
643faf2
test that the compiled modules are in the wheels
dolfim-ibm Oct 1, 2024
0f7dee9
test the wheel with docling
dolfim-ibm Oct 1, 2024
2ae51de
fix grep for python cache_tag
dolfim-ibm Oct 1, 2024
d32732e
nicer print while checking
dolfim-ibm Oct 1, 2024
2153125
fix env set by setup-python
dolfim-ibm Oct 1, 2024
fc9ee19
fix poetry init and use set MPS watermark
dolfim-ibm Oct 1, 2024
f1ab652
install poetry with pipx
dolfim-ibm Oct 1, 2024
e4e4e7d
verbose print python version
dolfim-ibm Oct 1, 2024
4238961
use explicit python-path output
dolfim-ibm Oct 1, 2024
1b205dd
use findpython3 and promote venv
dolfim-ibm Oct 1, 2024
eba76d3
let pybind11 find Python and use PYTHON_EXECUTABLE
dolfim-ibm Oct 1, 2024
53be288
add useful print
dolfim-ibm Oct 1, 2024
d60f085
remove python3.9 from CI
dolfim-ibm Oct 1, 2024
9ee4c94
Merge remote-tracking branch 'origin/main' into fix-wheels
dolfim-ibm Oct 1, 2024
f85d53e
check wheels
dolfim-ibm Oct 1, 2024
f67c882
add check_wheel.py script
dolfim-ibm Oct 1, 2024
01597fe
fix check wheels
dolfim-ibm Oct 1, 2024
32a9cb1
fix creation of venv
dolfim-ibm Oct 1, 2024
475f34a
fix test with proper arch
dolfim-ibm Oct 2, 2024
cacbf27
check host arch
dolfim-ibm Oct 2, 2024
994018e
remove integration test
dolfim-ibm Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 46 additions & 7 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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'}}
Expand Down Expand Up @@ -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
Expand All @@ -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/
Expand All @@ -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
Expand All @@ -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/
Expand Down Expand Up @@ -183,15 +214,23 @@ 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
ls -l ./wheelhouse
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/
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down