mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-30 18:52:38 +02:00
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:
parent
c22f945614
commit
f61097e9b3
1 changed files with 43 additions and 0 deletions
43
install/linux/vendor-pymupdf.py
Executable file
43
install/linux/vendor-pymupdf.py
Executable 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())
|
Loading…
Reference in a new issue