From 9d2d6adc3550de1a52428e5289a9a0136f1b24b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 10 Feb 2025 20:06:51 +0100 Subject: [PATCH] Support using system CMake and Ninja Add the dependencies on PyPI `cmake` and `ninja` packages only if the respective tool cannot be found, in order to support using system executables. This avoids unnecessary dependencies on third-party binary packages from PyPI, and improves portability be enabling use of downstream patching. --- pyproject.toml | 2 -- setup.py | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ed97244c2..4d3bb6749 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,5 @@ [build-system] requires = [ "setuptools", - "cmake>=3.12", - "ninja>=1.10" ] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index adfd89af7..3eb0d25a4 100644 --- a/setup.py +++ b/setup.py @@ -135,6 +135,12 @@ def build_extension(self, ext): with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() +setup_requires = [] +if which("cmake") is None: + setup_requires += ["cmake>=3.12"] +if which("ninja") is None: + setup_requires += ["ninja>=1.10"] + setup( name="PyMatching", version=version['__version__'], @@ -153,6 +159,7 @@ def build_extension(self, ext): 'console_scripts': ['pymatching=pymatching._cli_argv:cli_argv'], }, python_requires=">=3.7", + setup_requires=setup_requires, install_requires=['scipy', 'numpy==1.*', 'networkx', 'matplotlib'], # Needed on Windows to avoid the default `build` colliding with Bazel's `BUILD`. options={'build': {'build_base': 'python_build_stim'}},