Skip to content

aifc module is deprecated (and removed in Python 3.13) #144

@mgorny

Description

@mgorny

This package still uses the aifc module that is deprecated since Python 3.11, and was removed in Python 3.13.

As a result, the test suite fails with 3.13.0b2:

$ tox -e py313
py313: install_deps> python -I -m pip install pytest
.pkg: _optional_hooks> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True flit_core.buildapi
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True flit_core.buildapi
.pkg: build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True flit_core.buildapi
py313: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/audioread/.tox/.tmp/package/2/audioread-3.0.2.tar.gz
py313: commands[0]> pytest
========================================================= test session starts =========================================================
platform linux -- Python 3.13.0b2, pytest-8.2.2, pluggy-1.5.0
cachedir: .tox/py313/.pytest_cache
rootdir: /tmp/audioread
configfile: pyproject.toml
collected 4 items                                                                                                                     

test/test_audioread.py FFFF                                                                                                     [100%]

============================================================== FAILURES ===============================================================
__________________________________________________ test_audioread_early_exit[test-1] __________________________________________________

audiofile = <conftest.AudiofileSpec object at 0x7efcb006cad0>

    def test_audioread_early_exit(audiofile):
        """Abort the read before it is completed.
    
        This test guards against regressions such as
        https://github.com/beetbox/audioread/pull/78
    
        """
>       with audioread.audio_open(audiofile.path) as a:

test/test_audioread.py:29: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:123: in audio_open
    backends = available_backends()
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:80: in available_backends
    from . import rawread
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    # This file is part of audioread.
    # Copyright 2011, Adrian Sampson.
    #
    # Permission is hereby granted, free of charge, to any person obtaining
    # a copy of this software and associated documentation files (the
    # "Software"), to deal in the Software without restriction, including
    # without limitation the rights to use, copy, modify, merge, publish,
    # distribute, sublicense, and/or sell copies of the Software, and to
    # permit persons to whom the Software is furnished to do so, subject to
    # the following conditions:
    #
    # The above copyright notice and this permission notice shall be
    # included in all copies or substantial portions of the Software.
    
    """Uses standard-library modules to read AIFF, AIFF-C, and WAV files."""
>   import aifc
E   ModuleNotFoundError: No module named 'aifc'

.tox/py313/lib/python3.13/site-packages/audioread/rawread.py:16: ModuleNotFoundError
__________________________________________________ test_audioread_early_exit[test-2] __________________________________________________

audiofile = <conftest.AudiofileSpec object at 0x7efcb001bc50>

    def test_audioread_early_exit(audiofile):
        """Abort the read before it is completed.
    
        This test guards against regressions such as
        https://github.com/beetbox/audioread/pull/78
    
        """
>       with audioread.audio_open(audiofile.path) as a:

test/test_audioread.py:29: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:123: in audio_open
    backends = available_backends()
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:80: in available_backends
    from . import rawread
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    # This file is part of audioread.
    # Copyright 2011, Adrian Sampson.
    #
    # Permission is hereby granted, free of charge, to any person obtaining
    # a copy of this software and associated documentation files (the
    # "Software"), to deal in the Software without restriction, including
    # without limitation the rights to use, copy, modify, merge, publish,
    # distribute, sublicense, and/or sell copies of the Software, and to
    # permit persons to whom the Software is furnished to do so, subject to
    # the following conditions:
    #
    # The above copyright notice and this permission notice shall be
    # included in all copies or substantial portions of the Software.
    
    """Uses standard-library modules to read AIFF, AIFF-C, and WAV files."""
>   import aifc
E   ModuleNotFoundError: No module named 'aifc'

.tox/py313/lib/python3.13/site-packages/audioread/rawread.py:16: ModuleNotFoundError
_____________________________________________________ test_audioread_full[test-1] _____________________________________________________

audiofile = <conftest.AudiofileSpec object at 0x7efcafd8c2d0>

    def test_audioread_full(audiofile):
        """Read the audio data from the file."""
>       with audioread.audio_open(audiofile.path) as a:

test/test_audioread.py:38: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:123: in audio_open
    backends = available_backends()
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:80: in available_backends
    from . import rawread
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    # This file is part of audioread.
    # Copyright 2011, Adrian Sampson.
    #
    # Permission is hereby granted, free of charge, to any person obtaining
    # a copy of this software and associated documentation files (the
    # "Software"), to deal in the Software without restriction, including
    # without limitation the rights to use, copy, modify, merge, publish,
    # distribute, sublicense, and/or sell copies of the Software, and to
    # permit persons to whom the Software is furnished to do so, subject to
    # the following conditions:
    #
    # The above copyright notice and this permission notice shall be
    # included in all copies or substantial portions of the Software.
    
    """Uses standard-library modules to read AIFF, AIFF-C, and WAV files."""
>   import aifc
E   ModuleNotFoundError: No module named 'aifc'

