Skip to content

Commit fa13f22

Browse files
scripts/: default to not installing system packages such as valgrind by default.
This avoids possibly unwelcome use of sudo.
1 parent 6d780c4 commit fa13f22

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

scripts/gh_release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def get_bool(name, default=0):
231231
if platform.system() == 'Linux' and inputs_wheels_linux_pyodide:
232232
# Pyodide wheels are built by running scripts/test.py, not
233233
# cibuildwheel.
234-
command = f'{sys.executable} scripts/test.py'
234+
command = f'{sys.executable} scripts/test.py -P 1'
235235
if inputs_PYMUPDF_SETUP_MUPDF_BUILD:
236236
command += f' -m {shlex.quote(inputs_PYMUPDF_SETUP_MUPDF_BUILD)}'
237237
command += ' pyodide_wheel'

scripts/test.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
specified PyMuPDF will download its default mupdf .tgz.]
6363
-p <pytest-options>
6464
Set pytest options; default is ''.
65+
-P 0|1
66+
If 1, automatically install required packages such as Valgrind. Default
67+
is 0.
6568
-s 0 | 1
6669
If 1 (the default), build with Python Limited API/Stable ABI.
6770
-t <names>
@@ -174,6 +177,7 @@ def main(argv):
174177
pytest_k = None
175178
system_site_packages = False
176179
pyodide_build_version = None
180+
packages = False
177181

178182
options = os.environ.get('PYMUDF_SCRIPTS_TEST_options', '')
179183
options = shlex.split(options)
@@ -210,7 +214,9 @@ def main(argv):
210214
elif arg == '-k':
211215
pytest_k = next(args)
212216
elif arg == '-p':
213-
pytest_options = next(args)
217+
pytest_options = next(args)
218+
elif arg == '-P':
219+
packages = int(next(args))
214220
elif arg == '-s':
215221
value = next(args)
216222
assert value in ('0', '1'), f'`-s` must be followed by `0` or `1`, not {value=}.'
@@ -289,6 +295,7 @@ def do_test():
289295
test_fitz=test_fitz,
290296
pytest_k=pytest_k,
291297
pybind=pybind,
298+
packages=packages,
292299
)
293300

294301
for command in commands:
@@ -630,6 +637,7 @@ def test(
630637
test_fitz=True,
631638
pytest_k=None,
632639
pybind=False,
640+
packages=False,
633641
):
634642
'''
635643
Args:
@@ -737,9 +745,10 @@ def getmtime(path):
737745
run_compound_args += f' -t {timeout}'
738746
env_extra = None
739747
if valgrind:
740-
log('Installing valgrind.')
741-
run(f'sudo apt update')
742-
run(f'sudo apt install --upgrade valgrind')
748+
if packages:
749+
log('Installing valgrind.')
750+
run(f'sudo apt update')
751+
run(f'sudo apt install --upgrade valgrind')
743752
run(f'valgrind --version')
744753

745754
log('Running PyMuPDF tests under valgrind.')

0 commit comments

Comments
 (0)