summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2021-05-15 09:19:10 -0700
committerGitHub <noreply@github.com>2021-05-15 10:19:10 -0600
commit2202ce27fa03010630ab81ea5d8679503346cf7a (patch)
tree5ab61f17be986cc5813932579d58110bcb176f2a /lib
parent2a7fa295fbf615deea518cdd9936f0a0ef8623cc (diff)
downloadspack-2202ce27fa03010630ab81ea5d8679503346cf7a.tar.gz
spack-2202ce27fa03010630ab81ea5d8679503346cf7a.tar.bz2
spack-2202ce27fa03010630ab81ea5d8679503346cf7a.tar.xz
spack-2202ce27fa03010630ab81ea5d8679503346cf7a.zip
do not sort projections alphabetically (#23649)
* do not sort projections alphabetically * add assertion for ordered dict
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index a37cad8633..979e14e8c9 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -9,6 +9,7 @@ import sys
import shutil
import copy
import six
+import ruamel.yaml as yaml
from ordereddict_backport import OrderedDict
@@ -478,9 +479,12 @@ class ViewDescriptor(object):
def to_dict(self):
ret = syaml.syaml_dict([('root', self.root)])
if self.projections:
- projections_dict = syaml.syaml_dict(
- sorted(self.projections.items()))
- ret['projections'] = projections_dict
+ # projections guaranteed to be ordered dict if true-ish
+ # for python2.6, may be syaml or ruamel.yaml implementation
+ # so we have to check for both
+ types = (OrderedDict, syaml.syaml_dict, yaml.comments.CommentedMap)
+ assert isinstance(self.projections, types)
+ ret['projections'] = self.projections
if self.select:
ret['select'] = self.select
if self.exclude: