From c152e558e948a53d5c206835a027194386c5eb8c Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Fri, 27 Aug 2021 11:10:03 +0200 Subject: Make `SpecBuildInterface` pickleable (#25628) * Add a __reduce__ method to SpecBuildInterface This class was confusing pickle when being serialized, due to its scary nature of being an object that disguise as another type. * Add more MacOS tests, switch them to clingo * Fix condition syntax * Remove Python v3.6 and v3.9 with macOS --- lib/spack/spack/spec.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index af282e4425..7ab0ffa5fd 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1019,7 +1019,9 @@ class SpecBuildInterface(lang.ObjectWrapper): def __init__(self, spec, name, query_parameters): super(SpecBuildInterface, self).__init__(spec) - + # Adding new attributes goes after super() call since the ObjectWrapper + # resets __dict__ to behave like the passed object + self.token = spec, name, query_parameters is_virtual = spack.repo.path.is_virtual(name) self.last_query = QueryState( name=name, @@ -1027,6 +1029,9 @@ class SpecBuildInterface(lang.ObjectWrapper): isvirtual=is_virtual ) + def __reduce__(self): + return SpecBuildInterface, self.token + @lang.lazy_lexicographic_ordering(set_hash=False) class Spec(object): -- cgit v1.2.3-70-g09d2