Add a custom hook for dev_path changes (#46529)
* Add a custom hook for dev_path changes Co-authored-by: Greg Becker <becker33@llnl.gov>
This commit is contained in:
parent
bbd205543b
commit
ea6e39805a
@ -414,7 +414,13 @@ default, it will also clone the package to a subdirectory in the
|
||||
environment. This package will have a special variant ``dev_path``
|
||||
set, and Spack will ensure the package and its dependents are rebuilt
|
||||
any time the environment is installed if the package's local source
|
||||
code has been modified. Spack ensures that all instances of a
|
||||
code has been modified. Spack's native implementation to check for modifications
|
||||
is to check if ``mtime`` is newer than the installation.
|
||||
A custom check can be created by overriding the ``detect_dev_src_change`` method
|
||||
in your package class. This is particularly useful for projects using custom spack repo's
|
||||
to drive development and want to optimize performance.
|
||||
|
||||
Spack ensures that all instances of a
|
||||
developed package in the environment are concretized to match the
|
||||
version (and other constraints) passed as the spec argument to the
|
||||
``spack develop`` command.
|
||||
|
@ -546,8 +546,7 @@ def _is_dev_spec_and_has_changed(spec):
|
||||
last installation"""
|
||||
# First check if this is a dev build and in the process already try to get
|
||||
# the dev_path
|
||||
dev_path_var = spec.variants.get("dev_path", None)
|
||||
if not dev_path_var:
|
||||
if not spec.variants.get("dev_path", None):
|
||||
return False
|
||||
|
||||
# Now we can check whether the code changed since the last installation
|
||||
@ -555,9 +554,10 @@ def _is_dev_spec_and_has_changed(spec):
|
||||
# Not installed -> nothing to compare against
|
||||
return False
|
||||
|
||||
_, record = spack.store.STORE.db.query_by_spec_hash(spec.dag_hash())
|
||||
mtime = fs.last_modification_time_recursive(dev_path_var.value)
|
||||
return mtime > record.installation_time
|
||||
# hook so packages can use to write their own method for checking the dev_path
|
||||
# use package so attributes about concretization such as variant state can be
|
||||
# utilized
|
||||
return spec.package.detect_dev_src_change()
|
||||
|
||||
|
||||
def _error_on_nonempty_view_dir(new_root):
|
||||
|
@ -1101,6 +1101,15 @@ def update_external_dependencies(self, extendee_spec=None):
|
||||
"""
|
||||
pass
|
||||
|
||||
def detect_dev_src_change(self):
|
||||
"""
|
||||
Method for checking for source code changes to trigger rebuild/reinstall
|
||||
"""
|
||||
dev_path_var = self.spec.variants.get("dev_path", None)
|
||||
_, record = spack.store.STORE.db.query_by_spec_hash(self.spec.dag_hash())
|
||||
mtime = fsys.last_modification_time_recursive(dev_path_var.value)
|
||||
return mtime > record.installation_time
|
||||
|
||||
def all_urls_for_version(self, version: StandardVersion) -> List[str]:
|
||||
"""Return all URLs derived from version_urls(), url, urls, and
|
||||
list_url (if it contains a version) in a package in that order.
|
||||
|
Loading…
Reference in New Issue
Block a user