@@ -169,24 +169,23 @@ def __call__(self, parser, namespace, value, option_string=None):
169
169
replace = args .replace
170
170
)
171
171
172
- # Connect the self referencing token left in the kernel.json to point to it's install location.
173
-
174
- # Prepare the token replacement string which should be properly escaped for use in a JSON string
172
+ # Prepare token replacement strings which should be properly escaped for use in a JSON string
175
173
# The [1:-1] trims the first and last " json.dumps adds for strings.
176
- install_dest_json_fragment = json .dumps (install_dest )[1 :- 1 ]
174
+ executable_path = json .dumps (sys .executable )[1 :- 1 ]
175
+ launcher_path = json .dumps (os .path .join (install_dest , 'launcher.py' ))[1 :- 1 ]
176
+ kernel_path = json .dumps (os .path .join (install_dest , '${project.build.finalName}.jar' ))[1 :- 1 ]
177
177
178
178
# Prepare the paths to the installed kernel.json and the one bundled with this installer.
179
179
local_kernel_json_path = os .path .join (os .path .dirname (os .path .abspath (__file__ )), 'java' , 'kernel.json' )
180
180
installed_kernel_json_path = os .path .join (install_dest , 'kernel.json' )
181
181
182
- # Replace the @KERNEL_INSTALL_DIRECTORY@ token with the path to where the kernel was installed
183
- # in the installed kernel.json from the local template.
182
+ # Replace tokens in the installed kernel.json.
184
183
with open (local_kernel_json_path , 'r' ) as template_kernel_json_file :
185
184
template_kernel_json_contents = template_kernel_json_file .read ()
186
- kernel_json_contents = template_kernel_json_contents .replace (
187
- '@KERNEL_INSTALL_DIRECTORY @' ,
188
- install_dest_json_fragment
189
- )
185
+ kernel_json_contents = template_kernel_json_contents .replace ('@PY_EXECUTABLE@' , executable_path )
186
+ kernel_json_contents = kernel_json_contents . replace ( '@LAUNCHER_PATH @' , launcher_path )
187
+ kernel_json_contents = kernel_json_contents . replace ( '@KERNEL_PATH@' , kernel_path )
188
+ print ( kernel_json_contents )
190
189
kernel_json_json_contents = json .loads (kernel_json_contents )
191
190
kernel_env = kernel_json_json_contents .setdefault ('env' , {})
192
191
for k , v in args .env .items ():
0 commit comments