Truly independent web browser
Meta+test-web: Share a Python environment for linters and tests
Timothy Flynnb2fab801b8f3
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.ymlindex 1472245b7d7..7b3ccda61b6 100644--- a/.github/actions/setup/action.yml+++ b/.github/actions/setup/action.yml@@ -62,26 +62,16 @@ runs:with:python-version: 3.12cache: ${{ inputs.use_caches == 'true' && 'pip' || '' }}+ cache-dependency-path: requirements.txt- # actions/setup-python can fail to find its tool-cache pip inside job containers.+ # Use the system interpreter in Linux job containers: actions/setup-python can+ # fail to find its tool-cache pip there.- name: 'Set up Python environment'- if: ${{ inputs.os == 'Linux' }}shell: bashrun: |- python3 -m venv "${RUNNER_TEMP}/ladybird-python"- echo "${RUNNER_TEMP}/ladybird-python/bin" >> "$GITHUB_PATH"- echo "pythonLocation=${RUNNER_TEMP}/ladybird-python" >> "$GITHUB_ENV"-- - name: 'Install Python dependencies'- shell: bash- run: |- python3 -m pip install --upgrade pip-- if ${{ inputs.type == 'build' }} ; then- pip3 install pyyaml requests six cryptography- else- python3 "${GITHUB_WORKSPACE}/Meta/Linters/run.py"- fi+ python_bin=$(python3 "${GITHUB_WORKSPACE}/Meta/Utils/python_environment.py" --print-bin | tr -d '\r')+ echo "${python_bin}" >> "$GITHUB_PATH"+ echo "pythonLocation=$(dirname "${python_bin}")" >> "$GITHUB_ENV"- name: 'Select latest Xcode'if: ${{ inputs.os == 'macOS' || inputs.os == 'Android' }}diff --git a/Documentation/CodePolicy.md b/Documentation/CodePolicy.mdindex daa33159a59..9b93396fde6 100644--- a/Documentation/CodePolicy.md+++ b/Documentation/CodePolicy.md@@ -74,11 +74,11 @@ Do not use AI-generated descriptions or summaries as a substitute for understandThe repository contains a file called `.pre-commit-config.yaml` that defines several commit hooks that can be run automatically just before and after creating a new commit. These hooks lint your commit message, and the changes it contains to ensure they will pass the automated CI checks.The Python and workflow lint scripts use the versions pinned in-`Meta/Linters/requirements.txt`, including when called by commit hooks or CI.-They prepare a virtual environment under `Build/linters` on first use and reuse-it afterward. Python with `venv` and `pip` support is required; the first setup-downloads the pinned tools. Changing the requirements or Python interpreter-selects a fresh environment. Concurrent invocations share a setup lock.+`requirements.txt` at the repository root, including when called by commit hooks+or CI. They share a virtual environment under `Build/venv` with `test-web`.+Python with `venv` and `pip` support is required; the first setup downloads the+pinned packages. Changing the requirements or Python interpreter selects a fresh+environment. Concurrent invocations share a setup lock.To prepare the environment in advance or run a pinned tool directly:@@ -89,7 +89,8 @@ python3 Meta/Linters/run.py ruff check Meta/ladybird.py```Once prepared, the environment can be reused without downloading the packages-again. Delete `Build/linters` to clear the cache when no linters are running.+again. Delete `Build/venv` to clear the cache when no linters or tests are running,+then rebuild `test-web` before running it again.To enable these hooks, first follow the installation instructions available at https://pre-commit.com/#install and then enable one or both of the following hooks:diff --git a/Meta/CMake/python_environment.cmake b/Meta/CMake/python_environment.cmakenew file mode 100644index 00000000000..4787a5b7a2b--- /dev/null+++ b/Meta/CMake/python_environment.cmake@@ -0,0 +1,35 @@+include_guard()++set(python_environment_script "${LADYBIRD_SOURCE_DIR}/Meta/Utils/python_environment.py")+set(python_requirements "${LADYBIRD_SOURCE_DIR}/requirements.txt")++set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${python_environment_script}" "${python_requirements}")++# CI may configure with the managed interpreter. Use its base Python for setup, so recreating the environment does not+# remove the interpreter running setup.+execute_process(+ COMMAND "${Python3_EXECUTABLE}" -c "import os, sys; print(os.path.realpath(getattr(sys, '_base_executable', sys.executable)))"+ OUTPUT_VARIABLE python_environment_bootstrap+ OUTPUT_STRIP_TRAILING_WHITESPACE+ COMMAND_ERROR_IS_FATAL ANY+)++# Resolve the content-addressed path without creating the environment during configuration.+execute_process(+ COMMAND "${python_environment_bootstrap}" "${python_environment_script}" --print-python+ OUTPUT_VARIABLE LADYBIRD_TEST_PYTHON+ OUTPUT_STRIP_TRAILING_WHITESPACE+ COMMAND_ERROR_IS_FATAL ANY+)+get_filename_component(python_environment_bin "${LADYBIRD_TEST_PYTHON}" DIRECTORY)+get_filename_component(python_environment "${python_environment_bin}" DIRECTORY)++add_custom_command(+ OUTPUT "${python_environment}/.ready"+ COMMAND "${python_environment_bootstrap}" "${python_environment_script}"+ COMMAND "${CMAKE_COMMAND}" -E touch "${python_environment}/.ready"+ DEPENDS "${python_environment_script}" "${python_requirements}"+ COMMENT "Preparing Python environment for tests and linters"+ VERBATIM+)+add_custom_target(ladybird_python_environment DEPENDS "${python_environment}/.ready")diff --git a/Meta/CMake/targets.cmake b/Meta/CMake/targets.cmakeindex cb712a06ca0..534d055484d 100644--- a/Meta/CMake/targets.cmake+++ b/Meta/CMake/targets.cmake@@ -206,20 +206,23 @@ function(ladybird_test test_src sub_dir)endfunction()function(ladybird_python_test test_src)- cmake_parse_arguments(PARSE_ARGV 1 LADYBIRD_TEST "" "NAME;TIMEOUT" "ARGS;ENVIRONMENT")+ cmake_parse_arguments(PARSE_ARGV 1 LADYBIRD_TEST "" "NAME;TIMEOUT;PYTHON_EXECUTABLE" "ARGS;ENVIRONMENT")if (NOT LADYBIRD_TEST_NAME)get_filename_component(LADYBIRD_TEST_NAME ${test_src} NAME_WE)endif()if (NOT DEFINED LADYBIRD_TEST_TIMEOUT)set(LADYBIRD_TEST_TIMEOUT 120)endif()+ if (NOT LADYBIRD_TEST_PYTHON_EXECUTABLE)+ set(LADYBIRD_TEST_PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")+ endif()list(PREPEND LADYBIRD_TEST_ENVIRONMENT "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}")get_filename_component(test_src "${test_src}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")add_test(NAME ${LADYBIRD_TEST_NAME}- COMMAND ${Python3_EXECUTABLE} "${test_src}" ${LADYBIRD_TEST_ARGS}+ COMMAND "${LADYBIRD_TEST_PYTHON_EXECUTABLE}" "${test_src}" ${LADYBIRD_TEST_ARGS})set_tests_properties(${LADYBIRD_TEST_NAME} PROPERTIESTIMEOUT "${LADYBIRD_TEST_TIMEOUT}"diff --git a/Meta/Linters/requirements.txt b/Meta/Linters/requirements.txtdeleted file mode 100644index 1a583c388cd..00000000000--- a/Meta/Linters/requirements.txt+++ /dev/null@@ -1,3 +0,0 @@-actionlint-py==1.7.12.24-pyright==1.1.411-ruff==0.15.22diff --git a/Meta/Linters/run.py b/Meta/Linters/run.pyindex 39e3db4d833..7bc688ca2c0 100755--- a/Meta/Linters/run.py+++ b/Meta/Linters/run.py@@ -5,74 +5,16 @@# SPDX-License-Identifier: BSD-2-Clauseimport argparse-import hashlibimport os+import pathlibimport subprocessimport sys-import venv-from pathlib import Path+META_SOURCE_DIR = pathlib.Path(__file__).resolve().parent.parent+sys.path.append(str(META_SOURCE_DIR))-def lock_environment(lock_file):- if os.name == "nt":- import errno- import msvcrt- import time-- lock_file.write(b"\0")- lock_file.flush()- lock_file.seek(0)- while True:- try:- msvcrt.locking(lock_file.fileno(), msvcrt.LK_NBLCK, 1)- return- except OSError as error:- if error.errno != errno.EACCES:- raise- time.sleep(0.1)- else:- import fcntl-- fcntl.flock(lock_file, fcntl.LOCK_EX)---def prepare_environment(requirements_path, cache_root):- requirements = requirements_path.read_bytes()- identity = b"\0".join((requirements, sys.version.encode(), os.fsencode(sys.executable), os.fsencode(cache_root)))- environment = cache_root / hashlib.sha256(identity).hexdigest()[:16]- binaries = environment / ("Scripts" if os.name == "nt" else "bin")- python = binaries / ("python.exe" if os.name == "nt" else "python")- ready = environment / ".ready"- if ready.is_file() and python.is_file():- return binaries-- cache_root.mkdir(parents=True, exist_ok=True)- with (cache_root / f"{environment.name}.lock").open("a+b") as lock_file:- lock_environment(lock_file)- if not ready.is_file() or not python.is_file():- print(f"Preparing pinned linters in {environment}", file=sys.stderr, flush=True)- venv.EnvBuilder(with_pip=True, clear=True).create(environment)- # Install the exact snapshot used for the cache key, even if the- # checkout changes while pip is running.- snapshot = environment / "requirements.txt"- snapshot.write_bytes(requirements)- subprocess.run(- [- str(python),- "-m",- "pip",- "install",- "--disable-pip-version-check",- "--require-virtualenv",- "-r",- str(snapshot),- ],- check=True,- stdout=sys.stderr,- )- ready.touch()- return binaries+from Utils.python_environment import prepare_environment # noqa: E402def main():@@ -83,8 +25,7 @@ def main():parser.add_argument("args", nargs=argparse.REMAINDER, help="Arguments passed through to the linter")args = parser.parse_args()- linters = Path(__file__).resolve().parent- binaries = prepare_environment(linters / "requirements.txt", linters.parent.parent / "Build/linters")+ binaries = prepare_environment()if args.tool is None:print(binaries)return 0diff --git a/Meta/Utils/python_environment.py b/Meta/Utils/python_environment.pynew file mode 100755index 00000000000..3b3ca61daaa--- /dev/null+++ b/Meta/Utils/python_environment.py@@ -0,0 +1,117 @@+#!/usr/bin/env python3+#+# Copyright (c) 2026-present, the Ladybird developers.+#+# SPDX-License-Identifier: BSD-2-Clause++import argparse+import hashlib+import os+import subprocess+import sys+import venv++from pathlib import Path+from typing import BinaryIO++LADYBIRD_SOURCE_DIR = Path(__file__).resolve().parent.parent.parent++REQUIREMENTS = LADYBIRD_SOURCE_DIR / "requirements.txt"+CACHE_ROOT = LADYBIRD_SOURCE_DIR / "Build" / "venv"+++def lock_environment(lock_file: BinaryIO) -> None:+ if os.name == "nt":+ import errno+ import msvcrt+ import time++ lock_file.write(b"\0")+ lock_file.flush()+ lock_file.seek(0)++ while True:+ try:+ msvcrt.locking(lock_file.fileno(), msvcrt.LK_NBLCK, 1)+ return+ except OSError as error:+ if error.errno != errno.EACCES:+ raise+ time.sleep(0.1)+ else:+ import fcntl++ fcntl.flock(lock_file, fcntl.LOCK_EX)+++def environment_path(requirements: bytes, cache_root: Path) -> Path:+ # Use the base interpreter so running this script from the managed environment selects the same environment as+ # running it from the system Python.+ interpreter = os.path.realpath(getattr(sys, "_base_executable", sys.executable))+ identity = b"\0".join((requirements, sys.version.encode(), os.fsencode(interpreter), os.fsencode(cache_root)))+ return cache_root / hashlib.sha256(identity).hexdigest()[:16]+++def prepare_environment(requirements_path: Path = REQUIREMENTS, cache_root: Path = CACHE_ROOT) -> Path:+ requirements = requirements_path.read_bytes()+ environment = environment_path(requirements, cache_root)++ binaries = environment / ("Scripts" if os.name == "nt" else "bin")+ python = binaries / ("python.exe" if os.name == "nt" else "python")++ ready = environment / ".ready"+ if ready.is_file() and python.is_file():+ return binaries++ cache_root.mkdir(parents=True, exist_ok=True)+ with (cache_root / f"{environment.name}.lock").open("a+b") as lock_file:+ lock_environment(lock_file)++ if not ready.is_file() or not python.is_file():+ venv.EnvBuilder(with_pip=True, clear=True).create(environment)++ # Install the exact snapshot used for the cache key, even if the checkout changes while pip is running.+ snapshot = environment / "requirements.txt"+ snapshot.write_bytes(requirements)++ subprocess.run(+ [+ str(python),+ "-m",+ "pip",+ "install",+ "--quiet",+ "--quiet",+ "--disable-pip-version-check",+ "--require-virtualenv",+ "--requirement",+ str(snapshot),+ ],+ check=True,+ stdout=sys.stderr,+ )++ ready.touch()++ return binaries+++def main() -> None:+ parser = argparse.ArgumentParser(description="Prepare the shared Python environment for tests and linters.")+ output = parser.add_mutually_exclusive_group()+ output.add_argument("--print-python", action="store_true", help="Print the interpreter path without preparing it")+ output.add_argument("--print-bin", action="store_true", help="Print the binary directory after preparing it")+ args = parser.parse_args()++ if args.print_python:+ environment = environment_path(REQUIREMENTS.read_bytes(), CACHE_ROOT)+ binaries = environment / ("Scripts" if os.name == "nt" else "bin")+ print((binaries / ("python.exe" if os.name == "nt" else "python")).as_posix())+ else:+ binaries = prepare_environment()+ if args.print_bin:+ print(binaries.as_posix())+++if __name__ == "__main__":+ main()diff --git a/Tests/LibWeb/Fixtures/http-test-server.py b/Tests/LibWeb/Fixtures/http-test-server.pyindex 4037acb86ab..865780982f4 100755--- a/Tests/LibWeb/Fixtures/http-test-server.py+++ b/Tests/LibWeb/Fixtures/http-test-server.py@@ -877,24 +877,20 @@ class AIATLSServer(socketserver.ThreadingTCPServer):def _setup_tls_test_servers(http_port, ca_cert_output):- try:- from cryptography import x509 # type: ignore[import-not-found]- from cryptography.hazmat.primitives import hashes # type: ignore[import-not-found]- from cryptography.hazmat.primitives.asymmetric import ec # type: ignore[import-not-found]- from cryptography.hazmat.primitives.serialization import Encoding # type: ignore[import-not-found]- from cryptography.hazmat.primitives.serialization import NoEncryption # type: ignore[import-not-found]- from cryptography.hazmat.primitives.serialization import PrivateFormat # type: ignore[import-not-found]- from cryptography.hazmat.primitives.serialization import pkcs7 # type: ignore[import-not-found]- from cryptography.x509.oid import AuthorityInformationAccessOID # type: ignore[import-not-found]- from cryptography.x509.oid import ExtendedKeyUsageOID # type: ignore[import-not-found]- from cryptography.x509.oid import NameOID # type: ignore[import-not-found]- except ImportError as error:- logging.warning("TLS test setup skipped: python 'cryptography' unavailable (%s)", error)- return None-import datetimeimport tempfile+ from cryptography import x509 # type: ignore[import-not-found]+ from cryptography.hazmat.primitives import hashes # type: ignore[import-not-found]+ from cryptography.hazmat.primitives.asymmetric import ec # type: ignore[import-not-found]+ from cryptography.hazmat.primitives.serialization import Encoding # type: ignore[import-not-found]+ from cryptography.hazmat.primitives.serialization import NoEncryption # type: ignore[import-not-found]+ from cryptography.hazmat.primitives.serialization import PrivateFormat # type: ignore[import-not-found]+ from cryptography.hazmat.primitives.serialization import pkcs7 # type: ignore[import-not-found]+ from cryptography.x509.oid import AuthorityInformationAccessOID # type: ignore[import-not-found]+ from cryptography.x509.oid import ExtendedKeyUsageOID # type: ignore[import-not-found]+ from cryptography.x509.oid import NameOID # type: ignore[import-not-found]+def new_key():return ec.generate_private_key(ec.SECP256R1())diff --git a/Tests/LibWeb/test-web/Application.cpp b/Tests/LibWeb/test-web/Application.cppindex 0c272fd802f..ca3ed4f2e45 100644--- a/Tests/LibWeb/test-web/Application.cpp+++ b/Tests/LibWeb/test-web/Application.cpp@@ -25,11 +25,7 @@ namespace TestWeb {Application::Application(Optional<ByteString> ladybird_binary_path): WebView::Application(move(ladybird_binary_path)), test_concurrency(Core::System::hardware_concurrency())-#if defined(AK_OS_WINDOWS)- , python_executable_path("python")-#else- , python_executable_path("python3")-#endif+ , python_executable_path(LADYBIRD_PYTHON_EXECUTABLE){if (auto ladybird_source_dir = Core::Environment::get("LADYBIRD_SOURCE_DIR"sv); ladybird_source_dir.has_value())test_root_path = LexicalPath::join(*ladybird_source_dir, "Tests"sv, "LibWeb"sv).string();diff --git a/Tests/LibWeb/test-web/CMakeLists.txt b/Tests/LibWeb/test-web/CMakeLists.txtindex 3e899ad2461..5137f3d5a30 100644--- a/Tests/LibWeb/test-web/CMakeLists.txt+++ b/Tests/LibWeb/test-web/CMakeLists.txt@@ -1,3 +1,5 @@+include(python_environment)+set(SOURCESApplication.cppCaptureFile.cpp@@ -14,7 +16,8 @@ set(SOURCESadd_executable(test-web ${SOURCES})target_compile_definitions(test-web PRIVATE HAS_PDFJS=$<BOOL:${PDFJS_FOUND}>)-add_dependencies(test-web ladybird_build_resource_files ${ladybird_helper_processes})+target_compile_definitions(test-web PRIVATE LADYBIRD_PYTHON_EXECUTABLE="${LADYBIRD_TEST_PYTHON}")+add_dependencies(test-web ladybird_build_resource_files ladybird_python_environment ${ladybird_helper_processes})target_link_libraries(test-web PRIVATE AK LibCore LibDiff LibFileSystem LibGfx LibImageDecoders LibImageDecoderClient LibIPC LibJS LibMain LibRequests LibURL LibWeb LibWebView)if (APPLE)@@ -26,17 +29,19 @@ elseif (WIN32)endif()if (BUILD_TESTING)- ladybird_python_test(test-history-rate-limit-reset.py ARGS $<TARGET_FILE:test-web>)- ladybird_python_test(test-manual-rendering-reset.py ARGS $<TARGET_FILE:test-web> TIMEOUT 240)+ ladybird_python_test(test-history-rate-limit-reset.py+ PYTHON_EXECUTABLE "${LADYBIRD_TEST_PYTHON}" ARGS $<TARGET_FILE:test-web>)+ ladybird_python_test(test-manual-rendering-reset.py+ PYTHON_EXECUTABLE "${LADYBIRD_TEST_PYTHON}" ARGS $<TARGET_FILE:test-web> TIMEOUT 240)add_test(NAME LibWeb- COMMAND $<TARGET_FILE:test-web> --python-executable ${Python3_EXECUTABLE} --per-test-timeout 120 -v -v+ COMMAND $<TARGET_FILE:test-web> --per-test-timeout 120 -v -v)add_test(NAME LibWebUIProcessSessionHistory- COMMAND $<TARGET_FILE:test-web> --python-executable ${Python3_EXECUTABLE} --per-test-timeout 120+ COMMAND $<TARGET_FILE:test-web> --per-test-timeout 120--force-new-process --run-ui-process-session-history-tests -f "Text/input/navigation/*"--results-dir test-dumps/ui-process-session-history-results)diff --git a/Tests/Meta/test-lint-environment.py b/Tests/Meta/test-lint-environment.pyindex a9b2b650910..0997bb74336 100644--- a/Tests/Meta/test-lint-environment.py+++ b/Tests/Meta/test-lint-environment.py@@ -18,7 +18,8 @@ from unittest.mock import Mockfrom unittest.mock import patchSCRIPT = Path(os.environ["LADYBIRD_SOURCE_DIR"]) / "Meta/Linters/run.py"-MODULE = runpy.run_path(str(SCRIPT), run_name="lint_environment")+LINTER = runpy.run_path(str(SCRIPT), run_name="lint_environment")+MODULE = runpy.run_path(str(SCRIPT.parent.parent / "Utils/python_environment.py"), run_name="python_environment")PREPARE = MODULE["prepare_environment"]@@ -44,8 +45,10 @@ class TestLintEnvironment(unittest.TestCase):(binaries / ("python.exe" if os.name == "nt" else "python")).touch()def test_reuses_environment_and_installs_requirements_snapshot(self):- binaries = PREPARE(self.requirements, self.cache)- self.assertEqual(PREPARE(self.requirements, self.cache), binaries)+ with patch("builtins.print") as output:+ binaries = PREPARE(self.requirements, self.cache)+ self.assertEqual(PREPARE(self.requirements, self.cache), binaries)+ output.assert_not_called()self.install.assert_called_once()command = self.install.call_args.args[0]self.assertEqual(Path(command[0]).parent, binaries)@@ -70,6 +73,60 @@ class TestLintEnvironment(unittest.TestCase):self.assertTrue((binaries.parent / ".ready").is_file())self.assertEqual(self.builder.return_value.create.call_count, 2)+ def test_missing_interpreter_is_recreated(self):+ binaries = PREPARE(self.requirements, self.cache)+ (binaries / ("python.exe" if os.name == "nt" else "python")).unlink()+ self.assertEqual(PREPARE(self.requirements, self.cache), binaries)+ self.assertEqual(self.install.call_count, 2)++ def test_running_from_virtual_environment_uses_same_cache(self):+ original = PREPARE(self.requirements, self.cache)+ base = getattr(sys, "_base_executable", sys.executable)+ with patch.object(sys, "executable", str(original / "python")):+ with patch.object(sys, "_base_executable", base, create=True):+ self.assertEqual(PREPARE(self.requirements, self.cache), original)+ self.install.assert_called_once()++ def test_interpreter_aliases_use_same_cache(self):+ interpreter = self.root / "python"+ interpreter.touch()+ alias = self.root / "python3"+ alias.symlink_to(interpreter)+ with patch.object(sys, "_base_executable", str(interpreter), create=True):+ original = PREPARE(self.requirements, self.cache)+ with patch.object(sys, "_base_executable", str(alias), create=True):+ self.assertEqual(PREPARE(self.requirements, self.cache), original)+ self.install.assert_called_once()++ def test_printing_interpreter_path_does_not_prepare_environment(self):+ main = MODULE["main"]+ with patch.dict(main.__globals__, {"REQUIREMENTS": self.requirements, "CACHE_ROOT": self.cache}):+ with patch.object(sys, "argv", ["python_environment.py", "--print-python"]):+ with patch("builtins.print") as output:+ main()+ self.assertFalse(self.cache.exists())+ self.builder.assert_not_called()+ self.install.assert_not_called()+ binaries = PREPARE(self.requirements, self.cache)+ self.assertEqual(+ output.call_args.args[0], (binaries / ("python.exe" if os.name == "nt" else "python")).as_posix()+ )++ def test_setup_is_quiet_unless_binary_directory_is_requested(self):+ main = MODULE["main"]+ prepare = Mock(return_value=self.root)+ with patch.dict(main.__globals__, {"prepare_environment": prepare}):+ with patch.object(sys, "argv", ["python_environment.py"]):+ with patch("builtins.print") as output:+ main()+ output.assert_not_called()+ prepare.assert_called_once()+ with patch.object(sys, "argv", ["python_environment.py", "--print-bin"]):+ with patch("builtins.print") as output:+ main()+ output.assert_called_once_with(self.root.as_posix())+ self.assertEqual(prepare.call_count, 2)+def test_concurrent_setup_installs_once(self):barrier = threading.Barrier(2)lock_environment = MODULE["lock_environment"]@@ -86,7 +143,7 @@ class TestLintEnvironment(unittest.TestCase):self.install.assert_called_once()def test_tool_arguments_exit_status_and_pyright_version_overrides(self):- main = MODULE["main"]+ main = LINTER["main"]self.install.return_value.returncode = 7with patch.dict(main.__globals__, {"prepare_environment": Mock(return_value=self.root)}):with patch.object(sys, "argv", ["run.py", "pyright", "a file.py"]):diff --git a/requirements.txt b/requirements.txtnew file mode 100644index 00000000000..f6eff7c1469--- /dev/null+++ b/requirements.txt@@ -0,0 +1,7 @@+actionlint-py==1.7.12.24+cryptography==46.0.7+pyright==1.1.411+PyYAML==6.0.3+requests==2.32.5+ruff==0.15.22+six==1.17.0