-
Notifications
You must be signed in to change notification settings - Fork 389
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 Python Auxiliary CLI optional #10786
Conversation
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.
Walkthrough completed. Should be a pretty straightforward PR. I am open to discussion about the CMake variable name if anyone has really strong opinions about it.
@@ -1,15 +1,15 @@ | |||
compilers: | |||
- name: "gcc" | |||
version: "11.4" | |||
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DBUILD_PERFORMANCE_TESTS:BOOL=ON -DVALGRIND_ANALYZE_PERFORMANCE_TESTS:BOOL=ON -DENABLE_PCH:BOOL=OFF | |||
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DBUILD_PERFORMANCE_TESTS:BOOL=ON -DVALGRIND_ANALYZE_PERFORMANCE_TESTS:BOOL=ON -DENABLE_PCH:BOOL=OFF |
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.
Not necessary since it is defaulted OFF, but explicitly turn off the auxiliary Python stuff for Decent CI builds.
collect_performance_results: true | ||
skip_regression: true | ||
s3_upload_bucket: energyplus | ||
|
||
- name: "gcc" | ||
version: "11.4" | ||
build_type: RelWithDebInfo | ||
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF | ||
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF |
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.
Not necessary since it is defaulted OFF, but explicitly turn off the auxiliary Python stuff for Decent CI builds.
@@ -23,7 +23,7 @@ compilers: | |||
- name: "gcc" | |||
version: "11.4" | |||
build_type: RelWithDebInfo | |||
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF | |||
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=OFF -DPython_REQUIRED_VERSION:STRING=3.12.2 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.12.2/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF |
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.
Not necessary since it is defaulted OFF, but explicitly turn off the auxiliary Python stuff for Decent CI builds.
@@ -2,5 +2,5 @@ compilers: | |||
- name: Visual Studio | |||
version: 16 | |||
architecture: Win64 | |||
cmake_extra_flags: -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA% -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DLINK_WITH_PYTHON=ON -DPython_EXECUTABLE:PATH=C:/Users/elee/AppData/Local/Programs/Python/Python312/python.exe | |||
cmake_extra_flags: -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCOMMIT_SHA=%COMMIT_SHA% -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DLINK_WITH_PYTHON=ON -DPYTHON_CLI:BOOL=OFF -DPython_EXECUTABLE:PATH=C:/Users/elee/AppData/Local/Programs/Python/Python312/python.exe |
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.
Not necessary since it is defaulted OFF, but explicitly turn off the auxiliary Python stuff for Decent CI builds.
@@ -70,7 +70,8 @@ jobs: | |||
shell: bash | |||
run: | | |||
cmake -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \ | |||
-DLINK_WITH_PYTHON:BOOL=ON -DPython_REQUIRED_VERSION:STRING=${{ steps.setup-python.outputs.python-version }} \ | |||
-DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=ON \ | |||
-DPython_REQUIRED_VERSION:STRING=${{ steps.setup-python.outputs.python-version }} \ |
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.
Make sure to turn PYTHON_CLI ON when doing release packages.
@@ -184,6 +184,7 @@ endif() | |||
# If LINK_WITH_PYTHON, also request the Development (libs) at the same time, to ensure consistent version between interpreter and Development | |||
# and ask for at least 3.8 (for the PyConfig stuff). | |||
if(LINK_WITH_PYTHON) | |||
option(PYTHON_CLI "Build the Auxiliary CLI to Call Python Utilities" OFF) |
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 option is only exposed to the user once they turn LINK_WITH_PYTHON to ON.
) | ||
if (PYTHON_CLI) |
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.
Split the PythonCopyStandardLibrary.py and the Pip Install with Tcl Fixup stuff into two separate commands. This way we can protect the second one within an IF (PYTHON_CLI) condition.
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 you had enabled LINK_WITH_PYTHON and PYTHON_CLI, and you disable LINK_WITH_PYTHON, this block would still be executed.
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.
Oh, I thought this whole section was wrapped inside a LINK_WITH_PYTHON check.
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 whole section is indeed wrapped inside a LINK_WITH_PYTHON condition up at line 918. This one is fine I think. But I did find a spot just below where I am creating the shortcut lnk file to EPLaunch that needed extra protection. If you confirm that it definitely needs change here, let me know.
@@ -234,7 +234,7 @@ Built on Platform: {} | |||
// bool debugCLI = false; | |||
app.add_flag("--debug-cli", debugCLI, "Print the result of the CLI assignments to the console and exit")->group(""); // Empty group to hide it | |||
|
|||
#if LINK_WITH_PYTHON | |||
#if LINK_WITH_PYTHON && PYTHON_CLI |
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.
Only build out the auxiliary CLI if the new CLI flag is also enabled.
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.
(side note, but shouldn't this be #ifdef ?)
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.
That sounds fine. I changed it to ifdef and retested everything.
@@ -57,7 +57,7 @@ | |||
#include <EnergyPlus/Data/EnergyPlusData.hh> | |||
#include <EnergyPlus/DataAirLoop.hh> | |||
#include <EnergyPlus/DataEnvironment.hh> | |||
//#include <EnergyPlus/DataHeatBalance.hh> | |||
// #include <EnergyPlus/DataHeatBalance.hh> |
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.
Clang format did this not me.
@@ -57,7 +57,7 @@ | |||
#include <EnergyPlus/Coils/CoilCoolingDX.hh> | |||
#include <EnergyPlus/CurveManager.hh> | |||
#include <EnergyPlus/DXCoils.hh> | |||
//#include <EnergyPlus/Data/EnergyPlusData.hh> | |||
// #include <EnergyPlus/Data/EnergyPlusData.hh> |
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.
Clang format did this not me.
src/EnergyPlus/CMakeLists.txt
Outdated
if(PYTHON_CLI) | ||
add_compile_definitions(PYTHON_CLI) | ||
endif() |
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.
I'd nest it inside the above if(LINK_WITH_PYTHON) to be consistent with the options...
This could be a left over from another pass of CMake, and we shouldn't have a definition "PYTHON_CLI" is "LINK_WITH_PYTHON" is off (I did see you test with #if LINK_WITH_PYTHON && PYTHON_CLI
, but this could happen if we forget the LINK_WITH_PYTHON)
test:
CMakeLists.txt
option(LINK_WITH_PYTHON "Link with Python Library for Python Plugin Builds" OFF)
if(LINK_WITH_PYTHON)
option(PYTHON_CLI "Build the Auxiliary CLI to Call Python Utilities" OFF)
endif()
if(LINK_WITH_PYTHON)
message("LINK_WITH_PYTHON")
endif()
if(PYTHON_CLI)
message("PYTHON_CLI")
endif()
$ cmake -DLINK_WITH_PYTHON:BOOL=ON -DPYTHON_CLI:BOOL=ON .
LINK_WITH_PYTHON
PYTHON_CLI
$ cmake -DLINK_WITH_PYTHON:BOOL=OFF
PYTHON_CLI
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 fair. I'll protect the PYTHON_CLI a little better. As for this being leftover from a cmake pass, are you suggesting other changes need to be made here? And also - do you think I should do something other than PYTHON_CLI
? I thought about AUXILIARY_CLI
but it seemed that this was a Python-centric thing. PYTHON_AUXILIARY_CLI
? Maybe I just shouldn't worry about the name...
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.
Meh, all good choices really.
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.
Got it. OK, moved the def to inside the link-with-python flag condition.
) | ||
if (PYTHON_CLI) |
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 you had enabled LINK_WITH_PYTHON and PYTHON_CLI, and you disable LINK_WITH_PYTHON, this block would still be executed.
@@ -234,7 +234,7 @@ Built on Platform: {} | |||
// bool debugCLI = false; | |||
app.add_flag("--debug-cli", debugCLI, "Print the result of the CLI assignments to the console and exit")->group(""); // Empty group to hide it | |||
|
|||
#if LINK_WITH_PYTHON | |||
#if LINK_WITH_PYTHON && PYTHON_CLI |
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.
(side note, but shouldn't this be #ifdef ?)
Here is a suggested CMakeLists.txt based on https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html
The documentation for CMakeDependentOption is kinda gross, let me explain
This loosely translates to:
There's a CACHE INTERNAL variable used to remember the old value. |
That's an interesting trick. I think it's not necessary now that we've protected the couple places we are using it, so I'm not going to add that here unless you feel really strongly about it. Thanks for pointing out the spots to add protection, I am pushing now and think it's ready. |
With 24.2, a new CLI category was added for auxiliary tools. This enabled packaging up EP-Launch with the official EnergyPlus release packages. This is working fine, but in our build rules, it was tied directly to the core LINK_WITH_PYTHON CMake variable. Anyone who wants to build with LINK_WITH_PYTHON will end up now getting a pip install process, which could cause issues if your Python environment is not "ready". This is especially prominent on Mac with brew install complexities around tcl-tk.
This PR adds a second CMake variable, currently called PYTHON_CLI. This is only exposed to the user if they first turn on LINK_WITH_PYTHON. Here are the options:
This PR simply lets plugins work without needing to also have the auxiliary stuff.