From 137456fbf3061877f9d6dca2c3a5ddb353128a82 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 20 Jun 2018 10:45:41 -0500 Subject: externals: move spack.util.ordereddict to external/ordereddict_backport --- lib/spack/external/_pytest/fixtures.py | 5 +--- lib/spack/external/ordereddict_backport.py | 40 ++++++++++++++++++++++++++++++ lib/spack/spack/config.py | 2 +- lib/spack/spack/test/conftest.py | 4 +-- lib/spack/spack/util/ordereddict.py | 40 ------------------------------ lib/spack/spack/util/spack_yaml.py | 2 +- 6 files changed, 45 insertions(+), 48 deletions(-) create mode 100644 lib/spack/external/ordereddict_backport.py delete mode 100644 lib/spack/spack/util/ordereddict.py diff --git a/lib/spack/external/_pytest/fixtures.py b/lib/spack/external/_pytest/fixtures.py index b76ad50339..98317a4889 100644 --- a/lib/spack/external/_pytest/fixtures.py +++ b/lib/spack/external/_pytest/fixtures.py @@ -21,10 +21,7 @@ from _pytest.compat import ( from _pytest.outcomes import fail, TEST_OUTCOME -if sys.version_info[:2] == (2, 6): - from ordereddict import OrderedDict -else: - from collections import OrderedDict # nopyqver +from ordereddict_backport import OrderedDict def pytest_sessionstart(session): diff --git a/lib/spack/external/ordereddict_backport.py b/lib/spack/external/ordereddict_backport.py new file mode 100644 index 0000000000..bd21103cdc --- /dev/null +++ b/lib/spack/external/ordereddict_backport.py @@ -0,0 +1,40 @@ +############################################################################## +# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/spack/spack +# Please also see the NOTICE and LICENSE files for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +"""This file dispatches to the correct implementation of OrderedDict.""" + +# TODO: this file can be removed when support for python 2.6 will be dropped + +# Removing this import will make python 2.6 +# fail on import of ordereddict +from __future__ import absolute_import + +import sys + +if sys.version_info[:2] == (2, 6): + import ordereddict + OrderedDict = ordereddict.OrderedDict +else: + import collections + OrderedDict = collections.OrderedDict diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 73738c9ed3..d54dd74d5a 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -57,6 +57,7 @@ import multiprocessing from contextlib import contextmanager from six import string_types from six import iteritems +from ordereddict_backport import OrderedDict import yaml from yaml.error import MarkedYAMLError @@ -69,7 +70,6 @@ import spack.paths import spack.architecture import spack.schema from spack.error import SpackError -from spack.util.ordereddict import OrderedDict # Hacked yaml for configuration files preserves line numbers. import spack.util.spack_yaml as syaml diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 1072513c3c..d1f96451d4 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -28,6 +28,7 @@ import os import shutil import re +import ordereddict_backport import py import pytest @@ -42,7 +43,6 @@ import spack.paths import spack.platforms.test import spack.repo import spack.stage -import spack.util.ordereddict import spack.util.executable import spack.util.pattern from spack.dependency import Dependency @@ -603,7 +603,7 @@ class MockPackage(object): versions=None): self.name = name self.spec = None - self.dependencies = spack.util.ordereddict.OrderedDict() + self.dependencies = ordereddict_backport.OrderedDict() assert len(dependencies) == len(dependency_types) for dep, dtype in zip(dependencies, dependency_types): diff --git a/lib/spack/spack/util/ordereddict.py b/lib/spack/spack/util/ordereddict.py deleted file mode 100644 index bd21103cdc..0000000000 --- a/lib/spack/spack/util/ordereddict.py +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################## -# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. -# Produced at the Lawrence Livermore National Laboratory. -# -# This file is part of Spack. -# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. -# LLNL-CODE-647188 -# -# For details, see https://github.com/spack/spack -# Please also see the NOTICE and LICENSE files for our notice and the LGPL. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License (as -# published by the Free Software Foundation) version 2.1, February 1999. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and -# conditions of the GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -############################################################################## -"""This file dispatches to the correct implementation of OrderedDict.""" - -# TODO: this file can be removed when support for python 2.6 will be dropped - -# Removing this import will make python 2.6 -# fail on import of ordereddict -from __future__ import absolute_import - -import sys - -if sys.version_info[:2] == (2, 6): - import ordereddict - OrderedDict = ordereddict.OrderedDict -else: - import collections - OrderedDict = collections.OrderedDict diff --git a/lib/spack/spack/util/spack_yaml.py b/lib/spack/spack/util/spack_yaml.py index f7adadb980..c02f6c9d04 100644 --- a/lib/spack/spack/util/spack_yaml.py +++ b/lib/spack/spack/util/spack_yaml.py @@ -31,6 +31,7 @@ default unorderd dict. """ +from ordereddict_backport import OrderedDict from six import string_types, StringIO import yaml @@ -41,7 +42,6 @@ from yaml.constructor import ConstructorError from llnl.util.tty.color import colorize, clen, cextra import spack.error -from spack.util.ordereddict import OrderedDict # Only export load and dump __all__ = ['load', 'dump', 'SpackYAMLError'] -- cgit v1.2.3-70-g09d2