Skip to content

Commit 9593cc1

Browse files
mgornythejcfactor
authored andcommitted
Do not install cmake from PyPI when system CMake is available
Replace the unconditional build requirement on `cmake` with one that is added only if no system executable can be found. This ensures that the system CMake version is used when available, and this can be important when system CMake carries downstream patches for the platform. When no CMake executable is found, `cmake` is pulled in via `setup_requires`, and the previous behavior is preserved. Note that in order to accommodate this change, I had to remove the early check for CMAKE_EXE being present. This means that it is now possible to use `setup.py` without having CMake installed, and it will only fail when actually trying to compile the extension. Change-Id: I3bc31206285168952a7b3f98d2c43a3997f95801 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/222207 Reviewed-by: Jared Casey <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 4ae23c8 commit 9593cc1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

pycbc_build_setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ def create_cmake_config(cls, # noqa: C901
213213

214214
class CMakeExtension(Extension):
215215
def __init__(self, name, sourcedir=''):
216-
check_for_cmake()
217216
Extension.__init__(self, name, sources=[])
218217
self.sourcedir = os.path.abspath(sourcedir)
219218

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
requires = [
33
"setuptools>=42",
44
"wheel",
5-
"cmake"
65
]
76
build-backend = "setuptools.build_meta"
87

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
from pycbc_build_setup import (BuildCommand, # nopep8 # isort:skip # noqa: E402
2525
CMakeBuildExt,
2626
CMakeConfigureExt,
27-
CMakeExtension)
27+
CMakeExtension,
28+
CMAKE_EXE)
2829

2930
try:
3031
couchbase_version.gen_version()
@@ -40,6 +41,12 @@
4041
if platform.system() == 'Windows':
4142
package_data = {'couchbase': ['pycbc_core.pyd']}
4243

44+
# request installing cmake from PyPI if no CMake executable was found.
45+
# otherwise, we want to use the system executable.
46+
setup_requires = []
47+
if not CMAKE_EXE:
48+
setup_requires += ["cmake"]
49+
4350
print(f'Python SDK version: {PYCBC_VERSION}')
4451

4552
setup(name='couchbase',
@@ -49,6 +56,7 @@
4956
'build_ext': CMakeBuildExt,
5057
'configure_ext': CMakeConfigureExt},
5158
python_requires='>=3.7',
59+
setup_requires=setup_requires,
5260
packages=find_packages(
5361
include=['acouchbase', 'couchbase', 'txcouchbase', 'couchbase.*', 'acouchbase.*', 'txcouchbase.*'],
5462
exclude=['acouchbase.tests', 'couchbase.tests', 'txcouchbase.tests']),

0 commit comments

Comments
 (0)