Skip to content

Commit 52b102c

Browse files
authored
Add support for Python 3.13 (#6132)
Fixes #5575 Fixes #5822 Fixes #6082 Fixes #6026 ### Python 3.13 compatibility - Updated `librosa` dependency from `^0.10.2.post1` to `>=0.11` where a bug with `numpy` types is fixed. - Updated transitive `audioread` dependency which now pulls in `standard-aifc`, `standard-sunau`, and `audioop-lts` packages for Python 3.13 and above. ### Python 3.14 compatibility - Python 3.14 introduced stricter requirements for input type in low level `fnctl.ioctl` function which we used to detect the terminal width. I replaced it with high-level, cross-platform `shutil.get_terminal_size()`. - I'm not adding official support yet, as I faced many issues trying to install `librosa` dependencies on Python 3.14. It should work fine for people that do not use `autobpm`, and it may even work for those that do - if they have the right set of system dependencies available. We can revise this once we drop Python 3.9 in a couple of days.
2 parents 201677a + cbd74b3 commit 52b102c

File tree

6 files changed

+484
-138
lines changed

6 files changed

+484
-138
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
platform: [ubuntu-latest, windows-latest]
23-
python-version: ["3.9", "3.10", "3.11", "3.12"]
23+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2424
runs-on: ${{ matrix.platform }}
2525
env:
2626
IS_MAIN_PYTHON: ${{ matrix.python-version == '3.9' && matrix.platform == 'ubuntu-latest' }}
@@ -39,7 +39,15 @@ jobs:
3939
if: matrix.platform == 'ubuntu-latest'
4040
run: |
4141
sudo apt update
42-
sudo apt install --yes --no-install-recommends ffmpeg gobject-introspection gstreamer1.0-plugins-base python3-gst-1.0 libcairo2-dev libgirepository-2.0-dev pandoc imagemagick
42+
sudo apt install --yes --no-install-recommends \
43+
ffmpeg \
44+
gobject-introspection \
45+
gstreamer1.0-plugins-base \
46+
python3-gst-1.0 \
47+
libcairo2-dev \
48+
libgirepository-2.0-dev \
49+
pandoc \
50+
imagemagick
4351
4452
- name: Get changed lyrics files
4553
id: lyrics-update

beets/ui/__init__.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import optparse
2424
import os.path
2525
import re
26+
import shutil
2627
import sqlite3
27-
import struct
2828
import sys
2929
import textwrap
3030
import traceback
@@ -699,27 +699,11 @@ def get_replacements():
699699
return replacements
700700

701701

702-
def term_width():
702+
@cache
703+
def term_width() -> int:
703704
"""Get the width (columns) of the terminal."""
704-
fallback = config["ui"]["terminal_width"].get(int)
705-
706-
# The fcntl and termios modules are not available on non-Unix
707-
# platforms, so we fall back to a constant.
708-
try:
709-
import fcntl
710-
import termios
711-
except ImportError:
712-
return fallback
713-
714-
try:
715-
buf = fcntl.ioctl(0, termios.TIOCGWINSZ, " " * 4)
716-
except OSError:
717-
return fallback
718-
try:
719-
height, width = struct.unpack("hh", buf)
720-
except struct.error:
721-
return fallback
722-
return width
705+
columns, _ = shutil.get_terminal_size(fallback=(0, 0))
706+
return columns if columns else config["ui"]["terminal_width"].get(int)
723707

724708

725709
def split_into_lines(string, width_tuple):

beetsplug/lyrics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,9 @@ class Translator(RequestHandler):
745745
TRANSLATE_URL = "https://api.cognitive.microsofttranslator.com/translate"
746746
LINE_PARTS_RE = re.compile(r"^(\[\d\d:\d\d.\d\d\]|) *(.*)$")
747747
SEPARATOR = " | "
748-
remove_translations = partial(re.compile(r" / [^\n]+").sub, "")
748+
remove_translations = staticmethod(
749+
partial(re.compile(r" / [^\n]+").sub, "")
750+
)
749751

750752
_log: Logger
751753
api_key: str

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ New features:
1818
to receive extra verbose logging around last.fm results and how they are
1919
resolved. The ``extended_debug`` config setting and ``--debug`` option
2020
have been removed.
21+
- Added support for Python 3.13.
2122

2223
Bug fixes:
2324

0 commit comments

Comments
 (0)