Skip to content

Bump CMake minimum version to 3.24 for Python 3.13 compatibility - #243

Closed
justinchuby with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-cmake-versions-for-macos
Closed

Bump CMake minimum version to 3.24 for Python 3.13 compatibility#243
justinchuby with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-cmake-versions-for-macos

Conversation

Copilot AI commented Dec 31, 2025

Copy link
Copy Markdown
Contributor

Building from source fails on Python 3.13 due to CMake version mismatch between main project (3.22) and onnx submodule (3.24).

Changes

  • CMakeLists.txt: Bump cmake_minimum_required from 3.22 to 3.24 to match onnx submodule requirement
  • .github/workflows/build-and-test.yml: Remove obsolete -DCMAKE_POLICY_VERSION_MINIMUM=3.5 workaround

The workaround was added when submodules had ancient CMake requirements (<3.5). Current submodule versions require modern CMake (protobuf: 3.16+, onnx: 3.24), making the workaround obsolete.

Original prompt

This section details on the original issue you should resolve

<issue_title>Build failure on Python 3.13 (macOS) due to outdated CMake minimum versions in submodules</issue_title>
<issue_description>#### Description
Attempting to install onnxoptimizer==0.3.13 via uv pip install onnxoptimizer on macOS with Python 3.13 fails during the source build process. This occurs because there are no pre-built wheels available for Python 3.13 on PyPI, forcing a compile from source. The build errors out due to CMake compatibility issues in the bundled submodules (third_party/protobuf and third_party/onnx), which declare deprecated minimum CMake versions that are no longer supported by modern CMake (e.g., 3.20+ installed via Homebrew).

Specifically:

  • third_party/protobuf/cmake/CMakeLists.txt uses cmake_minimum_required with compatibility for <3.10, triggering a deprecation warning.
  • third_party/onnx/CMakeLists.txt uses cmake_minimum_required with compatibility for <3.5, causing a fatal error.

Additionally, there are non-fatal deprecation warnings related to setup.cfg (e.g., dash-separated 'license-file' key) and a shutil.which deprecation in the build script.

This package hasn't seen updates since April 2023, which may contribute to these compatibility issues with newer Python and build tools.

Steps to Reproduce

  1. On macOS, ensure Python 3.13 is installed (e.g., via Homebrew: brew install python@3.13).
  2. Create a virtual environment: uv venv --python 3.13 .venv && source .venv/bin/activate.
  3. Run uv pip install onnxoptimizer==0.3.13.

Environment

  • OS: macOS 15.5 (24F74)
  • Python: 3.13.3
  • CMake: 3.20.1 (or similar recent version)
  • Installer: uv (though similar issues occur with pip)

Error Log (Relevant Excerpt)

CMake Deprecation Warning at third_party/protobuf/cmake/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

CMake Error at third_party/onnx/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

subprocess.CalledProcessError: Command '['/opt/homebrew/bin/cmake', ...]' returned non-zero exit status 1.

Full traceback includes additional details like the setuptools deprecation for 'license-file' and a gitfile format warning in the uv cache, but the root cause is the CMake configuration failure.

Attempted Workarounds

  • Setting export CMAKE_ARGS="-DCMAKE_POLICY_VERSION_MINIMUM=3.5" (or 3.10) before install does not resolve the issue.
  • Downgrading to Python 3.11 succeeds, as pre-built wheels are available for that version.
    </issue_description>

<agent_instructions>Check if you need to update the versions in cmakelists </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@andife @antimora Thank you for your feedback. We are working on a release.

I created a new branch for python 3.13 (#205).
cibuildwheel was able to create a macos whl for 3.13 (could be downloaded at https://github.com/onnx/optimizer/actions/runs/16362399557/artifacts/3560685281 )

@take-cheeze </comment_new>
<comment_new>@take-cheeze
I've experienced this kind of isseu but made workaround with following env var:

CIBW_ENVIRONMENT: CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5"

CMAKE_ARGS="... -DCMAKE_POLICY_VERSION_MINIMUM=3.5"</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 31, 2025
Copilot AI and others added 2 commits December 31, 2025 07:25
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build failure for onnxoptimizer on macOS with Python 3.13 Bump CMake minimum version to 3.24 for Python 3.13 compatibility Dec 31, 2025
Copilot AI requested a review from justinchuby December 31, 2025 07:29
@sonarqubecloud

Copy link
Copy Markdown

@justinchuby
justinchuby requested a review from andife December 31, 2025 20:42
@justinchuby
justinchuby marked this pull request as ready for review December 31, 2025 20:42
@justinchuby
justinchuby requested review from a team as code owners December 31, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure on Python 3.13 (macOS) due to outdated CMake minimum versions in submodules

3 participants