Skip to content

Commit 3fe329a

Browse files
scripts/test.py: improved specification of install version.
We now use `-i <install_version>` to set version to be installed by `install` command. The `install` command now does not take a `<pymupdf>` value. Specifying the implementation (without/without optimisation) is now done with `-I` instead of `-i`.
1 parent e54ed1f commit 3fe329a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

scripts/test.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@
107107
-h
108108
Show help.
109109
110-
-i <implementations>
110+
-I <implementations>
111111
Set PyMuPDF implementations to test.
112112
<implementations> must contain only these individual characters:
113113
'r' - rebased.
114114
'R' - rebased without optimisations.
115115
Default is 'r'. Also see `PyMuPDF:tests/run_compound.py`.
116116
117+
-i <install_version>
118+
Set version installed by the 'install' command.
119+
117120
-k <expression>
118121
Specify which test(s) to run; passed straight through to pytest's `-k`.
119122
For example `-k test_3354`.
@@ -298,6 +301,7 @@ def main(argv):
298301
commands = list()
299302
env_extra = dict()
300303
implementations = 'r'
304+
install_version = None
301305
mupdf_sync = None
302306
os_names = list()
303307
system_packages = False
@@ -393,6 +397,9 @@ def main(argv):
393397
show_help = True
394398

395399
elif arg == '-i':
400+
install_version = next(args)
401+
402+
elif arg == '-I':
396403
implementations = next(args)
397404

398405
elif arg == '-k':
@@ -459,16 +466,12 @@ def main(argv):
459466
venv = int(next(args))
460467
assert venv in (0, 1, 2), f'Invalid {venv=} should be 0, 1 or 2.'
461468

462-
elif arg in ('build', 'cibw', 'pyodide', 'test', 'wheel'):
469+
elif arg in ('build', 'cibw', 'install', 'pyodide', 'test', 'wheel'):
463470
commands.append(arg)
464471

465472
elif arg == 'buildtest':
466473
commands += ['build', 'test']
467474

468-
elif arg == 'install':
469-
_pymupdf = next(args)
470-
commands.append(f'{arg}.{_pymupdf}')
471-
472475
else:
473476
assert 0, f'Unrecognised option/command: {arg=}.'
474477

@@ -530,9 +533,13 @@ def main(argv):
530533
# Build wheel(s) with cibuildwheel.
531534
cibuildwheel(env_extra, cibw_name, cibw_pyodide, cibw_sdist)
532535

533-
elif command.startswith('install.'):
534-
name = command[len('install.'):]
535-
run(f'pip install --force-reinstall {name}')
536+
elif command == 'install':
537+
p = 'pymupdf'
538+
if install_version:
539+
if not install_version.startswith(('==', '>=', '>')):
540+
p = f'{p}=='
541+
p = f'{p}{install_version}'
542+
run(f'pip install --force-reinstall {p}')
536543
have_installed = True
537544

538545
elif command == 'test':

0 commit comments

Comments
 (0)