Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ef9443d

Browse filesBrowse files
committed
fix: add CMake as a build requirement only if required
The PyPI distribution of CMake shall not be listed as an unconditional build requirement. It shall only be added as a build requirement if not installed or too low a version. This helps building from sources on platforms where no wheels are available for CMake but the system already provides a recent enough CMake version. In case of error checking the version, the backend falls back to using the PyPI distribution of CMake.
1 parent 43c1105 commit ef9443d
Copy full SHA for ef9443d

File tree

Expand file treeCollapse file tree

3 files changed

+29
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+29
-1
lines changed

‎MANIFEST.in

Copy file name to clipboardExpand all lines: MANIFEST.in
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include README.md
44
include find_version.py
55
include setup.py
66
include pyproject.toml
7+
include _build_backend/backend.py
78
recursive-include cv2 *
89
recursive-include docker *
910
recursive-include opencv *

‎_build_backend/backend.py

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from setuptools import build_meta as _orig
2+
3+
prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
4+
build_wheel = _orig.build_wheel
5+
build_sdist = _orig.build_sdist
6+
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist
7+
8+
def get_requires_for_build_wheel(config_settings=None):
9+
from packaging import version
10+
from skbuild.exceptions import SKBuildError
11+
from skbuild.cmaker import get_cmake_version
12+
packages = _orig.get_requires_for_build_wheel(config_settings)
13+
# check if system cmake can be used if present
14+
# if not, append cmake PyPI distribution to required packages
15+
# scikit-build>=0.18 itself requires cmake 3.5+
16+
min_version = "3.5"
17+
try:
18+
if version.parse(get_cmake_version().split("-")[0]) < version.parse(min_version):
19+
packages.append(f'cmake>={min_version}')
20+
except SKBuildError:
21+
packages.append(f'cmake>={min_version}')
22+
23+
return packages

‎pyproject.toml

Copy file name to clipboard
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
[build-system]
22
requires = [
3-
"cmake>=3.1",
43
"numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
54
"numpy==1.17.0; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
65
"numpy==1.17.5; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
76
"numpy==1.19.3; python_version<'3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'",
87
"numpy==1.21.0; python_version<'3.9' and sys_platform == 'darwin' and platform_machine == 'arm64'",
98
"numpy>=2.0.0; python_version>='3.9'",
9+
"packaging",
1010
"pip",
1111
"scikit-build>=0.14.0",
1212
"setuptools==59.2.0",
1313
]
14+
# use a custom backend to manage CMake check / installation
15+
# see https://scikit-build.readthedocs.io/en/latest/usage.html#adding-cmake-as-building-requirement-only-if-not-installed-or-too-low-a-version
16+
build-backend = "backend"
17+
backend-path = ["_build_backend"]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.