summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth R. Johnson <johnsonsr@ornl.gov>2019-08-23 00:42:17 -0400
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2019-08-23 06:42:17 +0200
commitc86006e9485993985a7dd0a72f9b49491c48c046 (patch)
treedfcd7382b5f2cc8e3ebbce3e475306d6317353a8
parenta707c5bd2b5dd0380fe8546b4f67ca993f520b4a (diff)
downloadspack-c86006e9485993985a7dd0a72f9b49491c48c046.tar.gz
spack-c86006e9485993985a7dd0a72f9b49491c48c046.tar.bz2
spack-c86006e9485993985a7dd0a72f9b49491c48c046.tar.xz
spack-c86006e9485993985a7dd0a72f9b49491c48c046.zip
Skip invisible non-packages in package directory. (#12467)
Having a non-directory invisible file causes `spack find` to die. This fixes the logic to ignore invalid module names but only warn if they're visible. ``` NotADirectoryError: [Errno 20] Not a directory: '/spack/var/spack/repos/builtin/packages/.DS_Store/package.py' ```
-rw-r--r--lib/spack/spack/repo.py10
-rw-r--r--lib/spack/spack/test/repo.py6
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py
index f9f733ef7f..6e4c0a2f49 100644
--- a/lib/spack/spack/repo.py
+++ b/lib/spack/spack/repo.py
@@ -150,11 +150,11 @@ class FastPackageChecker(Mapping):
pkg_dir = os.path.join(self.packages_path, pkg_name)
# Warn about invalid names that look like packages.
- if (not valid_module_name(pkg_name)
- and not pkg_name.startswith('.')):
- msg = 'Skipping package at {0}. '
- msg += '"{1}" is not a valid Spack module name.'
- tty.warn(msg.format(pkg_dir, pkg_name))
+ if not valid_module_name(pkg_name):
+ if not pkg_name.startswith('.'):
+ tty.warn('Skipping package at {0}. "{1}" is not '
+ 'a valid Spack module name.'.format(
+ pkg_dir, pkg_name))
continue
# Construct the file name from the directory
diff --git a/lib/spack/spack/test/repo.py b/lib/spack/spack/test/repo.py
index 8f37bc6754..e171dbca68 100644
--- a/lib/spack/spack/test/repo.py
+++ b/lib/spack/spack/test/repo.py
@@ -64,3 +64,9 @@ def test_repo_last_mtime():
latest_mtime = max(os.path.getmtime(p.module.__file__)
for p in spack.repo.path.all_packages())
assert spack.repo.path.last_mtime() == latest_mtime
+
+
+def test_repo_invisibles(repo_for_test, extra_repo):
+ with open(os.path.join(extra_repo.root, 'packages', '.invisible'), 'w'):
+ pass
+ extra_repo.all_package_names()