5858import spack .mirror
5959import spack .hooks
6060import spack .directives
61+ import spack .binary_distribution
6162import spack .build_environment
6263import spack .url
6364import spack .util .web
@@ -838,20 +839,21 @@ def _resource_stage(self, resource):
838839
839840 def do_install (self ,
840841 keep_prefix = False , keep_stage = False , ignore_deps = False ,
841- skip_patch = False , verbose = False , make_jobs = None , fake = False ):
842+ skip_patch = False , verbose = False , make_jobs = None , fake = False , install_policy = "build" ):
842843 """Called by commands to install a package and its dependencies.
843844
844845 Package implementations should override install() to describe
845846 their build process.
846847
847848 Args:
848- keep_prefix -- Keep install prefix on failure. By default, destroys it.
849- keep_stage -- Keep stage on successful build. By default, destroys it.
850- ignore_deps -- Do not install dependencies before installing this package.
851- fake -- Don't really build -- install fake stub files instead.
852- skip_patch -- Skip patch stage of build if True.
853- verbose -- Display verbose build output (by default, suppresses it)
854- make_jobs -- Number of make jobs to use for install. Default is ncpus.
849+ keep_prefix -- Keep install prefix on failure. By default, destroys it.
850+ keep_stage -- Keep stage on successful build. By default, destroys it.
851+ ignore_deps -- Do not install dependencies before installing this package.
852+ install_policy -- Whether to download a pre-compiled package or build from scratch
853+ fake -- Don't really build -- install fake stub files instead.
854+ skip_patch -- Skip patch stage of build if True.
855+ verbose -- Display verbose build output (by default, suppresses it)
856+ make_jobs -- Number of make jobs to use for install. Default is ncpus.
855857 """
856858 if not self .spec .concrete :
857859 raise ValueError ("Can only install concrete packages." )
@@ -865,11 +867,15 @@ def do_install(self,
865867 if not ignore_deps :
866868 self .do_install_dependencies (
867869 keep_prefix = keep_prefix , keep_stage = keep_stage , ignore_deps = ignore_deps ,
868- fake = fake , skip_patch = skip_patch , verbose = verbose ,
870+ fake = fake , skip_patch = skip_patch , verbose = verbose , install_policy = install_policy ,
869871 make_jobs = make_jobs )
870872
871873 start_time = time .time ()
872- if not fake :
874+ print install_policy
875+ if install_policy != "build" :
876+ spack .binary_distribution .prepare ()
877+ spack .binary_distribution .download_tarball (self )
878+ elif not fake :
873879 if not skip_patch :
874880 self .do_patch ()
875881 else :
@@ -900,7 +906,10 @@ def real_work():
900906 spack .hooks .pre_install (self )
901907
902908 # Set up process's build environment before running install.
903- if fake :
909+ if install_policy != "build" :
910+ spack .binary_distribution .extract_tarball (self )
911+ spack .binary_distribution .relocate (self )
912+ elif fake :
904913 self .do_fake_install ()
905914 else :
906915 # Do the real install in the source directory.
@@ -916,7 +925,7 @@ def real_work():
916925 self ._sanity_check_install ()
917926
918927 # Move build log into install directory on success
919- if not fake :
928+ if install_policy == "build" and not fake :
920929 log_install_path = spack .install_layout .build_log_path (self .spec )
921930 install (log_path , log_install_path )
922931
0 commit comments