From 162c3822f9cd7c271e24159fb416dcf532501438 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 2 Feb 2026 14:55:57 -0800 Subject: [PATCH 1/3] add apt equivalents in brewfile to post fetch --- Brewfile | 2 ++ devenv/post_fetch.py | 56 +++++++++++++++++++++++++++++++++++++++++++- setup.cfg | 2 +- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Brewfile b/Brewfile index bc36dbd09223f4..d5c52c0f4a5bd1 100644 --- a/Brewfile +++ b/Brewfile @@ -9,6 +9,8 @@ brew 'qemu' brew 'docker' brew 'docker-buildx' +### If updating below this line, please also update REQUIRED_APT_PKGS in devenv/post_fetch.py ### + # required for pnpm test -u brew 'watchman' diff --git a/devenv/post_fetch.py b/devenv/post_fetch.py index 590bb4ace44be4..fa3607ff33d52b 100644 --- a/devenv/post_fetch.py +++ b/devenv/post_fetch.py @@ -1,12 +1,66 @@ from __future__ import annotations import configparser +import shutil +import subprocess + +from devenv import constants +from devenv.lib import proc + +# we only support apt-based linuxes +LINUX = shutil.which("dpkg") is not None + +# these are the subset of requirements from the Brewfile that are necessary on linux +REQUIRED_APT_PKGS = ["watchman", "chromium-chromedriver"] + + +def dpkg_is_installed(pkg: str) -> bool: + try: + out = subprocess.check_output( + ["dpkg-query", "-W", "-f=${Status}", pkg], + stderr=subprocess.DEVNULL, + text=True, + ).strip() + except subprocess.CalledProcessError: + return False + + # + return out == "install ok installed" + + +def dpkgs_not_installed(pkgs: list[str]) -> list[str]: + return [pkg for pkg in pkgs if not dpkg_is_installed(pkg)] def main(context: dict[str, str]) -> int: - # post_fetch is meant for recommended but not required defaults reporoot = context["reporoot"] + if constants.DARWIN: + print("Installing sentry's brew dependencies...") + if constants.CI: + # Installing everything from brew takes too much time, + # and chromedriver cask flakes occasionally. Really all we need to + # set up the devenv is colima and docker-cli. + # This is also required for arm64 macOS GHA runners. + # We manage colima, so just need to install docker + qemu here. + proc.run(("brew", "install", "docker", "qemu")) + else: + proc.run( + (f"{constants.homebrew_bin}/brew", "bundle"), + cwd=reporoot, + ) + elif LINUX: + # if not constants.CI: + not_installed = dpkgs_not_installed(REQUIRED_APT_PKGS) + if not_installed: + raise SystemExit( + f"Please install the following apt packages: {' '.join(REQUIRED_APT_PKGS)}" + ) + else: + print( + f"Unsupported platform; assuming you have the equivalent of the following apt packages installed: {' '.join(REQUIRED_APT_PKGS)}" + ) + git_config = configparser.ConfigParser() git_config.read(f"{reporoot}/.git/config") git_config["blame"] = {"ignoreRevsFile": ".git-blame-ignore-revs"} diff --git a/setup.cfg b/setup.cfg index f3783b6e4d7069..81141bb460228e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -97,7 +97,7 @@ extend-ignore = E203,E501,E402,E731,B007,B009,B010,B011,B020,B023,B024,B026,B027 per-file-ignores = # these scripts must have minimal dependencies so opt out of the usual sentry rules .github/*: S - devenv/sync.py: S + devenv/*.py: S src/sentry/build/*: S tools/*: S # testing the options manager itself From c7c833aa14ee2acdea47ee76b68bf989fa92648d Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 2 Feb 2026 15:50:26 -0800 Subject: [PATCH 2/3] remove test --- devenv/post_fetch.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/devenv/post_fetch.py b/devenv/post_fetch.py index fa3607ff33d52b..4042c84a6d59a1 100644 --- a/devenv/post_fetch.py +++ b/devenv/post_fetch.py @@ -50,12 +50,12 @@ def main(context: dict[str, str]) -> int: cwd=reporoot, ) elif LINUX: - # if not constants.CI: - not_installed = dpkgs_not_installed(REQUIRED_APT_PKGS) - if not_installed: - raise SystemExit( - f"Please install the following apt packages: {' '.join(REQUIRED_APT_PKGS)}" - ) + if not constants.CI: + not_installed = dpkgs_not_installed(REQUIRED_APT_PKGS) + if not_installed: + raise SystemExit( + f"Please install the following apt packages: {' '.join(REQUIRED_APT_PKGS)}" + ) else: print( f"Unsupported platform; assuming you have the equivalent of the following apt packages installed: {' '.join(REQUIRED_APT_PKGS)}" From 9962f46b0eb930b3bd620ae9a4c916056d5ac532 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Tue, 3 Feb 2026 11:35:37 -0800 Subject: [PATCH 3/3] . --- devenv/post_fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devenv/post_fetch.py b/devenv/post_fetch.py index 4042c84a6d59a1..095ea94afa32d7 100644 --- a/devenv/post_fetch.py +++ b/devenv/post_fetch.py @@ -54,7 +54,7 @@ def main(context: dict[str, str]) -> int: not_installed = dpkgs_not_installed(REQUIRED_APT_PKGS) if not_installed: raise SystemExit( - f"Please install the following apt packages: {' '.join(REQUIRED_APT_PKGS)}" + f"Please install the following apt packages: {' '.join(not_installed)}" ) else: print(