Skip to content

Commit

Permalink
fix: validate value before returning library path
Browse files Browse the repository at this point in the history
In CMaker._guess_python_library(), there is a path where python_library
can be set to a file name without a path. For example, this happens
when using a venv in a MinGW envronment on Windows. This gets passed
to CMake via Python_LIBRARY which causes CMake to fail.

To fix it, we validate that the path exists on disk before returning
the value or return None if it does not exist.

Fixes: scikit-build#940
  • Loading branch information
dlech committed Apr 15, 2023
1 parent 84c7e4c commit 586852b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion skbuild/cmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ def _guess_python_library(python_version: str) -> str | None:
python_library = candidate
break

# TODO(opadron): what happens if we don't find a libpython?
if not os.path.exists(python_library):
return None

return python_library

Expand Down

0 comments on commit 586852b

Please sign in to comment.