Skip to content

Add cmake dependency only when system cmake is not available (backend version) #6643

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

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Jan 17, 2025

Description

Instead of unconditionally pulling cmake PyPI package in, check whether cmake is available first and add the dependency only when it is not available. This is the same approach as used by the scikit-build-core package, and it improves portability, especially given that CMake frequently requires downstream patching to work.

In this version of the patch, I've created a minimal PEP517 build backend that inherits the functions provided by setuptools, and adds the CMake dependency when necessary. This avoids using deprecated setuptools setup_requires argument, and it avoids adding CMake dependency when building source distributions.

Motivation and Context

Same as #6642, except using PEP517 backend instead of deprecated setup_requires.

@justinchuby
Copy link
Member

Thank you! Do you expect backend.py to remain stable, or do you expect that it will need to evolve with setuptools etc?

@mgorny
Copy link
Contributor Author

mgorny commented Jan 19, 2025

Thank you! Do you expect backend.py to remain stable, or do you expect that it will need to evolve with setuptools etc?

The backend is standardized per PEP 517 (and followup PEPs), so setuptools can't really change the API here. The only potential changes in the future might be related to new PEPs adding additional functions — but these would be entirely optional.

@justinchuby justinchuby added the topic: build Issues related to ONNX builds and packages label Jan 19, 2025
@justinchuby
Copy link
Member

When you get a chance, could you also signoff the commits following https://github.com/onnx/onnx/pull/6643/checks?check_run_id=35781036009 ? Thanks!

@mgorny
Copy link
Contributor Author

mgorny commented Jan 19, 2025

When you get a chance, could you also signoff the commits following https://github.com/onnx/onnx/pull/6643/checks?check_run_id=35781036009 ? Thanks!

Yeah, just noticed I didn't do that. Signoff will be there with the update.

Copy link

codecov bot commented Jan 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.46%. Comparing base (8275472) to head (ec4b0d0).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6643   +/-   ##
=======================================
  Coverage   57.46%   57.46%           
=======================================
  Files         507      507           
  Lines       31584    31584           
  Branches     3046     3046           
=======================================
  Hits        18151    18151           
  Misses      12607    12607           
  Partials      826      826           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Instead of unconditionally pulling `cmake` PyPI package in, check
whether `cmake` is available first and add the dependency only when
it is not available.  This is the same approach as used
by the `scikit-build-core` package, and it improves portability,
especially given that CMake frequently requires downstream patching
to work.

In this version of the patch, I've created a minimal PEP517 build
backend that inherits the functions provided by setuptools, and adds
the CMake dependency when necessary.  This avoids using deprecated
setuptools `setup_requires` argument, and it avoids adding CMake
dependency when building source distributions.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
@mgorny
Copy link
Contributor Author

mgorny commented Jan 19, 2025

Updated. Added an explanatory docstring, and fixed ruff errors.

@justinchuby justinchuby added the run release CIs Use this label to trigger release tests in CI label Jan 19, 2025
@justinchuby justinchuby temporarily deployed to testpypi_onnxweekly January 19, 2025 18:44 — with GitHub Actions Inactive
@justinchuby justinchuby added this pull request to the merge queue Jan 20, 2025
Merged via the queue into onnx:main with commit e194287 Jan 20, 2025
76 checks passed
@mgorny mgorny deleted the sys-cmake-v2 branch January 20, 2025 04:38
@mgorny
Copy link
Contributor Author

mgorny commented Jan 20, 2025

Thank you!

andife pushed a commit that referenced this pull request Jan 25, 2025
… version) (#6643)

### Description
Instead of unconditionally pulling `cmake` PyPI package in, check
whether `cmake` is available first and add the dependency only when it
is not available. This is the same approach as used by the
`scikit-build-core` package, and it improves portability, especially
given that CMake frequently requires downstream patching to work.

In this version of the patch, I've created a minimal PEP517 build
backend that inherits the functions provided by setuptools, and adds the
CMake dependency when necessary. This avoids using deprecated setuptools
`setup_requires` argument, and it avoids adding CMake dependency when
building source distributions.

### Motivation and Context
Same as #6642, except using PEP517 backend instead of deprecated
`setup_requires`.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Andreas Fehlner <fehlner@arcor.de>
seungwoo-ji-03 pushed a commit to seungwoo-ji-03/onnx that referenced this pull request Feb 17, 2025
… version) (onnx#6643)

### Description
Instead of unconditionally pulling `cmake` PyPI package in, check
whether `cmake` is available first and add the dependency only when it
is not available. This is the same approach as used by the
`scikit-build-core` package, and it improves portability, especially
given that CMake frequently requires downstream patching to work.

In this version of the patch, I've created a minimal PEP517 build
backend that inherits the functions provided by setuptools, and adds the
CMake dependency when necessary. This avoids using deprecated setuptools
`setup_requires` argument, and it avoids adding CMake dependency when
building source distributions.

### Motivation and Context
Same as onnx#6642, except using PEP517 backend instead of deprecated
`setup_requires`.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: seungwoo-ji <seungwoo.ji@nuvilab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run release CIs Use this label to trigger release tests in CI topic: build Issues related to ONNX builds and packages
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants