Skip to content

Commit

Permalink
setup.py tests/: install a pumupdf command that runs fitz/__main__.py.
Browse files Browse the repository at this point in the history
This uses pipcl.py's new `entry_points` support.

Note that direct installation with `setup.py install` does not implement this.

tests/test_general.py: test_cli() - basic test of command-line `pymupdf`
command.

Addresses #3199.
  • Loading branch information
julian-smith-artifex-com committed Feb 27, 2024
1 parent 5caba13 commit 20f35ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions setup.py
Expand Up @@ -1114,6 +1114,13 @@ def sdist():
('Tracker, https://github.com/pymupdf/PyMuPDF/issues'),
('Changelog, https://pymupdf.readthedocs.io/en/latest/changes.html'),
],

# Create a `fitz` command.
entry_points = textwrap.dedent('''
[console_scripts]
pymupdf = fitz.__main__:main
'''),

fn_build=build,
fn_sdist=sdist,

Expand Down
7 changes: 7 additions & 0 deletions tests/test_general.py
Expand Up @@ -916,3 +916,10 @@ def next_fd():
fd2 = next_fd()
assert fd2 == fd1, f'{fd1=} {fd2=}'
os.remove(oldfile)

def test_cli():
if not hasattr(fitz, 'mupdf'):
print('test_cli(): Not running on classic because of fitz_old.')
return
import subprocess
subprocess.run(f'pymupdf -h', shell=1, check=1)

0 comments on commit 20f35ac

Please sign in to comment.