From ae2a803496772db9ce6f9245d165b44f587e4389 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 30 Aug 2016 10:47:38 -0500 Subject: [PATCH] Make subcommands importable, '-' -> '_', fixes #1642 --- bin/spack | 11 +++++++++-- .../spack/cmd/{package-list.py => package_list.py} | 0 .../spack/cmd/{test-install.py => test_install.py} | 0 lib/spack/spack/cmd/{url-parse.py => url_parse.py} | 0 lib/spack/spack/test/cmd/test_install.py | 6 +----- 5 files changed, 10 insertions(+), 7 deletions(-) rename lib/spack/spack/cmd/{package-list.py => package_list.py} (100%) rename lib/spack/spack/cmd/{test-install.py => test_install.py} (100%) rename lib/spack/spack/cmd/{url-parse.py => url_parse.py} (100%) diff --git a/bin/spack b/bin/spack index 7efa88f1ee..323a06aa53 100755 --- a/bin/spack +++ b/bin/spack @@ -56,8 +56,15 @@ with warnings.catch_warnings(): # Spack, were removed, but shadow system modules that Spack still # imports. If we leave them, Spack will fail in mysterious ways. # TODO: more elegant solution for orphaned pyc files. -orphaned_pyc_files = [os.path.join(SPACK_EXTERNAL_LIBS, n) - for n in ('functools.pyc', 'ordereddict.pyc')] +orphaned_pyc_files = [ + os.path.join(SPACK_EXTERNAL_LIBS, 'functools.pyc'), + os.path.join(SPACK_EXTERNAL_LIBS, 'ordereddict.pyc'), + os.path.join(SPACK_LIB_PATH, 'spack', 'platforms', 'cray_xc.pyc'), + os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'package-list.pyc'), + os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'test-install.pyc'), + os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'url-parse.pyc') +] + for pyc_file in orphaned_pyc_files: if not os.path.exists(pyc_file): continue diff --git a/lib/spack/spack/cmd/package-list.py b/lib/spack/spack/cmd/package_list.py similarity index 100% rename from lib/spack/spack/cmd/package-list.py rename to lib/spack/spack/cmd/package_list.py diff --git a/lib/spack/spack/cmd/test-install.py b/lib/spack/spack/cmd/test_install.py similarity index 100% rename from lib/spack/spack/cmd/test-install.py rename to lib/spack/spack/cmd/test_install.py diff --git a/lib/spack/spack/cmd/url-parse.py b/lib/spack/spack/cmd/url_parse.py similarity index 100% rename from lib/spack/spack/cmd/url-parse.py rename to lib/spack/spack/cmd/url_parse.py diff --git a/lib/spack/spack/test/cmd/test_install.py b/lib/spack/spack/test/cmd/test_install.py index 39287d5d6d..4734fe1267 100644 --- a/lib/spack/spack/test/cmd/test_install.py +++ b/lib/spack/spack/test/cmd/test_install.py @@ -30,6 +30,7 @@ import spack import spack.cmd +from spack.cmd import test_install FILE_REGISTRY = collections.defaultdict(StringIO.StringIO) @@ -51,11 +52,6 @@ def mock_open(filename, mode): handle.close() -# The use of __import__ is necessary to maintain a name with hyphen (which -# cannot be an identifier in python) -test_install = __import__("spack.cmd.test-install", fromlist=['test_install']) - - class MockSpec(object): def __init__(self, name, version, hashStr=None):