install: Add script for vendoring PyMuPDF

Add a script that installs PyMuPDF under ./dangerzone/vendor. This will
be useful in subsequent commits, for vendoring PyMuPDF when building
Debian packages.
This commit is contained in:
Alex Pyrgiotis 2024-10-07 14:41:52 +03:00
parent c22f945614
commit f61097e9b3
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

43
install/linux/vendor-pymupdf.py Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env python3
import argparse
import subprocess
import sys
from pathlib import Path
DZ_VENDOR_DIR = Path("./dangerzone/vendor")
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--dest",
default=DZ_VENDOR_DIR,
help="The destination directory for the vendored packages (default: ./dangerzone/vendor)",
)
args = parser.parse_args()
print(">>> Getting PyMuPDF deps as requirements.txt", file=sys.stderr)
cmd = ["poetry", "export", "--only", "container"]
container_requirements_txt = subprocess.check_output(cmd)
print(f">>> Vendoring PyMuPDF under '{args.dest}'", file=sys.stderr)
cmd = [
"python3",
"-m",
"pip",
"install",
"--no-cache-dir",
"--no-compile",
"-t",
args.dest,
"-r",
"/proc/self/fd/0", # XXX: pip does not read requirements.txt from stdin
]
subprocess.check_output(cmd, input=container_requirements_txt)
print(f">>> Successfully vendored PyMuPDF under '{args.dest}'", file=sys.stderr)
if __name__ == "__main__":
sys.exit(main())