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: add CMake as a build requirement only if required #1031

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include README.md
include find_version.py
include setup.py
include pyproject.toml
include _build_backend/backend.py
recursive-include cv2 *
recursive-include docker *
recursive-include opencv *
Expand Down
23 changes: 23 additions & 0 deletions _build_backend/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from setuptools import build_meta as _orig

prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
build_wheel = _orig.build_wheel
build_sdist = _orig.build_sdist
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist

def get_requires_for_build_wheel(config_settings=None):
from packaging import version
from skbuild.exceptions import SKBuildError
from skbuild.cmaker import get_cmake_version
packages = _orig.get_requires_for_build_wheel(config_settings)
# check if system cmake can be used if present
# if not, append cmake PyPI distribution to required packages
# scikit-build>=0.18 itself requires cmake 3.5+
min_version = "3.5"
try:
if version.parse(get_cmake_version().split("-")[0]) < version.parse(min_version):
packages.append(f'cmake>={min_version}')
except SKBuildError:
packages.append(f'cmake>={min_version}')

return packages
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[build-system]
requires = [
"cmake>=3.1",
"numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.17.0; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.17.5; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.19.3; python_version<'3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'",
"numpy==1.21.0; python_version<'3.9' and sys_platform == 'darwin' and platform_machine == 'arm64'",
"numpy>=2.0.0; python_version>='3.9'",
"packaging",
"pip",
"scikit-build>=0.14.0",
"setuptools==59.2.0",
]
# use a custom backend to manage CMake check / installation
# see https://scikit-build.readthedocs.io/en/latest/usage.html#adding-cmake-as-building-requirement-only-if-not-installed-or-too-low-a-version
build-backend = "backend"
backend-path = ["_build_backend"]
Loading