22from importlib .resources import files
33from pathlib import Path
44import subprocess
5- from . import nhls_path
5+ from . import nhls_path
66
7+
8+ # Test if we can run rustup commands
79def check_rustup_present ():
810 try :
9- subprocess .run (
10- ["rustup" ],
11- stdout = subprocess .DEVNULL ,
12- stderr = subprocess .DEVNULL
13- )
11+ subprocess .run (["rustup" ], stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
1412 return True
1513 except FileNotFoundError :
16- return False
14+ return False
1715
18- def session_init (nhls_path_override = None ):
16+
17+ def session_init (nhls_path_override = None ):
1918 # Load NHLS version information
2019 nhls_version_path = files ("nhls_py" ) / "nhls_version.json"
2120 print (f"nhls_version_path: { nhls_version_path } " )
@@ -27,8 +26,8 @@ def session_init(nhls_path_override = None):
2726 nhls_url = nhls_version ["url" ]
2827 print (f"nhls branch: { nhls_branch } , url: { nhls_url } " )
2928
30- # Figure out where checkout should be
31- global nhls_path
29+ # Figure out where checkout should be
30+ global nhls_path
3231 if nhls_path_override is None :
3332 nhls_path = Path (nhls_path ).expanduser ()
3433 else :
@@ -52,11 +51,11 @@ def session_init(nhls_path_override = None):
5251 nhls_path ,
5352 ]
5453 subprocess .run (
55- clone_args ,
56- cwd = nhls_path .parent ,
57- capture_output = False ,
58- text = True ,
59- check = True
54+ clone_args ,
55+ cwd = nhls_path .parent ,
56+ capture_output = False ,
57+ text = True ,
58+ check = True ,
6059 )
6160
6261 # Check that rustup is present
@@ -66,7 +65,7 @@ def session_init(nhls_path_override = None):
6665 print ("please install rustup!" )
6766 print ("https://rustup.rs" )
6867 raise ValueError ("Rustup not installed" )
69-
68+
7069 # Ensure correct toolchain is present
7170 print ("checking toolchain..." )
7271 tool_args = [
@@ -75,11 +74,7 @@ def session_init(nhls_path_override = None):
7574 "install" ,
7675 ]
7776 subprocess .run (
78- tool_args ,
79- cwd = nhls_path ,
80- capture_output = False ,
81- text = True ,
82- check = True
77+ tool_args , cwd = nhls_path , capture_output = False , text = True , check = True
8378 )
8479
8580 # Run cargo build now
@@ -89,13 +84,9 @@ def session_init(nhls_path_override = None):
8984 "cargo" ,
9085 "build" ,
9186 "--release" ,
92- ]
87+ ]
9388 subprocess .run (
94- build_args ,
95- cwd = nhls_path ,
96- capture_output = False ,
97- text = True ,
98- check = True
89+ build_args , cwd = nhls_path , capture_output = False , text = True , check = True
9990 )
10091
10192 # Done
0 commit comments