summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/utils.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/spack/spack/utils.py b/lib/spack/spack/utils.py
index 465c83caf9..2781262b5a 100644
--- a/lib/spack/spack/utils.py
+++ b/lib/spack/spack/utils.py
@@ -1,7 +1,6 @@
import os
import re
import errno
-import glob
import shutil
import subprocess
import multiprocessing
@@ -39,9 +38,17 @@ def install(src, dest):
def list_modules(directory):
"""Lists all of the modules, excluding __init__.py, in
a particular directory."""
- os.chdir(directory)
- for name in glob.glob("*.py"):
- if name != '__init__.py':
+ for name in os.listdir(directory):
+ if name == '__init__.py':
+ continue
+
+ path = new_path(directory, name)
+ if os.path.isdir(path):
+ init_py = new_path(path, '__init__.py')
+ if os.path.isfile(init_py):
+ yield name
+
+ elif name.endswith('.py'):
yield re.sub('.py$', '', name)