Skip to content

DeprecationWarning: ABCs Collection #20434

@mrmundt

Description

@mrmundt

NOTE: Spack still functions as intended. I simply want to report the deprecation warning.

I wrote a spack-python script to do some cleanup/setup of spack files in between runs. I wrote a few unittests for my script, and when I ran them, I got these deprecation warnings:

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 spack/lib/spack/llnl/util/lang.py:267: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    class HashableMap(collections.MutableMapping):

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 /spack/lib/spack/llnl/util/filesystem.py:1171: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    class FileList(collections.Sequence):

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 /spack/lib/spack/external/ruamel/yaml/comments.py:12: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    from collections import MutableSet

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 /spack/lib/spack/llnl/util/lang.py:192: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    if not isinstance(args, collections.Hashable):

tests/test_cleanup.py::test_SpackCleanup::test_external_find
 /spack/lib/spack/spack/spec.py:2073: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    assert isinstance(self.extra_attributes, collections.Mapping), msg

Steps to reproduce the issue

The script is rather long, so I'll give you a piece of it:

def spack_compiler_find():
    """
    Enable spack to find compilers.

    """
    from spack.main import SpackCommand
    compiler = SpackCommand('compiler')
    compiler('find')
    logger.info("'spack compiler find' has been triggered.")

The test:

import unittest
from .cleanup import spack_compiler_find
import os
import shutil

class test_SpackCleanup(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        if not os.path.isdir(os.path.expanduser('~/.spack')):
            os.mkdir(os.path.expanduser('~/.spack'))

    @classmethod
    def tearDownClass(cls):
        if os.path.isdir(os.path.expanduser('~/.spack')):
            shutil.rmtree(os.path.expanduser('~/.spack'))

    def test_compiler_find(self):
        spack_compiler_find()
        self.assertTrue(os.path.isdir(os.path.expanduser('~/.spack')))

Error Message

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 spack/lib/spack/llnl/util/lang.py:267: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    class HashableMap(collections.MutableMapping):

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 /spack/lib/spack/llnl/util/filesystem.py:1171: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    class FileList(collections.Sequence):

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 /spack/lib/spack/external/ruamel/yaml/comments.py:12: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    from collections import MutableSet

tests/test_cleanup.py::test_SpackCleanup::test_compiler_find
 /spack/lib/spack/llnl/util/lang.py:192: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    if not isinstance(args, collections.Hashable):

tests/test_cleanup.py::test_SpackCleanup::test_external_find
 /spack/lib/spack/spack/spec.py:2073: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    assert isinstance(self.extra_attributes, collections.Mapping), msg

Information on your system

* **Spack:** 0.16.0-247-86f006ffa
* **Python:** 3.8.5
* **Platform:** darwin-catalina-skylake
* **Concretizer:** original

Additional information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output (Not Applicable)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriageThe issue needs to be prioritized

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions