From 1f6cd4de1b85ffc4767c66272467bf9542aba970 Mon Sep 17 00:00:00 2001 From: Stu Hood Date: Fri, 22 May 2020 11:22:25 -0700 Subject: [PATCH] Default to invalidating for `requirements.txt` to ameliorate #7022. [ci skip-rust-tests] [ci skip-jvm-tests] --- src/python/pants/init/options_initializer.py | 28 ++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/python/pants/init/options_initializer.py b/src/python/pants/init/options_initializer.py index 6dfea7eb1231..003fea3ca1c8 100644 --- a/src/python/pants/init/options_initializer.py +++ b/src/python/pants/init/options_initializer.py @@ -136,20 +136,15 @@ def compute_pantsd_invalidation_globs(buildroot, bootstrap_options): invalidation_globs provided by users. """ invalidation_globs = OrderedSet() - globs = [ + + # Globs calculated from the sys.path and other file-like configuration need to be sanitized + # to relative globs (where possible). + potentially_absolute_globs = ( *sys.path, *bootstrap_options.pythonpath, *bootstrap_options.pants_config_files, - "!*.pyc", - "!__pycache__/", - *bootstrap_options.pantsd_invalidation_globs, - ] - - for glob in globs: - if glob.startswith("!"): - invalidation_globs.add(glob) - continue - + ) + for glob in potentially_absolute_globs: glob_relpath = fast_relpath_optional(glob, buildroot) if os.path.isabs(glob) else glob if glob_relpath: invalidation_globs.update([glob_relpath, glob_relpath + "/**"]) @@ -158,6 +153,17 @@ def compute_pantsd_invalidation_globs(buildroot, bootstrap_options): f"Changes to {glob}, outside of the buildroot, will not be invalidated." ) + # Explicitly specified globs are already relative, and added verbatim. + invalidation_globs.update( + ( + "!*.pyc", + "!__pycache__/", + # TODO: See https://github.com/pantsbuild/pants/issues/7022. + "**/requirements.txt", + *bootstrap_options.pantsd_invalidation_globs, + ) + ) + return list(invalidation_globs) @classmethod