diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cb723f6..4249ab9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -80,6 +80,20 @@ jobs: run: | choco install -y zip if: runner.os == 'Windows' + - name: Install macos dependencies + run: | + brew install icu4c pkg-config + export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"; + export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH" + python -m pip install --no-binary=:pyicu: pyicu + if: runner.os == 'macOS' + - name: Install linux dependencies + run: | + sudo apt-get install pkg-config libicu-dev + export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"; + export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH" + python -m pip install --no-binary=:pyicu: pyicu + if: runner.os == 'Linux' - name: Build and install PyPi packages run: | diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index b4987e7..ca88919 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -41,12 +41,25 @@ jobs: run: | choco install -y zip if: runner.os == 'Windows' + - name: Install macos dependencies + run: | + brew install icu4c pkg-config + export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"; + export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH" + python -m pip install --no-binary=:pyicu: pyicu + if: runner.os == 'macOS' + - name: Install linux dependencies + run: | + sudo apt-get install pkg-config libicu-dev + export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"; + export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:$PATH" + python -m pip install --no-binary=:pyicu: pyicu + if: runner.os == 'Linux' - name: Build, Install and Test PyPi packages run: | make clean pydist python -m pip install "dist/$(python setup.py --fullname)-py3-none-any.whl[all]" - echo "CT_FULL_NAME=$(python setup.py --fullname)" >> $GITHUB_ENV python -m flake8 python -m pytest @@ -69,4 +82,4 @@ jobs: draft: false files: | dist/!(*Linux).zip - dist/*.whl + dist/*${{ fromJSON('["never", ""]')[runner.os == 'Linux'] }}.whl diff --git a/comicapi/comicarchive.py b/comicapi/comicarchive.py index e887098..0d850a4 100644 --- a/comicapi/comicarchive.py +++ b/comicapi/comicarchive.py @@ -148,7 +148,7 @@ class SevenZipArchiver(UnknownArchiver): def get_filename_list(self) -> list[str]: try: with py7zr.SevenZipFile(self.path, "r") as zf: - namelist: list[str] = zf.getnames() + namelist: list[str] = [file.filename for file in zf.list() if not file.is_directory] return namelist except (py7zr.Bad7zFile, OSError) as e: @@ -248,7 +248,7 @@ class ZipArchiver(UnknownArchiver): def get_filename_list(self) -> list[str]: try: with zipfile.ZipFile(self.path, mode="r") as zf: - namelist = zf.namelist() + namelist = [file.filename for file in zf.infolist() if not file.is_dir()] return namelist except (zipfile.BadZipfile, OSError) as e: logger.error("Error listing files in zip archive [%s]: %s", e, self.path) @@ -934,7 +934,7 @@ class ComicArchive: # seems like some archive creators are on Windows, and don't know about case-sensitivity! if sort_list: - files = cast(list[str], natsort.natsorted(files, alg=natsort.ns.IC | natsort.ns.I | natsort.ns.U)) + files = cast(list[str], natsort.os_sorted(files)) # make a sub-list of image files self.page_list = [] diff --git a/requirements.txt b/requirements.txt index 0084ebd..2f88c88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ pathvalidate pillow>=9.1.0 py7zr pycountry +pyicu; sys_platform == 'linux' or sys_platform == 'darwin' requests==2.* text2digits thefuzz>=0.19.0 diff --git a/testing/data/Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz b/testing/data/Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz index a228fd0..e12d05b 100644 Binary files a/testing/data/Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz and b/testing/data/Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz differ diff --git a/testing/data/fake_cbr.cbr b/testing/data/fake_cbr.cbr index 1157aec..50f2aed 100644 Binary files a/testing/data/fake_cbr.cbr and b/testing/data/fake_cbr.cbr differ diff --git a/tests/comicarchive_test.py b/tests/comicarchive_test.py index 27b3cb2..0f1aadf 100644 --- a/tests/comicarchive_test.py +++ b/tests/comicarchive_test.py @@ -15,6 +15,8 @@ def test_getPageNameList(): pageNameList = c.get_page_name_list() assert pageNameList == [ + "!cover.jpg", + "00.jpg", "page0.jpg", "Page1.jpeg", "Page2.png",