Skip to content

Commit

Permalink
fix: validate value before returning library path (#942)
Browse files Browse the repository at this point in the history
* fix: validate value before returning library path

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: #940

* Update cmaker.py

* Update cmaker.py

---------

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
  • Loading branch information
dlech and henryiii authored Apr 16, 2023
1 parent 84c7e4c commit 3245109
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions skbuild/cmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,7 @@ def _guess_python_library(python_version: str) -> str | None:
python_library = candidate
break

# TODO(opadron): what happens if we don't find a libpython?

return python_library
return python_library if python_library and os.path.exists(python_library) else None

@staticmethod
def check_for_bad_installs() -> None:
Expand Down

0 comments on commit 3245109

Please sign in to comment.