diff --git a/bin/spack b/bin/spack index 60a2ef4c3a..b922fc5479 100755 --- a/bin/spack +++ b/bin/spack @@ -39,6 +39,12 @@ SPACK_PREFIX = os.path.dirname(os.path.dirname(SPACK_FILE)) SPACK_LIB_PATH = os.path.join(SPACK_PREFIX, "lib", "spack") sys.path.insert(0, SPACK_LIB_PATH) +# If there is no working directory, use the spack prefix. +try: + os.getcwd() +except OSError: + os.chdir(SPACK_PREFIX) + # clean up the scope and start using spack package instead. del SPACK_FILE, SPACK_PREFIX, SPACK_LIB_PATH import llnl.util.tty as tty @@ -74,10 +80,8 @@ args = parser.parse_args() spack.verbose = args.verbose spack.debug = args.debug if args.mock: - from llnl.util.filesystem import join_path from spack.packages import PackageDB - mock_path = join_path(spack.module_path, 'test', 'mock_packages') - spack.db = PackageDB(mock_path) + spack.db = PackageDB(spack.mock_packages_path) # If the user asked for it, don't check ssl certs. if args.insecure: diff --git a/lib/spack/spack/globals.py b/lib/spack/spack/globals.py index 20801447fa..4ff50a3e7e 100644 --- a/lib/spack/spack/globals.py +++ b/lib/spack/spack/globals.py @@ -53,8 +53,13 @@ # # Set up the packages database. # -db = PackageDB(join_path(module_path, "packages")) +packages_path = join_path(var_path, "packages") +db = PackageDB(packages_path) +# +# This is the path to mock packages used by spack for testing. +# +mock_packages_path = join_path(var_path, "mock_packages") # # This controls how spack lays out install prefixes and diff --git a/lib/spack/spack/packages/__init__.py b/lib/spack/spack/packages.py similarity index 97% rename from lib/spack/spack/packages/__init__.py rename to lib/spack/spack/packages.py index beb8ecf6ab..732ced9bf2 100644 --- a/lib/spack/spack/packages/__init__.py +++ b/lib/spack/spack/packages.py @@ -200,10 +200,6 @@ def get_class_for_package_name(self, pkg_name): else: raise UnknownPackageError(pkg_name) - # Figure out pacakges module based on self.root - if not re.match(r'%s' % spack.module_path, self.root): - raise RuntimeError("Packages path is not a submodule of spack.") - class_name = class_name_for_package_name(pkg_name) try: module_name = _imported_packages_module + '.' + pkg_name diff --git a/lib/spack/spack/test/mock_packages_test.py b/lib/spack/spack/test/mock_packages_test.py index f300995d7e..e9a8113c09 100644 --- a/lib/spack/spack/test/mock_packages_test.py +++ b/lib/spack/spack/test/mock_packages_test.py @@ -24,15 +24,10 @@ ############################################################################## import unittest -from llnl.util.lang import list_modules -from llnl.util.filesystem import join_path - import spack from spack.packages import PackageDB from spack.spec import Spec -mock_packages_path = join_path(spack.module_path, 'test', 'mock_packages') - def set_pkg_dep(pkg, spec): """Alters dependence information for a pacakge. Use this to mock up constraints. @@ -48,7 +43,7 @@ def setUp(self): # us to set up contrived packages that don't interfere with # real ones. self.real_db = spack.db - spack.db = PackageDB(mock_packages_path) + spack.db = PackageDB(spack.mock_packages_path) @classmethod diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py index 146700948f..1b2e0ab07a 100644 --- a/lib/spack/spack/test/packages.py +++ b/lib/spack/spack/test/packages.py @@ -24,9 +24,10 @@ ############################################################################## import unittest +from llnl.util.filesystem import join_path + import spack import spack.packages as packages - from spack.test.mock_packages_test import * @@ -43,7 +44,7 @@ def test_package_name(self): def test_package_filename(self): filename = spack.db.filename_for_package_name('mpich') - self.assertEqual(filename, join_path(mock_packages_path, 'mpich', 'package.py')) + self.assertEqual(filename, join_path(spack.mock_packages_path, 'mpich', 'package.py')) def test_package_name(self): @@ -53,7 +54,7 @@ def test_package_name(self): def test_nonexisting_package_filename(self): filename = spack.db.filename_for_package_name('some-nonexisting-package') - self.assertEqual(filename, join_path(mock_packages_path, 'some-nonexisting-package', 'package.py')) + self.assertEqual(filename, join_path(spack.mock_packages_path, 'some-nonexisting-package', 'package.py')) def test_package_class_names(self): diff --git a/lib/spack/spack/test/mock_packages/callpath/package.py b/var/spack/mock_packages/callpath/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/callpath/package.py rename to var/spack/mock_packages/callpath/package.py diff --git a/lib/spack/spack/test/mock_packages/direct_mpich/package.py b/var/spack/mock_packages/direct_mpich/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/direct_mpich/package.py rename to var/spack/mock_packages/direct_mpich/package.py diff --git a/lib/spack/spack/test/mock_packages/dyninst/package.py b/var/spack/mock_packages/dyninst/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/dyninst/package.py rename to var/spack/mock_packages/dyninst/package.py diff --git a/lib/spack/spack/test/mock_packages/fake/package.py b/var/spack/mock_packages/fake/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/fake/package.py rename to var/spack/mock_packages/fake/package.py diff --git a/lib/spack/spack/test/mock_packages/indirect_mpich/package.py b/var/spack/mock_packages/indirect_mpich/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/indirect_mpich/package.py rename to var/spack/mock_packages/indirect_mpich/package.py diff --git a/lib/spack/spack/test/mock_packages/libdwarf/package.py b/var/spack/mock_packages/libdwarf/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/libdwarf/package.py rename to var/spack/mock_packages/libdwarf/package.py diff --git a/lib/spack/spack/test/mock_packages/libelf/package.py b/var/spack/mock_packages/libelf/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/libelf/package.py rename to var/spack/mock_packages/libelf/package.py diff --git a/lib/spack/spack/test/mock_packages/mpich/package.py b/var/spack/mock_packages/mpich/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/mpich/package.py rename to var/spack/mock_packages/mpich/package.py diff --git a/lib/spack/spack/test/mock_packages/mpich2/package.py b/var/spack/mock_packages/mpich2/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/mpich2/package.py rename to var/spack/mock_packages/mpich2/package.py diff --git a/lib/spack/spack/test/mock_packages/mpileaks/package.py b/var/spack/mock_packages/mpileaks/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/mpileaks/package.py rename to var/spack/mock_packages/mpileaks/package.py diff --git a/lib/spack/spack/test/mock_packages/multimethod/package.py b/var/spack/mock_packages/multimethod/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/multimethod/package.py rename to var/spack/mock_packages/multimethod/package.py diff --git a/lib/spack/spack/test/mock_packages/trivial_install_test_package/package.py b/var/spack/mock_packages/trivial_install_test_package/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/trivial_install_test_package/package.py rename to var/spack/mock_packages/trivial_install_test_package/package.py diff --git a/lib/spack/spack/test/mock_packages/zmpi/package.py b/var/spack/mock_packages/zmpi/package.py similarity index 100% rename from lib/spack/spack/test/mock_packages/zmpi/package.py rename to var/spack/mock_packages/zmpi/package.py diff --git a/lib/spack/spack/packages/callpath/package.py b/var/spack/packages/callpath/package.py similarity index 100% rename from lib/spack/spack/packages/callpath/package.py rename to var/spack/packages/callpath/package.py diff --git a/lib/spack/spack/packages/cmake/package.py b/var/spack/packages/cmake/package.py similarity index 100% rename from lib/spack/spack/packages/cmake/package.py rename to var/spack/packages/cmake/package.py diff --git a/lib/spack/spack/packages/dyninst/package.py b/var/spack/packages/dyninst/package.py similarity index 100% rename from lib/spack/spack/packages/dyninst/package.py rename to var/spack/packages/dyninst/package.py diff --git a/lib/spack/spack/packages/graphlib/package.py b/var/spack/packages/graphlib/package.py similarity index 100% rename from lib/spack/spack/packages/graphlib/package.py rename to var/spack/packages/graphlib/package.py diff --git a/lib/spack/spack/packages/launchmon/package.py b/var/spack/packages/launchmon/package.py similarity index 100% rename from lib/spack/spack/packages/launchmon/package.py rename to var/spack/packages/launchmon/package.py diff --git a/lib/spack/spack/packages/launchmon/patch.lmon_install_dir b/var/spack/packages/launchmon/patch.lmon_install_dir similarity index 100% rename from lib/spack/spack/packages/launchmon/patch.lmon_install_dir rename to var/spack/packages/launchmon/patch.lmon_install_dir diff --git a/lib/spack/spack/packages/libdwarf/package.py b/var/spack/packages/libdwarf/package.py similarity index 100% rename from lib/spack/spack/packages/libdwarf/package.py rename to var/spack/packages/libdwarf/package.py diff --git a/lib/spack/spack/packages/libelf/package.py b/var/spack/packages/libelf/package.py similarity index 100% rename from lib/spack/spack/packages/libelf/package.py rename to var/spack/packages/libelf/package.py diff --git a/lib/spack/spack/packages/libunwind/package.py b/var/spack/packages/libunwind/package.py similarity index 100% rename from lib/spack/spack/packages/libunwind/package.py rename to var/spack/packages/libunwind/package.py diff --git a/lib/spack/spack/packages/mpich/package.py b/var/spack/packages/mpich/package.py similarity index 100% rename from lib/spack/spack/packages/mpich/package.py rename to var/spack/packages/mpich/package.py diff --git a/lib/spack/spack/packages/mpileaks/package.py b/var/spack/packages/mpileaks/package.py similarity index 100% rename from lib/spack/spack/packages/mpileaks/package.py rename to var/spack/packages/mpileaks/package.py diff --git a/lib/spack/spack/packages/mrnet/package.py b/var/spack/packages/mrnet/package.py similarity index 100% rename from lib/spack/spack/packages/mrnet/package.py rename to var/spack/packages/mrnet/package.py diff --git a/lib/spack/spack/packages/mvapich2/ad_lustre_rwcontig_open_source.patch b/var/spack/packages/mvapich2/ad_lustre_rwcontig_open_source.patch similarity index 100% rename from lib/spack/spack/packages/mvapich2/ad_lustre_rwcontig_open_source.patch rename to var/spack/packages/mvapich2/ad_lustre_rwcontig_open_source.patch diff --git a/lib/spack/spack/packages/mvapich2/package.py b/var/spack/packages/mvapich2/package.py similarity index 100% rename from lib/spack/spack/packages/mvapich2/package.py rename to var/spack/packages/mvapich2/package.py diff --git a/lib/spack/spack/packages/openmpi/ad_lustre_rwcontig_open_source.patch b/var/spack/packages/openmpi/ad_lustre_rwcontig_open_source.patch similarity index 100% rename from lib/spack/spack/packages/openmpi/ad_lustre_rwcontig_open_source.patch rename to var/spack/packages/openmpi/ad_lustre_rwcontig_open_source.patch diff --git a/lib/spack/spack/packages/openmpi/llnl-platforms.patch b/var/spack/packages/openmpi/llnl-platforms.patch similarity index 100% rename from lib/spack/spack/packages/openmpi/llnl-platforms.patch rename to var/spack/packages/openmpi/llnl-platforms.patch diff --git a/lib/spack/spack/packages/openmpi/package.py b/var/spack/packages/openmpi/package.py similarity index 100% rename from lib/spack/spack/packages/openmpi/package.py rename to var/spack/packages/openmpi/package.py diff --git a/lib/spack/spack/packages/pmgr_collective/package.py b/var/spack/packages/pmgr_collective/package.py similarity index 100% rename from lib/spack/spack/packages/pmgr_collective/package.py rename to var/spack/packages/pmgr_collective/package.py diff --git a/lib/spack/spack/packages/scr/package.py b/var/spack/packages/scr/package.py similarity index 100% rename from lib/spack/spack/packages/scr/package.py rename to var/spack/packages/scr/package.py diff --git a/lib/spack/spack/packages/spindle/package.py b/var/spack/packages/spindle/package.py similarity index 100% rename from lib/spack/spack/packages/spindle/package.py rename to var/spack/packages/spindle/package.py diff --git a/lib/spack/spack/packages/stat/package.py b/var/spack/packages/stat/package.py similarity index 100% rename from lib/spack/spack/packages/stat/package.py rename to var/spack/packages/stat/package.py