From 72e1546c2cbecbd1fbfff1345a20a0597a158e8a Mon Sep 17 00:00:00 2001 From: Nils Leo Date: Fri, 3 Jul 2026 00:07:36 +0200 Subject: [PATCH] fix: enable unrar on all distros, not just Fedora (#1376) * fix: enable unrar on all distros, not just Fedora unrar was gated behind distro.id() == 'fedora', so on Debian/Ubuntu the binary was installed but never invoked. Try unrar unconditionally after 7z, with an optional rarfile Python fallback. Fixes CBR extraction on non-Fedora Linux distributions. * fix: gate unrar on Linux and drop unused distro dependency Debian/Ubuntu's '7zip' package ships the upstream 7zz binary, which excludes RAR support for licensing reasons, so 7z fails to read .cbr (RAR) archives. unrar was installed but only invoked when distro.id() == 'fedora', so on Debian it was never tried and extraction failed. Per maintainer feedback, gate unrar on platform.system() == 'Linux' (not needed on Windows or macOS) and drop the rarfile PyPI fallback to avoid a new dependency. Since the code no longer imports distro, also remove it from the requirements files and setup.py. --- kindlecomicconverter/comicarchive.py | 13 ++++++------- requirements-docker.txt | 1 - requirements-osx-legacy.txt | 1 - requirements-win7.txt | 1 - requirements.txt | 1 - setup.py | 1 - 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/kindlecomicconverter/comicarchive.py b/kindlecomicconverter/comicarchive.py index 0acfc76..c4bb853 100644 --- a/kindlecomicconverter/comicarchive.py +++ b/kindlecomicconverter/comicarchive.py @@ -22,7 +22,6 @@ from functools import cached_property, lru_cache import os from pathlib import Path import platform -import distro from subprocess import STDOUT, PIPE, CalledProcessError from xml.dom.minidom import parseString from xml.parsers.expat import ExpatError @@ -41,12 +40,12 @@ class ComicArchive: self.dirname, self.basename = os.path.split(filepath) @cached_property - def type(self): + def type(self): extraction_commands = [ [SEVENZIP, 'l', '-y', '-p1', self.basename], ] - if distro.id() == 'fedora' or distro.like() == 'fedora': + if platform.system() == 'Linux': extraction_commands.append( ['unrar', 'l', '-y', '-p1', self.basename], ) @@ -85,20 +84,20 @@ class ComicArchive: extraction_commands.reverse() - if distro.id() == 'fedora' or distro.like() == 'fedora': + if platform.system() == 'Linux': extraction_commands.append( ['unrar', 'x', '-y', '-x__MACOSX', '-x.DS_Store', '-xthumbs.db', '-xThumbs.db', self.basename, targetdir] ) - + for cmd in extraction_commands: try: subprocess_run(cmd, capture_output=True, check=True, cwd=self.dirname) - return targetdir + return targetdir except FileNotFoundError: missing.append(cmd[0]) except CalledProcessError: pass - + if missing: raise OSError(f'Extraction failed, install specialized extraction software. ') else: diff --git a/requirements-docker.txt b/requirements-docker.txt index 8e5d5fa..da6a8c5 100644 --- a/requirements-docker.txt +++ b/requirements-docker.txt @@ -5,7 +5,6 @@ python-slugify>=8.0.4 packaging>=26.2 mozjpeg-lossless-optimization>=1.2.0 natsort>=8.4.0 -distro>=1.9.0 # Below requirements are compiled in Dockefile # numpy==2.3.4 # PyMuPDF==1.26.6 \ No newline at end of file diff --git a/requirements-osx-legacy.txt b/requirements-osx-legacy.txt index c620399..701b28f 100644 --- a/requirements-osx-legacy.txt +++ b/requirements-osx-legacy.txt @@ -6,6 +6,5 @@ python-slugify>=8.0.4 packaging>=26.2 mozjpeg-lossless-optimization>=1.2.0 natsort>=8.4.0 -distro>=1.9.0 numpy<2 PyMuPDF==1.25.5 diff --git a/requirements-win7.txt b/requirements-win7.txt index 346c1af..cbd2fe2 100644 --- a/requirements-win7.txt +++ b/requirements-win7.txt @@ -6,6 +6,5 @@ python-slugify>=8.0.4 packaging>=26.2 mozjpeg-lossless-optimization>=1.2.0 natsort>=8.4.0 -distro>=1.9.0 numpy==1.23.5 PyMuPDF>=1.16 diff --git a/requirements.txt b/requirements.txt index 0b51a8e..e7c867f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,5 @@ python-slugify>=8.0.4,<9.0.0 packaging>=26.2 mozjpeg-lossless-optimization>=1.2.0 natsort>=8.4.0 -distro>=1.9.0 numpy>=1.22.4 PyMuPDF>=1.18.0 diff --git a/setup.py b/setup.py index daf2276..385329a 100644 --- a/setup.py +++ b/setup.py @@ -155,7 +155,6 @@ setuptools.setup( 'python-slugify>=1.2.1,<9.0.0', 'mozjpeg-lossless-optimization>=1.2.0', 'natsort>=8.4.0', - 'distro>=1.8.0', 'numpy>=1.22.4', 'packaging>=23.2', 'PyMuPDF>=1.16.1',