-
Notifications
You must be signed in to change notification settings - Fork 700
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
Make it possible to override PYTHON_VERSION when invoking cmake #1442
Conversation
21e1e17
to
89f31ba
Compare
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) | ||
if (NOT NO_PYVERBS AND Python_VERSION_MAJOR EQUAL 3) | ||
FIND_PACKAGE(PythonInterp REQUIRED) | ||
FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite different now, previously we only required the development packages if cmake was enabled, now it needs it always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this discards the preference to use python3, that doesn't seem right. If PYTHON_VERSION is not specified it should continue to do the automatic detection logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_package will not fail if PythonLibs is not found.
https://cmake.org/cmake/help/v3.11/command/find_package.html
but PYTHONLIBS_FOUND wont be set so i check for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PythonInterp already prefers 3 over 2. No need to make this explicit
elseif (${CMAKE_VERSION} VERSION_GREATER "3.12") | ||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) | ||
FIND_PACKAGE(Python 3 REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development) | ||
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both legs if this if should be setting this, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PythonInterp sets PYTHON_EXECUTABLE
https://cmake.org/cmake/help/v3.11/module/FindPythonInterp.html
FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT) | ||
elseif (${CMAKE_VERSION} VERSION_GREATER "3.12") | ||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) | ||
FIND_PACKAGE(Python 3 REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What fails cmake if cython is enabled and we don't find Development?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If find_package python find developer libs Python_Development_FOUND variable is set so i check for that
https://cmake.org/cmake/help/v3.13/module/FindPython.html#result-variables
Updated commit. Now should always prefer python3 |
CMakeLists.txt
Outdated
if (NOT NO_PYVERBS AND Python_VERSION_MAJOR EQUAL 3) | ||
FIND_PACKAGE(PythonInterp 3 REQUIRED) | ||
FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT) | ||
elseif (${CMAKE_VERSION} VERSION_GREATER "3.12") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing to handle 3.12:
VERSION_GREATER_EQUAL
Make it possible to override PYTHON_VERSION when invoking cmake. Signed-off-by: Maksym Chukhrii <mchukhrii@nvidia.com>
Currently cmake script will override PYTHON_EXECUTABLE if specified in command line.
This patch should fix it. Now if PYTHON_EXECUTABLE is not empty it will be used and python version discovery will not run.