From fc9ff946b72c271d52c5ae08f3036905890de9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 21 Jan 2025 23:39:19 +0100 Subject: [PATCH] use cmake from PyPI only when system executable is not available (#7514) Rather than pulling `cmake` from PyPI unconditionally, add it to build dependencies only if the system `cmake` executable cannot be found. This eliminates an unnecessary dependency on systems featuring CMake, and ensures that whenever possible, a downstream patched CMake version is used that is more compatible with the system in question. --- src/api/python/pyproject.toml | 2 +- src/api/python/setup.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/python/pyproject.toml b/src/api/python/pyproject.toml index ead5d1b2d..380744c87 100644 --- a/src/api/python/pyproject.toml +++ b/src/api/python/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=70", "cmake"] +requires = ["setuptools>=70"] build-backend = "setuptools.build_meta" diff --git a/src/api/python/setup.py b/src/api/python/setup.py index 9590d78ce..8cd5afdaa 100644 --- a/src/api/python/setup.py +++ b/src/api/python/setup.py @@ -88,6 +88,11 @@ else: LIBRARY_FILE = "libz3.so" EXECUTABLE_FILE = "z3" +# check if cmake is available, and pull it in via PyPI if necessary +SETUP_REQUIRES = [] +if not shutil.which("cmake"): + SETUP_REQUIRES += ["cmake"] + def rmtree(tree): if os.path.exists(tree): shutil.rmtree(tree, ignore_errors=False) @@ -327,6 +332,7 @@ setup( license='MIT License', keywords=['z3', 'smt', 'sat', 'prover', 'theorem'], packages=['z3'], + setup_requires = SETUP_REQUIRES, install_requires = ["importlib-resources; python_version < '3.9'"], include_package_data=True, package_data={