.tox/py313/lib/python3.13/site-packages/audioread/rawread.py:16: ModuleNotFoundError
_____________________________________________________ test_audioread_full[test-2] _____________________________________________________

audiofile = <conftest.AudiofileSpec object at 0x7efcafff7950>

    def test_audioread_full(audiofile):
        """Read the audio data from the file."""
>       with audioread.audio_open(audiofile.path) as a:

test/test_audioread.py:38: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:123: in audio_open
    backends = available_backends()
.tox/py313/lib/python3.13/site-packages/audioread/__init__.py:80: in available_backends
    from . import rawread
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    # This file is part of audioread.
    # Copyright 2011, Adrian Sampson.
    #
    # Permission is hereby granted, free of charge, to any person obtaining
    # a copy of this software and associated documentation files (the
    # "Software"), to deal in the Software without restriction, including
    # without limitation the rights to use, copy, modify, merge, publish,
    # distribute, sublicense, and/or sell copies of the Software, and to
    # permit persons to whom the Software is furnished to do so, subject to
    # the following conditions:
    #
    # The above copyright notice and this permission notice shall be
    # included in all copies or substantial portions of the Software.
    
    """Uses standard-library modules to read AIFF, AIFF-C, and WAV files."""
>   import aifc
E   ModuleNotFoundError: No module named 'aifc'

.tox/py313/lib/python3.13/site-packages/audioread/rawread.py:16: ModuleNotFoundError
======================================================= short test summary info =======================================================
FAILED test/test_audioread.py::test_audioread_early_exit[test-1] - ModuleNotFoundError: No module named 'aifc'
FAILED test/test_audioread.py::test_audioread_early_exit[test-2] - ModuleNotFoundError: No module named 'aifc'
FAILED test/test_audioread.py::test_audioread_full[test-1] - ModuleNotFoundError: No module named 'aifc'
FAILED test/test_audioread.py::test_audioread_full[test-2] - ModuleNotFoundError: No module named 'aifc'
========================================================== 4 failed in 0.08s ==========================================================
py313: exit 1 (0.38 seconds) /tmp/audioread> pytest pid=97746
.pkg: _exit> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True flit_core.buildapi
  py313: FAIL code 1 (5.46=setup[5.08]+cmd[0.38] seconds)
  evaluation failed :( (5.57 seconds)

Activity

added a commit that references this issue on Oct 11, 2024
lucas42

lucas42 commented on Oct 14, 2024

@lucas42

It's worth mentioning that the sunau module is also deprecated and being removed at the same time.
(There was discussion about wave, but looks like they'd decided to keep it in python core)

There's an attempt to make the deprecated libraries available as pip dependencies: https://github.com/youknowone/python-deadlib However, it seems there's currently a couple of issues with that repository which means it won't work with 3.13 yet.

lucas42

lucas42 commented on Oct 14, 2024

@lucas42

I've submitted a pull request to the python-deadlib library to try to get its aifc fork from the python core working on python 3.13: youknowone/python-deadlib#9

Another potential approach would be to handle the ModuleNotFoundError more gracefully here. That would reduce the range of file types supported on python3.13, but is still better than a hard error, even when aifc support isn't needed!

lucas42

lucas42 commented on Oct 30, 2024

@lucas42

The python-deadlib modules have now been fixed up and can be used to replace the missing modules from python core.

So a workaround to this issue is pip install standard-aifc standard-sunau

linked a pull request that will close this issue on Oct 30, 2024
montvid

montvid commented on Dec 7, 2024

@montvid

The library does not build on python 3.12 too Anjok07/ultimatevocalremovergui#1578 (comment)

pipx >(analyze_pip_output:311): pip seemed to fail to build package:
    audioread==3.0.0

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    ModuleNotFoundError: No module named 'imp'
lucas42

lucas42 commented on Dec 8, 2024

@lucas42

@montvid I don't think your error is related to this issue.

Looks like that the imp issue might have been fixed in 3.0.1 (see #136 )
I'd guess ultimatevocalremovergui just needs to update its dependencies to the latest release.

ISSOtm

ISSOtm commented on Jan 3, 2025

@ISSOtm

I wonder if using https://github.com/scientific-python/lazy-loader could help? Then the modules would only be loaded (and thus fail to be found) on demand.

lucas42

lucas42 commented on Jan 3, 2025

@lucas42

@ISSOtm That approach would mean some uses of audioread would work in python 3.13, but others would error. Whilst it's tempting (and would certainly solve my personal use of it), I think it'd cause confusing results to people unfamiliar with the internal implementation. The question of "is this library supported in python 3.13?" would need an answer of "it depends", followed by details of the nuance.
Given the effort needed to introduce lazy-loader, it seems just as simple to fully support python 3.13, and in doing so be much clearer to users of the library.

15 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @mgorny@lucas42@arogl@bmcfee@ISSOtm

      Issue actions

        `aifc` module is deprecated (and removed in Python 3.13) · Issue #144 · beetbox/audioread