Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitef9443d

Browse 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 parent43c1105 commitef9443d

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

‎MANIFEST.in

Lines 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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
fromsetuptoolsimportbuild_metaas_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+
defget_requires_for_build_wheel(config_settings=None):
9+
frompackagingimportversion
10+
fromskbuild.exceptionsimportSKBuildError
11+
fromskbuild.cmakerimportget_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+
ifversion.parse(get_cmake_version().split("-")[0])<version.parse(min_version):
19+
packages.append(f'cmake>={min_version}')
20+
exceptSKBuildError:
21+
packages.append(f'cmake>={min_version}')
22+
23+
returnpackages

‎pyproject.toml

Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp