@@ -39,7 +39,25 @@ echo "Julia 1.10 binary path: $julia_path"
39
39
40
40
# Get current conda environment name
41
41
current_env=$( conda info --envs | grep ' \*' | awk ' {print $1}' )
42
- echo " Current conda environment: $current_env "
42
+
43
+ # Ask the user to confirm RMS is being installed in the correct
44
+ # conda environemnt. Skip if this is run under CI.
45
+ if [ " $RMS_MODE " != " CI" ]; then
46
+ echo " Please confirm that you want to install RMS into the current conda environment: '$current_env '"
47
+ echo " If this is not correct, abort and activate the correct environment before rerunning."
48
+ read -p " Proceed with installation in '$current_env '? (y/N): " confirm
49
+ case " $confirm " in
50
+ [yY][eE][sS]|[yY])
51
+ echo " ✅ Proceeding with installation in '$current_env '"
52
+ ;;
53
+ * )
54
+ echo " ❌ Aborted. Please activate the correct conda environment and try again."
55
+ exit 1
56
+ ;;
57
+ esac
58
+ else
59
+ echo " Current conda environment: $current_env "
60
+ fi
43
61
44
62
# Set environment variables for the current environment, for future uses
45
63
# https://juliapy.github.io/PythonCall.jl/stable/pythoncall/#If-you-already-have-Python-and-required-Python-packages-installed
@@ -89,28 +107,84 @@ if [ "$RMS_MODE" = "dev" ]; then
89
107
echo " Using local RMS path: $RMS_PATH "
90
108
fi
91
109
92
- if [ " $RMS_MODE " = " standard" ]; then
110
+ # Initialize the Julia environment from Python using juliacall
111
+ python << EOF
112
+ import sys
113
+ try:
114
+ from juliacall import Main
115
+ Main.seval('println("Active Julia environment: ", Base.active_project())')
116
+ Main.seval('println("Julia load path: ", Base.load_path())')
117
+ Main.seval('using Pkg')
118
+ Main.seval('Pkg.status()')
119
+ except Exception as e:
120
+ print("❌ Error while initialize Julia environment:")
121
+ print(e)
122
+ sys.exit(1)
123
+ EOF
124
+
125
+ # Install RMS
126
+ if [ " $RMS_MODE " = " standard" ] || [ " $RMS_MODE " = " CI" ]; then
93
127
echo " Installing RMS from branch: $RMS_BRANCH "
94
128
julia << EOF || echo "RMS standard install error - continuing anyway ¯\\ _(ツ)_/¯"
95
129
using Pkg
96
130
Pkg.activate(ENV["PYTHON_JULIAPKG_PROJECT"])
97
131
Pkg.add(Pkg.PackageSpec(name="ReactionMechanismSimulator", url="https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git", rev="$RMS_BRANCH "))
98
132
Pkg.instantiate()
99
- using ReactionMechanismSimulator
133
+ try
134
+ @info "Loading RMS"
135
+ using ReactionMechanismSimulator
136
+ @info "RMS loaded successfully!"
137
+ catch err
138
+ @error "Failed to load RMS" exception=err
139
+ Base.show_backtrace(stderr, catch_backtrace())
140
+ exit(1)
141
+ end
100
142
EOF
101
143
elif [ " $RMS_MODE " = " dev" ]; then
102
144
echo " Installing RMS in developer mode from path: $RMS_PATH "
103
145
julia << EOF || echo "RMS developer install error - continuing anyway ¯\\ _(ツ)_/¯"
104
146
using Pkg
147
+ println(ENV["PYTHON_JULIAPKG_PROJECT"])
105
148
Pkg.activate(ENV["PYTHON_JULIAPKG_PROJECT"])
106
149
Pkg.develop(path="$RMS_PATH ")
107
150
Pkg.instantiate()
108
- using ReactionMechanismSimulator
151
+ try
152
+ @info "Loading RMS"
153
+ using ReactionMechanismSimulator
154
+ @info "RMS loaded successfully!"
155
+ catch err
156
+ @error "Failed to load RMS" exception=err
157
+ Base.show_backtrace(stderr, catch_backtrace())
158
+ exit(1)
159
+ end
109
160
EOF
110
161
else
111
162
echo " Unknown RMS_MODE: $RMS_MODE . Must be either 'standard' or 'dev'."
112
163
exit 1
113
164
fi
114
165
166
+ julia_status=$?
167
+ if [ $julia_status -ne 0 ]; then
168
+ echo " RMS installation failed!"
169
+ exit $julia_status
170
+ fi
171
+
115
172
echo " Checking if ReactionMechanismSimulator is installed in the current conda environment for Python usage..."
116
- python -c " from juliacall import Main; import sys; sys.exit(0 if Main.seval('Base.identify_package(\" ReactionMechanismSimulator\" ) !== nothing') and print('ReactionMechanismSimulator is installed in $current_env ') is None else 1)"
173
+
174
+ python << EOF
175
+ import sys
176
+ try:
177
+ from juliacall import Main
178
+ RMS_Pkg = Main.seval('Base.identify_package("ReactionMechanismSimulator")')
179
+ print("Package identify result: ", RMS_Pkg)
180
+ if RMS_Pkg is Main.nothing:
181
+ print("❌ ReactionMechanismSimulator is NOT installed correctly.")
182
+ sys.exit(1)
183
+ else:
184
+ print("✅ ReactionMechanismSimulator is succesfully installed!")
185
+ sys.exit(0)
186
+ except Exception as e:
187
+ print("❌ Error while checking ReactionMechanismSimulator installation:")
188
+ print(e)
189
+ sys.exit(1)
190
+ EOF
0 commit comments