summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2024-07-01 08:33:56 +0200
committerGitHub <noreply@github.com>2024-07-01 08:33:56 +0200
commite34d9cbe5fb3006a895cec745ca347efced00403 (patch)
tree78fbd0225c69e23e769f5bba1cfc942e396c0044 /lib
parent0efba0999009af9296dd63511af4dd52e1dc570c (diff)
downloadspack-e34d9cbe5fb3006a895cec745ca347efced00403.tar.gz
spack-e34d9cbe5fb3006a895cec745ca347efced00403.tar.bz2
spack-e34d9cbe5fb3006a895cec745ca347efced00403.tar.xz
spack-e34d9cbe5fb3006a895cec745ca347efced00403.zip
Remove DIYStage (#44949)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/package_base.py10
-rw-r--r--lib/spack/spack/stage.py58
-rw-r--r--lib/spack/spack/test/concretize_requirements.py19
-rw-r--r--lib/spack/spack/test/stage.py63
4 files changed, 9 insertions, 141 deletions
diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py
index d82f4cd499..fff859efd0 100644
--- a/lib/spack/spack/package_base.py
+++ b/lib/spack/spack/package_base.py
@@ -1583,13 +1583,11 @@ class PackageBase(WindowsRPath, PackageViewMixin, RedistributionMixin, metaclass
tty.debug("Patching failed last time. Restaging.")
self.stage.restage()
else:
- # develop specs/ DIYStages may have patch failures but
- # should never be restaged
- msg = (
- "A patch failure was detected in %s." % self.name
- + " Build errors may occur due to this."
+ # develop specs may have patch failures but should never be restaged
+ tty.warn(
+ f"A patch failure was detected in {self.name}."
+ " Build errors may occur due to this."
)
- tty.warn(msg)
return
# If this file exists, then we already applied all the patches.
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 67a81a68ee..9e2328700f 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -346,7 +346,7 @@ class Stage(LockableStagingDir):
similar, and are intended to persist for only one run of spack.
"""
- #: Most staging is managed by Spack. DIYStage is one exception.
+ #: Most staging is managed by Spack. DevelopStage is one exception.
needs_fetching = True
requires_patch_success = True
@@ -822,62 +822,6 @@ class StageComposite(pattern.Composite):
item.keep = value
-class DIYStage:
- """
- Simple class that allows any directory to be a spack stage. Consequently,
- it does not expect or require that the source path adhere to the standard
- directory naming convention.
- """
-
- needs_fetching = False
- requires_patch_success = False
-
- def __init__(self, path):
- if path is None:
- raise ValueError("Cannot construct DIYStage without a path.")
- elif not os.path.isdir(path):
- raise StagePathError("The stage path directory does not exist:", path)
-
- self.archive_file = None
- self.path = path
- self.source_path = path
- self.created = True
-
- # DIY stages do nothing as context managers.
- def __enter__(self):
- pass
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- pass
-
- def fetch(self, *args, **kwargs):
- tty.debug("No need to fetch for DIY.")
-
- def check(self):
- tty.debug("No checksum needed for DIY.")
-
- def expand_archive(self):
- tty.debug("Using source directory: {0}".format(self.source_path))
-
- @property
- def expanded(self):
- """Returns True since the source_path must exist."""
- return True
-
- def restage(self):
- raise RestageError("Cannot restage a DIY stage.")
-
- def create(self):
- self.created = True
-
- def destroy(self):
- # No need to destroy DIY stage.
- pass
-
- def cache_local(self):
- tty.debug("Sources for DIY stages are not cached")
-
-
class DevelopStage(LockableStagingDir):
needs_fetching = False
requires_patch_success = False
diff --git a/lib/spack/spack/test/concretize_requirements.py b/lib/spack/spack/test/concretize_requirements.py
index 960ef90a3a..3b3b564691 100644
--- a/lib/spack/spack/test/concretize_requirements.py
+++ b/lib/spack/spack/test/concretize_requirements.py
@@ -103,23 +103,6 @@ def test_repo(_create_test_repo, monkeypatch, mock_stage):
yield mock_repo_path
-class MakeStage:
- def __init__(self, stage):
- self.stage = stage
-
- def __call__(self, *args, **kwargs):
- return self.stage
-
-
-@pytest.fixture
-def fake_installs(monkeypatch, tmpdir):
- stage_path = str(tmpdir.ensure("fake-stage", dir=True))
- universal_unused_stage = spack.stage.DIYStage(stage_path)
- monkeypatch.setattr(
- spack.build_systems.generic.Package, "_make_stage", MakeStage(universal_unused_stage)
- )
-
-
def test_one_package_multiple_reqs(concretize_scope, test_repo):
conf_str = """\
packages:
@@ -514,7 +497,7 @@ packages:
assert s2.satisfies("@2.5")
-def test_reuse_oneof(concretize_scope, _create_test_repo, mutable_database, fake_installs):
+def test_reuse_oneof(concretize_scope, _create_test_repo, mutable_database, mock_fetch):
conf_str = """\
packages:
y:
diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py
index b576a42f68..7bb7f3753a 100644
--- a/lib/spack/spack/test/stage.py
+++ b/lib/spack/spack/test/stage.py
@@ -23,7 +23,7 @@ import spack.stage
import spack.util.executable
import spack.util.url as url_util
from spack.resource import Resource
-from spack.stage import DevelopStage, DIYStage, ResourceStage, Stage, StageComposite
+from spack.stage import DevelopStage, ResourceStage, Stage, StageComposite
from spack.util.path import canonicalize_path
# The following values are used for common fetch and stage mocking fixtures:
@@ -146,9 +146,8 @@ def check_destroy(stage, stage_name):
assert not os.path.exists(stage_path)
# tmp stage needs to remove tmp dir too.
- if not isinstance(stage, DIYStage):
- target = os.path.realpath(stage_path)
- assert not os.path.exists(target)
+ target = os.path.realpath(stage_path)
+ assert not os.path.exists(target)
def check_setup(stage, stage_name, archive):
@@ -801,62 +800,6 @@ class TestStage:
with Stage("file:///does-not-exist", path=testpath) as stage:
assert stage.path == testpath
- def test_diystage_path_none(self):
- """Ensure DIYStage for path=None behaves as expected."""
- with pytest.raises(ValueError):
- DIYStage(None)
-
- def test_diystage_path_invalid(self):
- """Ensure DIYStage for an invalid path behaves as expected."""
- with pytest.raises(spack.stage.StagePathError):
- DIYStage("/path/does/not/exist")
-
- def test_diystage_path_valid(self, tmpdir):
- """Ensure DIYStage for a valid path behaves as expected."""
- path = str(tmpdir)
- stage = DIYStage(path)
- assert stage.path == path
- assert stage.source_path == path
-
- # Order doesn't really matter for DIYStage since they are
- # basically NOOPs; however, call each since they are part
- # of the normal stage usage and to ensure full test coverage.
- stage.create() # Only sets the flag value
- assert stage.created
-
- stage.cache_local() # Only outputs a message
- stage.fetch() # Only outputs a message
- stage.check() # Only outputs a message
- stage.expand_archive() # Only outputs a message
-
- assert stage.expanded # The path/source_path does exist
-
- with pytest.raises(spack.stage.RestageError):
- stage.restage()
-
- stage.destroy() # A no-op
- assert stage.path == path # Ensure can still access attributes
- assert os.path.exists(stage.source_path) # Ensure path still exists
-
- def test_diystage_preserve_file(self, tmpdir):
- """Ensure DIYStage preserves an existing file."""
- # Write a file to the temporary directory
- fn = tmpdir.join(_readme_fn)
- fn.write(_readme_contents)
-
- # Instantiate the DIYStage and ensure the above file is unchanged.
- path = str(tmpdir)
- stage = DIYStage(path)
- assert os.path.isdir(path)
- assert os.path.isfile(str(fn))
-
- stage.create() # Only sets the flag value
-
- readmefn = str(fn)
- assert os.path.isfile(readmefn)
- with open(readmefn) as _file:
- _file.read() == _readme_contents
-
def _create_files_from_tree(base, tree):
for name, content in tree.items():