11# *****************************************************************************
22#
33# Part of the py5jupyter (& py5) library
4- # Copyright (C) 2022-2023 Jim Schmitz
4+ # Copyright (C) 2022-2024 Jim Schmitz
55#
66# This library is free software: you can redistribute it and/or modify it
77# under the terms of the GNU Lesser General Public License as published by
2929
3030
3131kernel_json = {
32- "argv" : [sys .executable , "-m" , "py5jupyter.kernels.py5bot" , "-f" , "{connection_file}" ],
32+ "argv" : [
33+ sys .executable ,
34+ "-m" ,
35+ "py5jupyter.kernels.py5bot" ,
36+ "-f" ,
37+ "{connection_file}" ,
38+ ],
3339 "display_name" : "py5bot" ,
3440 "language" : "python" ,
3541}
3844def install_py5bot_kernel_spec (user = True , prefix = None ):
3945 with TemporaryDirectory () as td :
4046 os .chmod (td , 0o755 ) # Starts off as 700, not user readable
41- with open (Path (td ) / ' kernel.json' , 'w' ) as f :
47+ with open (Path (td ) / " kernel.json" , "w" ) as f :
4248 json .dump (kernel_json , f , sort_keys = True )
4349
4450 # Copy any resources
45- for file in (Path (__file__ ).parent / ' resources' ).glob ('*' ):
51+ for file in (Path (__file__ ).parent / " resources" ).glob ("*" ):
4652 shutil .copy (file , Path (td ) / file .name )
4753
48- print ('Installing py5bot Jupyter kernel spec' )
49- KernelSpecManager ().install_kernel_spec (
50- td , 'py5bot' , user = user , prefix = prefix )
54+ print ("Installing py5bot Jupyter kernel spec" )
55+ KernelSpecManager ().install_kernel_spec (td , "py5bot" , user = user , prefix = prefix )
5156
5257
5358def _is_root ():
@@ -59,13 +64,21 @@ def _is_root():
5964
6065def main (argv = None ):
6166 ap = argparse .ArgumentParser ()
62- ap .add_argument ('--user' , action = 'store_true' ,
63- help = "Install to the per-user kernels registry. Default if not root." )
64- ap .add_argument ('--sys-prefix' , action = 'store_true' ,
65- help = "Install to sys.prefix (e.g. a virtualenv or conda env)" )
66- ap .add_argument ('--prefix' ,
67- help = "Install to the given prefix. "
68- "Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/" )
67+ ap .add_argument (
68+ "--user" ,
69+ action = "store_true" ,
70+ help = "Install to the per-user kernels registry. Default if not root." ,
71+ )
72+ ap .add_argument (
73+ "--sys-prefix" ,
74+ action = "store_true" ,
75+ help = "Install to sys.prefix (e.g. a virtualenv or conda env)" ,
76+ )
77+ ap .add_argument (
78+ "--prefix" ,
79+ help = "Install to the given prefix. "
80+ "Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/" ,
81+ )
6982 args = ap .parse_args (argv )
7083
7184 if args .sys_prefix :
@@ -76,5 +89,5 @@ def main(argv=None):
7689 install_py5bot_kernel_spec (user = args .user , prefix = args .prefix )
7790
7891
79- if __name__ == ' __main__' :
92+ if __name__ == " __main__" :
8093 main ()
0 commit comments