Skip to content

Commit fc33569

Browse files
python dependencies message
1 parent 96401dc commit fc33569

5 files changed

Lines changed: 90 additions & 6 deletions

File tree

kratos.gid/exec/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"configurations": [
33
{
44
"name": "Launch via pip",
5-
"script": "global_pip"
5+
"script": "pip"
66
},
77
{
88
"name": "Launch via pip with local packages",

kratos.gid/exec/pip.unix.bat

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# OutputFile: "$2/$1.info"
3+
# ErrorFile: "$2/$1.err"
4+
#delete previous result file
5+
rm -f "$2/$1*.post.bin"
6+
rm -f "$2/$1*.post.res"
7+
rm -f "$2/$1*.post.msh"
8+
rm -f "$2/$1.info"
9+
rm -f "$2/$1.err"
10+
rm -f "$2/$1.flavia.dat"
11+
12+
# include .bashrc if it exists
13+
if [ -f "$HOME/.bashrc" ]; then
14+
. "$HOME/.bashrc"
15+
fi
16+
17+
18+
19+
# gid redefines LD_LIBRARY_PATH to its own libs directory
20+
# and maintains OLD_LD_LIBRARY_PATH with previous settings
21+
# therefore, we use the OLD_LD_LIBRARY_PATH and prepend the path to the kratos libs
22+
if [ "$OLD_LD_LIBRARY_PATH" != "" ]; then
23+
export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$OLD_LD_LIBRARY_PATH
24+
else
25+
# do not add the ':'
26+
export LD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs"
27+
fi
28+
29+
# Prevents the PYTHONHOME error from happening and isolate possible python repacks present
30+
# in the system and interfeering with runkratos
31+
# export PYTHONHOME="$3/exec/Kratos"
32+
export PYTHONPATH="$3/exec/Kratos/python34.zip":"$3/exec/Kratos":$PYTHONPATH
33+
34+
35+
# if mac
36+
KERNEL=`uname -s`
37+
if [ $KERNEL = "Darwin" ]; then
38+
KERNEL_NAME="macosx"
39+
export DYLD_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$DYLD_LIBRARY_PATH
40+
export DYLD_FALLBACK_LIBRARY_PATH="$3/exec/Kratos":"$3/exec/Kratos/libs":$DYLD_FALLBACK_LIBRARY_PATH
41+
export PYTHONPATH="$3/exec/Kratos/Lib":"$3/exec/Kratos/Lib/lib-dynload/":$PYTHONPATH
42+
export PYTHONHOME="$3/exec/Kratos"
43+
else
44+
KERNEL_NAME="linux"
45+
fi
46+
47+
# Run Python using the script MainKratos.py
48+
python3 MainKratos.py > "$2/$1.info" 2> "$2/$1.err"

kratos.gid/exec/pip.win.bat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
REM @ECHO OFF
2+
REM Identification for arguments
3+
REM basename = %1
4+
REM Project directory = %2
5+
REM Problem directory = %3
6+
7+
REM OutputFile: "%2\%1.info"
8+
REM ErrorFile: "%2\%1.err"
9+
10+
REM Remove previous calculation files and results
11+
DEL "%2\%1.info"
12+
DEL "%2\%1.err"
13+
DEL "%2\%1*.post.bin"
14+
DEL "%2\%1*.post.res"
15+
DEL "%2\%1*.post.msh"
16+
17+
@REM Calculate!
18+
python MainKratos.py > "%2\\%1.info" 2> "%2\\%1.err"

kratos.gid/scripts/Launch.tcl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ proc Kratos::GetMissingPipPackages { } {
6464

6565

6666
proc Kratos::CheckDependencies { } {
67-
if {[pythonVersion] <= 0} {
67+
if { [GidUtils::IsTkDisabled] } {
68+
return 0
69+
}
70+
set py_version [Kratos::pythonVersion]
71+
if {$py_version <= 0} {
6872
set msgBox_type yesno
6973
# -do_not_ask_again 1 -do_not_ask_again_key "kratos_install_python"
7074
set reply [tk_messageBox -icon warning -type $msgBox_type -parent .gid \
@@ -76,8 +80,20 @@ proc Kratos::CheckDependencies { } {
7680
if {[string equal $reply "cancel"]} {
7781

7882
}
79-
} else {
83+
}
84+
set missing_packages [Kratos::GetMissingPipPackages]
85+
if {[llength $missing_packages] > 0} {
86+
set msgBox_type yesno
87+
# -do_not_ask_again 1 -do_not_ask_again_key "kratos_install_python"
88+
set reply [tk_messageBox -icon warning -type $msgBox_type -parent .gid \
89+
-message "Python $py_version is installed, but there are some missing packages. Do you want Kratos to install them? \n\nPackages to be installed: \n$missing_packages" \
90+
-title [_ "Missing python packages"]]
91+
if {[string equal $reply "yes"]} {
92+
Kratos::InstallAllPythonDependencies
93+
}
94+
if {[string equal $reply "cancel"]} {
8095

96+
}
8197
}
8298
}
8399

@@ -87,13 +103,13 @@ proc Kratos::GetLaunchConfigurationFile { } {
87103
return [list $new_dir $file]
88104
}
89105

90-
proc Kratos::LoadLaunchModes { } {
106+
proc Kratos::LoadLaunchModes { {force 0} } {
91107
# Get location of launch config script
92108
lassign [Kratos::GetLaunchConfigurationFile] new_dir file
93109

94110
# If it does not exist, copy it from exec
95111
if {[file exists $new_dir] == 0} {file mkdir $new_dir}
96-
if {[file exists $file] == 0} {
112+
if {[file exists $file] == 0 || $force} {
97113
::GidUtils::SetWarnLine "Loading launch mode"
98114
set source [file join $::Kratos::kratos_private(Path) exec launch.json]
99115
file copy -force $source $file

kratos.gid/scripts/Menus.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ proc Kratos::ChangeMenus { } {
151151
if {[GidUtils::VersionCmp "14.1.4d"] <0 } { set cmd [list ChangeVariables kratos_preferences] } {set cmd [list PreferencesWindow kratos_preferences]}
152152
GiDMenu::InsertOption "Kratos" [list "Kratos preferences" ] [incr pos] PRE $cmd "" "" replace =
153153
GiDMenu::InsertOption "Kratos" [list "View current log" ] [incr pos] PREPOST [list Kratos::ViewLog] "" "" replace =
154-
GiDMenu::InsertOption "Kratos" [list "Install python and dependencies" ] [incr pos] PREPOST [list Kratos::CheckDependencies] "" "" replace =
154+
GiDMenu::InsertOption "Kratos" [list "Install python and dependencies" ] [incr pos] PREPOST [list Kratos::InstallAllPythonDependencies] "" "" replace =
155+
GiDMenu::InsertOption "Kratos" [list "Refresh launch configurations" ] [incr pos] PREPOST [list Kratos::LoadLaunchModes 1] "" "" replace =
156+
GiDMenu::InsertOption "Kratos" [list "---"] [incr pos] PRE "" "" "" replace =
155157
GiDMenu::InsertOption "Kratos" [list "About Kratos" ] [incr pos] PREPOST [list Kratos::About] "" "" replace =
156158
GidChangeDataLabel "Data units" ""
157159
GidChangeDataLabel "Interval" ""

0 commit comments

Comments
 (0)