From 44fe4c3f636d0147216786e9a67c1777f49ef5a5 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Mon, 18 Nov 2024 13:06:56 +0000 Subject: [PATCH] scripts/: default to not installing system packages such as valgrind by default. --- scripts/gh_release.py | 2 +- scripts/test.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/gh_release.py b/scripts/gh_release.py index b834df4c0..28bb77b88 100755 --- a/scripts/gh_release.py +++ b/scripts/gh_release.py @@ -231,7 +231,7 @@ def get_bool(name, default=0): if platform.system() == 'Linux' and inputs_wheels_linux_pyodide: # Pyodide wheels are built by running scripts/test.py, not # cibuildwheel. - command = f'{sys.executable} scripts/test.py' + command = f'{sys.executable} scripts/test.py -P 1' if inputs_PYMUPDF_SETUP_MUPDF_BUILD: command += f' -m {shlex.quote(inputs_PYMUPDF_SETUP_MUPDF_BUILD)}' command += ' pyodide_wheel' diff --git a/scripts/test.py b/scripts/test.py index ec12cde6e..656cf4737 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -62,6 +62,9 @@ specified PyMuPDF will download its default mupdf .tgz.] -p Set pytest options; default is ''. + -P 0|1 + If 1, automatically install required packages such as Valgrind. Default + is 0. -s 0 | 1 If 1 (the default), build with Python Limited API/Stable ABI. -t @@ -174,6 +177,7 @@ def main(argv): pytest_k = None system_site_packages = False pyodide_build_version = None + packages = False options = os.environ.get('PYMUDF_SCRIPTS_TEST_options', '') options = shlex.split(options) @@ -210,7 +214,9 @@ def main(argv): elif arg == '-k': pytest_k = next(args) elif arg == '-p': - pytest_options = next(args) + packages = int(next(args)) + elif arg == '-P': + packages = int(next(args)) elif arg == '-s': value = next(args) assert value in ('0', '1'), f'`-s` must be followed by `0` or `1`, not {value=}.' @@ -289,6 +295,7 @@ def do_test(): test_fitz=test_fitz, pytest_k=pytest_k, pybind=pybind, + packages=packages, ) for command in commands: @@ -630,6 +637,7 @@ def test( test_fitz=True, pytest_k=None, pybind=False, + packages=False, ): ''' Args: @@ -737,9 +745,10 @@ def getmtime(path): run_compound_args += f' -t {timeout}' env_extra = None if valgrind: - log('Installing valgrind.') - run(f'sudo apt update') - run(f'sudo apt install --upgrade valgrind') + if packages: + log('Installing valgrind.') + run(f'sudo apt update') + run(f'sudo apt install --upgrade valgrind') run(f'valgrind --version') log('Running PyMuPDF tests under valgrind.')