From e027d853c2c68240171febbf3828a88d8b2f9834 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Mon, 7 Oct 2024 21:13:49 +0300 Subject: [PATCH] FIXUP: Implement review comments --- dangerzone/__init__.py | 4 +++- debian/rules | 6 +++--- install/linux/vendor-pymupdf.py | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dangerzone/__init__.py b/dangerzone/__init__.py index 1bbab6b..2a232db 100644 --- a/dangerzone/__init__.py +++ b/dangerzone/__init__.py @@ -4,7 +4,9 @@ import sys try: from . import vendor # type: ignore [attr-defined] - sys.path.insert(0, vendor.__path__[0]) + vendor_path = vendor.__path__[0] + print(f"Using vendored PyMuPDF libraries from '{vendor_path}'") + sys.path.insert(0, vendor_path) except ImportError: pass diff --git a/debian/rules b/debian/rules index df1e73b..fbcb611 100755 --- a/debian/rules +++ b/debian/rules @@ -1,9 +1,9 @@ #!/usr/bin/make -f export PYBUILD_NAME=dangerzone export DEB_BUILD_OPTIONS=nocheck -#export PYBUILD_INSTALL_ARGS=--install-lib=/usr/lib/python3/dist-packages -#export PYTHONDONTWRITEBYTECODE=1 -#export DH_VERBOSE=1 +export PYBUILD_INSTALL_ARGS=--install-lib=/usr/lib/python3/dist-packages +export PYTHONDONTWRITEBYTECODE=1 +export DH_VERBOSE=1 %: dh $@ --with python3 --buildsystem=pybuild diff --git a/install/linux/vendor-pymupdf.py b/install/linux/vendor-pymupdf.py index b5b8638..e0234bf 100755 --- a/install/linux/vendor-pymupdf.py +++ b/install/linux/vendor-pymupdf.py @@ -22,16 +22,19 @@ def main(): container_requirements_txt = subprocess.check_output(cmd) print(f">>> Vendoring PyMuPDF under '{args.dest}'", file=sys.stderr) + # We prefer to call the CLI version of `pip`, instead of importing it directly, as + # instructed here: + # https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program cmd = [ - "python3", + sys.executable, "-m", "pip", "install", "--no-cache-dir", "--no-compile", - "-t", + "--target", args.dest, - "-r", + "--requirements", "/proc/self/fd/0", # XXX: pip does not read requirements.txt from stdin ] subprocess.check_output(cmd, input=container_requirements_txt)