|
26 | 26 | If set, overrides location of mupdf when building PyMuPDF: |
27 | 27 | Empty string: |
28 | 28 | Build PyMuPDF with the system mupdf. |
| 29 | + A string starting with 'git:': |
| 30 | + Use `git clone` to get a mupdf directory. We use the string in |
| 31 | + the git clone command; it must contain the git URL from which |
| 32 | + to clone, and can also contain other `git clone` args, for |
| 33 | + example: |
| 34 | + PYMUPDF_SETUP_MUPDF_BUILD="git:--branch master https://github.com/ArtifexSoftware/mupdf.git" |
29 | 35 | Otherwise: |
30 | 36 | Location of mupdf directory. |
31 | 37 | |
@@ -454,7 +460,40 @@ def get_mupdf(): |
454 | 460 | log( f'PYMUPDF_SETUP_MUPDF_BUILD="", using system mupdf') |
455 | 461 | return None |
456 | 462 |
|
457 | | - else: |
| 463 | + git_prefix = 'git:' |
| 464 | + if path.startswith( git_prefix): |
| 465 | + # Get git clone of mupdf. |
| 466 | + # |
| 467 | + # `mupdf_url_or_local` is taken to be portion of a `git clone` command, |
| 468 | + # for example: |
| 469 | + # |
| 470 | + # PYMUPDF_SETUP_MUPDF_BUILD="git:--branch master git://git.ghostscript.com/mupdf.git" |
| 471 | + # PYMUPDF_SETUP_MUPDF_BUILD="git:--branch 1.20.x https://github.com/ArtifexSoftware/mupdf.git" |
| 472 | + # PYMUPDF_SETUP_MUPDF_BUILD="git:--branch master https://github.com/ArtifexSoftware/mupdf.git" |
| 473 | + # |
| 474 | + # One would usually also set PYMUPDF_SETUP_MUPDF_TGZ= (empty string) to |
| 475 | + # avoid the need to download a .tgz into an sdist. |
| 476 | + # |
| 477 | + command_suffix = path[ len(git_prefix):] |
| 478 | + path = 'mupdf' |
| 479 | + assert not os.path.exists( path), \ |
| 480 | + f'Cannot use git clone because local directory already exists: {path}' |
| 481 | + command = ('' |
| 482 | + + f'git clone' |
| 483 | + + f' --recursive' |
| 484 | + #+ f' --single-branch' |
| 485 | + #+ f' --recurse-submodules' |
| 486 | + + f' --depth 1' |
| 487 | + + f' --shallow-submodules' |
| 488 | + #+ f' --branch {branch}' |
| 489 | + #+ f' git://git.ghostscript.com/mupdf.git' |
| 490 | + + f' {command_suffix}' |
| 491 | + + f' {path}' |
| 492 | + ) |
| 493 | + log( f'Running: {command}') |
| 494 | + subprocess.run( command, shell=True, check=True) |
| 495 | + |
| 496 | + if 1: |
458 | 497 | # Use custom mupdf directory. |
459 | 498 | log( f'Using custom mupdf directory from $PYMUPDF_SETUP_MUPDF_BUILD: {path}') |
460 | 499 | assert os.path.isdir( path), f'$PYMUPDF_SETUP_MUPDF_BUILD is not a directory: {path}' |
|
0 commit comments