Skip to content

Commit 8d903ba

Browse files
authored
fix: python version in wheels (#31)
[skip ci] --------- Signed-off-by: Michele Dolfi <[email protected]>
1 parent c342951 commit 8d903ba

File tree

4 files changed

+55
-13
lines changed

4 files changed

+55
-13
lines changed

.github/actions/setup-poetry/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ runs:
1010
- name: Install poetry
1111
run: pipx install poetry==1.8.3
1212
shell: bash
13-
- uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
14+
id: py
1415
with:
1516
python-version: ${{ inputs.python-version }}
1617
update-environment: false
1718
cache: 'poetry'
1819
- name: Setup poetry env with correct python
19-
run: poetry env use python3
20+
run: |
21+
poetry env use ${{ steps.py.outputs.python-path }}
22+
poetry run python --version
2023
shell: bash
2124
- name: Install only dependencies and not the package itself
2225
run: poetry install --all-extras --no-root

.github/workflows/wheels.yml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
# 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
1515
fail-fast: false
1616
matrix:
17-
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
python-version: ["3.10", "3.11", "3.12"]
1818

1919
os:
2020
- name: "ubuntu-latest"
@@ -51,11 +51,21 @@ jobs:
5151

5252
- name: Setup Python
5353
uses: actions/setup-python@v5
54+
id: py
5455
with:
5556
python-version: ${{ matrix.python-version }}
57+
update-environment: false
5658

5759
- name: Install Poetry
58-
run: python -m pip install poetry==1.8.3
60+
run: |
61+
which python
62+
python --version
63+
which python3
64+
python3 --version
65+
echo "pythonpath: ${{ steps.py.outputs.python-path }}"
66+
${{ steps.py.outputs.python-path }} --version
67+
pipx install poetry==1.8.3
68+
poetry env use ${{ steps.py.outputs.python-path }}
5969
6070
- name: Set up custom PATH and set py version to cpXYZ [windows]
6171
if: ${{matrix.os.platform_id == 'win_amd64'}}
@@ -97,9 +107,15 @@ jobs:
97107
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
98108
ARCHFLAGS: -arch x86_64
99109
BUILD_THREADS: "4"
110+
PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0"
100111
run: |
101-
echo "Building wheel ${CIBW_BUILD}"
112+
PY_CACHE_TAG=$(poetry run python -c 'import sys;print(sys.implementation.cache_tag)')
113+
echo "Building wheel ${CIBW_BUILD} ${{ env.CIBW_BUILD }}"
114+
echo "Building cp: ${{ env.python_cp_version }}"
115+
echo "Building cache_tag: ${PY_CACHE_TAG}"
116+
echo "Building platform_id: ${{ matrix.os.platform_id }}"
102117
poetry run python --version
118+
poetry run python --version | grep ${{ matrix.python-version }}
103119
poetry install --no-root --only=build
104120
cat ./pyproject.toml
105121
poetry run python -m cibuildwheel --output-dir wheelhouse
@@ -115,6 +131,10 @@ jobs:
115131
for file in ./wheelhouse/*.whl; do
116132
echo "Inspecting $file"
117133
poetry run python -m zipfile --list "$file"
134+
echo "Checking if .so is contained in the wheel"
135+
poetry run python -m zipfile --list "$file" | grep \\.so
136+
echo "Checking if the correct python version is contained in the wheel"
137+
poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
118138
done
119139
mkdir -p ./dist
120140
cp wheelhouse/*.whl ./dist/
@@ -137,9 +157,16 @@ jobs:
137157
CIBW_ENVIRONMENT: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.os.macos_version }}.0"
138158
ARCHFLAGS: -arch arm64
139159
BUILD_THREADS: "4"
160+
PYTORCH_MPS_HIGH_WATERMARK_RATIO: "0.0"
161+
CUDA_VISIBLE_DEVICES: "cpu"
140162
run: |
141-
echo "Building wheel ${CIBW_BUILD}"
163+
PY_CACHE_TAG=$(poetry run python -c 'import sys;print(sys.implementation.cache_tag)')
164+
echo "Building wheel ${CIBW_BUILD} ${{ env.CIBW_BUILD }}"
165+
echo "Building cp: ${{ env.python_cp_version }}"
166+
echo "Building cache_tag: ${PY_CACHE_TAG}"
167+
echo "Building platform_id: ${{ matrix.os.platform_id }}"
142168
poetry run python --version
169+
poetry run python --version | grep ${{ matrix.python-version }}
143170
poetry install --no-root --only=build
144171
cat ./pyproject.toml
145172
poetry run python -m cibuildwheel --output-dir wheelhouse
@@ -155,6 +182,10 @@ jobs:
155182
for file in ./wheelhouse/*.whl; do
156183
echo "Inspecting $file"
157184
poetry run python -m zipfile --list "$file"
185+
echo "Checking if .so is contained in the wheel"
186+
poetry run python -m zipfile --list "$file" | grep \\.so
187+
echo "Checking if the correct python version is contained in the wheel"
188+
poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
158189
done
159190
mkdir -p ./dist
160191
cp wheelhouse/*.whl ./dist/
@@ -183,15 +214,23 @@ jobs:
183214
CIBW_BUILD_VERBOSITY: 3
184215
BUILD_THREADS: "8"
185216
run: |
186-
echo "Building wheel ${CIBW_BUILD}"
217+
PY_CACHE_TAG=$(poetry run python -c 'import sys;print(sys.implementation.cache_tag)')
218+
echo "Building cp: ${{ env.python_cp_version }}"
219+
echo "Building cache_tag: ${PY_CACHE_TAG}"
220+
echo "Building platform_id: ${{ matrix.os.platform_id }}"
187221
poetry run python --version
222+
poetry run python --version | grep ${{ matrix.python-version }}
188223
poetry install --no-root --only=build
189224
cat ./pyproject.toml
190225
poetry run python -m cibuildwheel --output-dir ./wheelhouse
191226
ls -l ./wheelhouse
192227
for file in ./wheelhouse/*.whl; do
193228
echo "Inspecting $file"
194229
poetry run python -m zipfile --list "$file"
230+
echo "Checking if .so is contained in the wheel"
231+
poetry run python -m zipfile --list "$file" | grep \\.so
232+
echo "Checking if the correct python version is contained in the wheel"
233+
poetry run python -m zipfile --list "$file" | grep ${PY_CACHE_TAG}
195234
done
196235
mkdir -p ./dist
197236
cp wheelhouse/*.whl ./dist/
@@ -256,9 +295,9 @@ jobs:
256295
257296
- name: publish wheels (dry run)
258297
run: |
259-
poetry publish --dry-run --no-interaction -vvv
298+
poetry publish --skip-existing --dry-run --no-interaction -vvv
260299
261300
- name: publish wheels (on publishing) [for releases only]
262301
if: ${{ startsWith(github.ref, 'refs/tags/') }}
263302
run: |
264-
poetry publish --no-interaction -vvv
303+
poetry publish --skip-existing --no-interaction -vvv

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.12)
1+
cmake_minimum_required(VERSION 3.12..3.26)
22

33
project(docling_parse VERSION 1.0.0 LANGUAGES CXX C)
44
#set(CMAKE_VERBOSE_MAKEFILE off)
@@ -147,7 +147,7 @@ target_link_libraries(parse ${LIB_LINK})
147147
# ***************************
148148

149149
# https://pybind11.readthedocs.io/en/stable/compiling.html
150-
find_package (Python COMPONENTS Interpreter Development)
150+
# https://pybind11.readthedocs.io/en/stable/compiling.html#configuration-variables
151151
find_package(pybind11 CONFIG REQUIRED)
152152

153153
pybind11_add_module(docling_parse "${TOPLEVEL_PREFIX_PATH}/app/pybind_parse.cpp")

build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def run(cmd: List[str], cwd: str="./"):
4141
def build_local(num_threads: int):
4242

4343
print("python prefix: ", sys.exec_prefix)
44+
print("python executable: ", sys.executable)
4445
config_cmd = [
4546
"cmake",
4647
"-B", f"{BUILD_DIR}",
47-
f"-DPython_ROOT_DIR={sys.exec_prefix}",
48-
f"-DPython3_ROOT_DIR={sys.exec_prefix}",
48+
f"-DPYTHON_EXECUTABLE={sys.executable}",
4949
]
5050
config_cmd.extend(get_pybind11_cmake_args())
5151
success = run(config_cmd, cwd=ROOT_DIR)

0 commit comments

Comments
 (0)