Skip to content

Commit

Permalink
Taking the auxiliary interface away from mac for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Sep 18, 2024
1 parent f5fa4bb commit 6fd1590
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Releases
name: Linux Releases

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_mac.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Releases
name: Mac Releases

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Releases
name: Windows Releases

on:
push:
Expand Down
5 changes: 3 additions & 2 deletions cmake/PythonCopyStandardLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# this script must be called with two args:
# 1 - the path to the EnergyPlus executable in the install-tree, which is used to determine where to copy the library
# since this is in the install-tree, you'll need to use a cmake generator expression
# 2 - name of the folder to create to store the copied in python standard library, usually python_library
# 2 - name of the folder to create to store the copied in python standard library, usually python_lib
import ctypes
import os
import platform
Expand Down Expand Up @@ -122,7 +122,8 @@ def find_libs(dir_path):
python_root_dir = os.path.dirname(standard_lib_dir)
tcl_dir = os.path.join(python_root_dir, 'tcl')
shutil.copytree(tcl_dir, target_dir, dirs_exist_ok=True)

# TODO: Need to do this on Mac as well, see the bottom of cmake/PythonFixUpOnMac.cmake for more info

# then I'm going to try to clean up any __pycache__ folders in the target dir to reduce installer size
for root, dirs, _ in os.walk(target_dir):
for this_dir in dirs:
Expand Down
17 changes: 17 additions & 0 deletions cmake/PythonFixUpOnMac.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ foreach(PREREQ IN LISTS PREREQUISITES)
execute_process(COMMAND "install_name_tool" -change "${PREREQ}" "@loader_path/${LIB_INT_FILENAME}" "${LOCAL_PYTHON_LIBRARY}")
endif()
endforeach()

##############3
# we need to look into the tkinter binary's runtime dependencies, copy over the tcl and tk dylibs, update them with install_name_tool, and make sure they all get signed, like this:

# libtcl
# cp /opt/homebrew/opt/tcl-tk/lib/libtcl8.6.dylib /path/to/python_lib/lib-dynload/
# install_name_tool -change "/opt/homebrew/opt/tcl-tk/lib/libtcl8.6.dylib" "@loader_path/libtcl8.6.dylib" /path/to/python_lib/lib-dynload/_tkinter.cpython-312-darwin.so

# Do the same for libtk
# cp /opt/homebrew/opt/tcl-tk/lib/libtk8.6.dylib /path/to/python_lib/lib-dynload/
# install_name_tool -change "/opt/homebrew/opt/tcl-tk/lib/libtk8.6.dylib" "@loader_path/libtk8.6.dylib" /path/to/python_lib/lib-dynload/_tkinter.cpython-312-darwin.so

# Resign _tkinter
# codesign -vvvv -s "Developer ID Application: National ..." -f --timestamp -i "org.nrel.EnergyPlus" -o runtime /path/to/python_lib/lib-dynload/_tkinter.cpython-312-darwin.so
# codesign -vvvv -s "Developer ID Application: National ..." -f --timestamp -i "org.nrel.EnergyPlus" -o runtime /path/to/python_lib/lib-dynload/libtcl8.6.dylib
# codesign -vvvv -s "Developer ID Application: National ..." -f --timestamp -i "org.nrel.EnergyPlus" -o runtime /path/to/python_lib/lib-dynload/libtk8.6.dylib
##############3
7 changes: 6 additions & 1 deletion src/EnergyPlus/CommandLineInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ Built on Platform: {}
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 __APPLE__
// for now on Apple we are not providing the command line interface to EP-Launch due to packaging issues
// once that is fixed, this __APPLE__ block will be removed and we'll just have this on all platforms
#else
auto *auxiliaryToolsSubcommand = app.add_subcommand("auxiliary", "Run Auxiliary Python Tools");
auxiliaryToolsSubcommand->require_subcommand(); // should default to requiring 1 or more additional args?

Expand Down Expand Up @@ -278,10 +282,11 @@ sys.argv.append("energyplus")
from eplaunch.tk_runner import main_gui
main_gui()
)python";
std::cout << "Trying to execute this python snippet: " << std::endl << cmd << std::endl;
// std::cout << "Trying to execute this python snippet: " << std::endl << cmd << std::endl;
engine.exec(cmd);
exit(0);
});
#endif
#endif

app.footer("Example: energyplus -w weather.epw -r input.idf");
Expand Down

0 comments on commit 6fd1590

Please sign in to comment.