@@ -53,8 +53,9 @@ def parse_args(self):
53
53
help = "Directory to install Spack instance and a build directory." )
54
54
parser .add_argument ("--spack-url" , type = str , default = default_spack_url ,
55
55
help = "URL to download spack." )
56
- parser .add_argument ("--debug" , action = "store_true" ,
57
- help = "Set this flag if seeing odd Spack issues with tpl-manager." )
56
+ parser .add_argument ("--clean" , action = "store_true" ,
57
+ help = "Set this flag to ensure concretizations/installs are fresh. " + \
58
+ "If issues arise, try using this flag." )
58
59
parser .add_argument ("--no-upstream" , action = "store_true" ,
59
60
help = "Ignore upstream by temporarily modifying environment." )
60
61
parser .add_argument ("--init-only" , action = "store_true" ,
@@ -119,14 +120,14 @@ def clone_spack(self):
119
120
sexe (f"git -C { spack_dir } fetch --depth=2 origin { spack_commit } " )
120
121
sexe (f"git -C { spack_dir } checkout FETCH_HEAD" )
121
122
self .add_spack_paths (spack_dir )
122
- if self .args .debug :
123
+ if ( self .args .clean ) :
123
124
sexe (f"git -C { spack_dir } clean -df" )
124
125
125
126
def find_spack_package (self , package_names ):
126
127
"""
127
128
Find if the package name/s is already in the environment.
128
- If any one of them are found, return the name of that package
129
- If not, run spack external find and raise an error if none are found
129
+ If any one of them are found, return the name of that package.
130
+ If not, run spack external find and raise an error if none are found.
130
131
"""
131
132
cur_packages = spack .config .get ("packages" )
132
133
if (type (package_names ) is not list ):
@@ -185,7 +186,8 @@ def custom_spack_env(self, env_dir, env_name):
185
186
dev_cmd ("-p" , dev_path , f"{ package } @=develop" ) # spack develop <package>@=develop
186
187
187
188
comp_cmd ("find" ) # spack compiler find
188
- ext_cmd ("find" )
189
+ ext_cmd ("find" ) # spack external find
190
+
189
191
# req_packages are packages we refuse to let spack build
190
192
# If they aren't found, an error will be thrown telling the user
191
193
# to install the package or ensure an install is in $PATH
@@ -245,21 +247,33 @@ def activate_spack_env(self):
245
247
env_dir = os .path .join (config_env_dir , env_name )
246
248
self .custom_spack_env (env_dir , env_name )
247
249
248
- def concretize_spec (self ):
250
+ def concretize_spec (self , check_spec ):
249
251
"Concretize the spec"
250
- self .spack_spec = spack .spec .Spec (self .args .spec )
251
- if (self .args .add_spec ):
252
- add_cmd = SpackCommand ("add" )
253
- add_cmd (self .args .spec )
252
+ if (check_spec ):
253
+ self .spack_spec = spack .spec .Spec (self .args .spec )
254
+ if (self .args .add_spec ):
255
+ add_cmd = SpackCommand ("add" )
256
+ add_cmd (self .args .spec )
254
257
print ("Concretizing environment" )
255
258
conc_cmd = SpackCommand ("concretize" )
256
- conc_cmd ("-U" )
257
- matches = self .spack_env .matching_spec (self .spack_spec )
258
- if (not matches ):
259
- raise Exception (f"{ self .args .spec } not found in current " + \
260
- "environment. Rerun with --add-spec to add it." )
261
- self .spack_spec = matches
262
- print (f"Found matching root spec for { self .args .spec } " )
259
+ if (self .args .clean ):
260
+ conc_cmd ("-U" , "-f" )
261
+ else :
262
+ conc_cmd ("-U" )
263
+ if (check_spec ):
264
+ matches = self .spack_env .matching_spec (self .spack_spec )
265
+ if (not matches ):
266
+ raise Exception (f"{ self .args .spec } not found in current " + \
267
+ "environment. Rerun with --add-spec to add it." )
268
+ self .spack_spec = matches
269
+ print (f"Found matching root spec for { self .args .spec } " )
270
+
271
+ def do_install (self , install_args , spec ):
272
+ install_cmd = SpackCommand ("install" )
273
+ if (self .args .dry_run ):
274
+ install_args .append ("--fake" )
275
+ print (f"Running spack { ' ' .join (install_args )} { spec } " )
276
+ install_cmd (* install_args , spec )
263
277
264
278
def install_and_config (self ):
265
279
"Install TPLs and create host config file for given spec"
@@ -285,15 +299,12 @@ def install_and_config(self):
285
299
spec_cmd = SpackCommand ("spec" )
286
300
print (f"Running spack spec -IL { spec } " )
287
301
spec_cmd ("-IL" , spec )
288
- if (not self .args .dry_run ):
289
- install_cmd = SpackCommand ("install" )
290
- install_args = ["-u" , "initconfig" ]
291
- if (self .args .dev_pkg ):
292
- # Spec is provided so assumes we are building from a buildcache
293
- install_args .extend (["--use-buildcache" , "package:never,dependencies:only" , "--no-check-signature" ])
294
- print (f"Running spack { ' ' .join (install_args )} { spec } " )
295
- install_cmd (* install_args , spec )
296
- print (f"Created { host_config_file } " )
302
+ install_args = ["-u" , "initconfig" ]
303
+ if (self .args .dev_pkg ):
304
+ # Spec is provided so assumes we are building from a buildcache
305
+ install_args .extend (["--use-buildcache" , "package:never,dependencies:only" , "--no-check-signature" ])
306
+ self .do_install (install_args , spec )
307
+ print (f"Created { host_config_file } " )
297
308
298
309
if (self .args .ci_run ):
299
310
shutil .copyfile (host_config_file , "gitlab.cmake" )
@@ -312,17 +323,14 @@ def __init__(self):
312
323
self .activate_spack_env ()
313
324
if (self .args .spec ):
314
325
# If --spec is given, install TPLs and create host config file
315
- self .concretize_spec ()
326
+ self .concretize_spec (check_spec = True )
316
327
self .install_and_config ()
317
328
else :
318
329
# Concretize the current environment
319
- print ("Concretizing environment" )
320
- conc_cmd = SpackCommand ("concretize" )
321
- conc_cmd ("-U" )
330
+ self .concretize_spec (check_spec = False )
322
331
# No spec is given, install TPLs for all env specs
323
- install_cmd = SpackCommand ("install" )
324
- print (f"Running spack install --only dependencies { package_name } " )
325
- install_cmd ("--only" , "dependencies" , package_name )
332
+ install_args = ["--only" , "dependencies" ]
333
+ self .do_install (install_args , package_name )
326
334
327
335
# Undo any file changes we made to spack.yaml
328
336
orig_file = os .path .join (self .spack_env .path , "origspack.yaml" )
0 commit comments