Skip to content

Commit

Permalink
app-text/fiction-dl: Patch to drop PyMuPDF dependency; mask PyMuPDF.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjon3377 committed Dec 28, 2024
1 parent 3294877 commit e5dd91f
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app-text/fiction-dl/Manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
AUX fiction-dl-1.8.3-drop-pdf.patch 5347 BLAKE2B e36f78f8431f9e4a28f1f8ee01dfd67538148d4de877282cdc8463fd0eaa7f6ae26de029ff0febc93a8907ec5e68c018389545f138e58555e1c473c0376e161c SHA512 b614021f3a42c685b3f5def14b7d7924710c2022962adce805edfe1362fde7b3f55681e6c7cbd6905240da5dd320726c44d89fd06b5e7dc085039036cd53aefc
DIST fiction-dl-1.8.2.tar.gz 92700 BLAKE2B af4fd583994e5699a394730c776f6db8d1c04baf022712be5cb56671877f8fedd512e7fd56e685f836a52da4391d5163828013b42d27adc83430f7ecd0fe2e75 SHA512 672dfd254d250ccfb1e4d3c5a63c5d7eff3761c93c77bbdca7540762c5db6373fd4c969a271ca8e266f53435038d28e977f48184e26bd4af0294173f1a0b0d90
DIST fiction-dl-1.8.3.tar.gz 92914 BLAKE2B 8365d9756c6249aa5085156c15a399706dda313ea55e167c98e3a01b03c6e4bed547261e24425487ec38dd115c977c3afc48e8adcfdbff49ed2670bcb2900a94 SHA512 1e85c0db87c6ceaeb26917264cec36db349b9edac5c5ed78237213b7df60485c7c06a68c38345191138aa4dfc41bda1ff02a42d77989751a5cf18b2ff1c99307
EBUILD fiction-dl-1.8.2.ebuild 1257 BLAKE2B d82fdee20730f04fcc79c0d9cb63cc83a3af396e2309c9f6fc0bc6767ed167d307230954f7dec91ea6d0892ad7eabdcbb08d0b302294296025c00e3bedb6f0dc SHA512 76c998566d07c7e284a2d8eafd0bddcb4cb18bcc5a3d04c010ecdd0a0e60a90e9edab4ff302b7a5b96bc0a89c082e382c1c16399fe8c31c160b680bc7fa2a588
EBUILD fiction-dl-1.8.3.ebuild 1418 BLAKE2B ece4bf79f2592cacf728382565e0ac296827c0abfb04e9aceeac63c75532c7a5c1bfe90204ecf95201f3e875512b05f794528a73651a9650b37fc481c8305b2e SHA512 16ca0a986ea78a41f2adbfadbec1ed4c1c66979535e85fb56121103913addb4e9697e405b2606ec118f1e27e9b8ca43dce64a315a78405c2f226b09aa32b9f86
EBUILD fiction-dl-1.8.3-r1.ebuild 1456 BLAKE2B af665f5303bd0e6cea1e4bf5c4fc69d7d96a2abd5f42b3b82fd219d97f2357bee47bf23fd5a7065aacfdaecedce78d5c131e50265cd843f5f5fd856385882959 SHA512 1585a8a0b8701464541ab29ba1337f3d18ef0bc1f4d735ff2d2cd9dab241dd197b306de13f9da492bb7052d7dba6567781d2ce5dbed5c74e2e7253f912333d99
MISC metadata.xml 379 BLAKE2B fd6116574361bed0b3fb592cf3ca87cb4f48b012d51116cfcb28fa0857cdffdfe337a987b6b7b412489d0c781055f95cb302de082a28532069b324016e04580b SHA512 8ef829c0b3fd911889438005eaf199d7e6ac87d2e6bbf6d662848f99246863283baf394a58c42e8f5e9b9474a843f0a9d90ae27780af59170d3a5fbbae35eaef
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ KEYWORDS="~amd64" # no ~x86 because not present in cloudscraper

DEPEND="dev-python/Dreamy-Utilities[${PYTHON_USEDEP}]"
RDEPEND="${DEPEND}
dev-python/PyMuPDF[${PYTHON_USEDEP}]
dev-python/bleach[${PYTHON_USEDEP}]
dev-python/beautifulsoup4[${PYTHON_USEDEP}]
dev-python/ebooklib[${PYTHON_USEDEP}]
Expand All @@ -34,10 +33,12 @@ RDEPEND="${DEPEND}
dev-python/pykakasi[${PYTHON_USEDEP}]
dev-python/pyopenssl[${PYTHON_USEDEP}]"

# N.B. without this patch, depends on PyMuPDF for PDF output; we patch to drop
# that feature because building PyMuPDF against a system install of mupdf has
# been failing for some time now.
PATCHES=( "${FILESDIR}/${P}-drop-pdf.patch" )

