diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 9af32218374cddf18e0f065a953fc239122b7252..c17bec4a1468a01aa19913da98e760353fc4eba8 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -926,6 +926,9 @@ def build_process():
                      install(env_path, env_install_path)
                      dump_packages(self.spec, packages_dir)
 
+                # Run post install hooks before build stage is removed.
+                spack.hooks.post_install(self)
+
             # Stop timer.
             self._total_time = time.time() - start_time
             build_time = self._total_time - self._fetch_time
@@ -954,9 +957,6 @@ def build_process():
         # the database, so that we don't need to re-read from file.
         spack.installed_db.add(self.spec, self.prefix)
 
-        # Once everything else is done, run post install hooks
-        spack.hooks.post_install(self)
-
 
     def sanity_check_prefix(self):
         """This function checks whether install succeeded."""