Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking cmake is in the system path for windows #64

Merged
merged 4 commits into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,43 @@ def build_extensions(self):
raise RuntimeError("Cython is required to generate C++ code")


def check_cmake_in_path():
try:
result = subprocess.run(
["cmake", "--version"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
if result.returncode == 0:
# CMake is in the system path
return True, result.stdout.strip()
else:
# CMake is not in the system path
return False, None
except FileNotFoundError:
# CMake command not found
return False, None


if os.name == "nt": # Check if the OS is Windows
# Check if CMake is in the system path
cmake_found, cmake_version = check_cmake_in_path()

if cmake_found:
print(
f"CMake is in the system path. Version: \
{cmake_version}"
)
else:
raise SystemError(
"CMake is not found in the \
system path. Make sure CMake \
is installed and in the system \
path."
)


# Workaround for `distutils.spawn` problem on Windows python < 3.9
# See details: [bpo-39763: distutils.spawn now uses subprocess (GH-18743)]
# (https://github.com/python/cpython/commit/1ec63b62035e73111e204a0e03b83503e1c58f2e)
Expand Down
Loading