src_prepare() {
sed -i -e '/opencv-python/d' -e 's@bs4@beautifulsoup4@' setup.py ${PN/-/_}.egg-info/requires.txt || die
sed -i -e 's/loadPage/load_page/' -e 's/getPixmap/get_pixmap/' \
-e 's/getImageData/tobytes/' \
fiction_dl/Utilities/General.py || die # PyMuPDF API changed
default
}
167 changes: 167 additions & 0 deletions app-text/fiction-dl/files/fiction-dl-1.8.3-drop-pdf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
diff --git a/fiction_dl/Core/Application.py b/b/fiction_dl/Core/Application.py
index 75cede1..501bb96 100644
--- a/fiction_dl/Core/Application.py
+++ b/fiction_dl/Core/Application.py
@@ -39,11 +39,9 @@ from fiction_dl.Formatters.FormatterEPUB import FormatterEPUB
from fiction_dl.Formatters.FormatterHTML import FormatterHTML
from fiction_dl.Formatters.FormatterMOBI import FormatterMOBI
from fiction_dl.Formatters.FormatterODT import FormatterODT
-from fiction_dl.Formatters.FormatterPDF import FormatterPDF
from fiction_dl.Processors.SanitizerProcessor import SanitizerProcessor
from fiction_dl.Processors.TypographyProcessor import TypographyProcessor
from fiction_dl.Utilities.Extractors import CreateExtractor
-from fiction_dl.Utilities.General import RenderPDFPageToBytes
from fiction_dl.Utilities.HTML import FindImagesInCode, MakeURLAbsolute
from fiction_dl.Utilities.Text import GetPrintableStoryTitle, Transliterate
import fiction_dl. Configuration as Configuration
@@ -565,33 +563,6 @@ class Application:

self._interface.Text("Output file already exists.")

- # Format and save the stories to PDF.
-
- self._interface.Comment("Saving as PDF... ", end = "")
-
- coverImageData = None
-
- formatter = FormatterPDF(self._arguments.Images)
-
- if not self._arguments.LibreOffice.is_file():
-
- self._interface.Text("This output format is unavailable.")
-
- elif not filePaths["PDF"].is_file():
-
- if not formatter.ConvertFromODT(filePaths["ODT"], filePaths["PDF"].parent, self._arguments.LibreOffice):
- self._interface.Text("Failed!")
-
- else:
- self._interface.Text("Done!")
-
- else:
-
- self._interface.Text("Output file already exists.")
-
- if filePaths["PDF"].is_file():
- coverImageData = RenderPDFPageToBytes(filePaths["PDF"], 0)
-
# Format and save the stories to EPUB.

self._interface.Comment("Saving as EPUB... ", end = "")
@@ -689,7 +660,6 @@ class Application:
"Directory": outputDirectoryPath,
"HTML" : outputDirectoryPath / (sanitizedTitle + ".html"),
"ODT" : outputDirectoryPath / (sanitizedTitle + ".odt" ),
- "PDF" : outputDirectoryPath / (sanitizedTitle + ".pdf" ),
"EPUB" : outputDirectoryPath / (sanitizedTitle + ".epub"),
"MOBI" : outputDirectoryPath / (sanitizedTitle + ".mobi"),
}
@@ -704,10 +674,4 @@ class Application:
"be generated."
)

- if not self._arguments.LibreOffice.is_file():
- notices.append(
- "\"LibreOffice\" doesn't seem to be installed on this machine. PDF output files will "
- "not be generated."
- )
-
- return notices
\ No newline at end of file
+ return notices
diff --git a/fiction_dl/Utilities/General.py b/a/fiction_dl/Utilities/General.py
deleted file mode 100644
index bd63d4b..0000000
--- a/fiction_dl/Utilities/General.py
+++ /dev/null
@@ -1,61 +0,0 @@
-####
-#
-# fiction-dl
-# Copyright (C) (2020 - 2021) Benedykt Synakiewicz <[email protected]>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-####
-
-#
-#
-#
-# Imports.
-#
-#
-#
-
-# Standard packages.
-
-from pathlib import Path
-
-# Non-standard packages.
-
-import fitz
-
-#
-#
-#
-# Functions.
-#
-#
-#
-
-def RenderPDFPageToBytes(documentFilePath: Path, pageIndex: int) -> bytes:
-
- ##
- #
- # Renders given page of a PDF document to image, then returns the image data.
- #
- # @param documentFilePath The path to the document in question.
- # @param pageIndex Index of the page to be rendered.
- #
- # @return Encoded image data, in JPEG format.
- #
- ##
-
- document = fitz.open(documentFilePath)
- page = document.loadPage(pageIndex)
-
- return page.getPixmap().getImageData(output = "jpeg")
\ No newline at end of file
diff --git a/fiction_dl.egg-info/requires.txt b/b/fiction_dl.egg-info/requires.txt
index ec2afd2..194bc9f 100644
--- a/fiction_dl.egg-info/requires.txt
+++ b/fiction_dl.egg-info/requires.txt
@@ -1,4 +1,3 @@
-PyMuPDF
bleach
bs4
dreamy-utilities>=1.2.0
diff --git a/setup.py b/b/setup.py
index 1d43491..2100e07 100644
--- a/setup.py
+++ b/setup.py
@@ -61,7 +61,6 @@ setup(
url = Configuration.ApplicationURL,

install_requires = [
- "PyMuPDF",
"bleach",
"bs4",
"dreamy-utilities>=1.2.0",
@@ -123,4 +122,4 @@ setup(

python_requires = ">=3.8",

-)
\ No newline at end of file
+)
5 changes: 5 additions & 0 deletions profiles/package.mask
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ media-sound/gwc
# Fails to build; later version builds without issue.
=games-strategy/vms-empire-1.15

# Fails to build, TODO: investigate further
dev-python/PyMuPDF
# Depends on PyMuPDF
=app-text/fiction-dl-1.8.2

0 comments on commit e5dd91f

Please sign in to comment.