From aae41c25a8df12a316cbb07e4abe681373a1cbcb Mon Sep 17 00:00:00 2001 From: Connor Peshek Date: Thu, 28 Aug 2025 09:21:57 -0400 Subject: [PATCH] root: check for brew install of libxml2 before updating path (#16422) --- Makefile | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 528ad03a8d..b57eb8d48c 100644 --- a/Makefile +++ b/Makefile @@ -20,12 +20,19 @@ redis_db := $(shell uv run python -m authentik.lib.config redis.db 2>/dev/null) UNAME := $(shell uname) -## For macOS users, add the libxml2 and libxmlsec1 installed from brew to the build path -## to prevent SAML-related tests from failing and ensure correct compilation +# For macOS users, add the libxml2 installed from brew libxmlsec1 to the build path +# to prevent SAML-related tests from failing and ensure correct pip dependency compilation ifeq ($(UNAME), Darwin) -BREW_LDFLAGS := -L$(shell brew --prefix libxml2)/lib $(LDFLAGS) -BREW_CPPFLAGS := -I$(shell brew --prefix libxml2)/include $(CPPFLAGS) -BREW_PKG_CONFIG_PATH := $(shell brew --prefix libxml2)/lib/pkgconfig:$(PKG_CONFIG_PATH) +# Only add for brew users who installed libxmlsec1 + BREW_EXISTS := $(shell command -v brew 2> /dev/null) + ifdef BREW_EXISTS + LIBXML2_EXISTS := $(shell brew list libxml2 2> /dev/null) + ifdef LIBXML2_EXISTS + BREW_LDFLAGS := -L$(shell brew --prefix libxml2)/lib $(LDFLAGS) + BREW_CPPFLAGS := -I$(shell brew --prefix libxml2)/include $(CPPFLAGS) + BREW_PKG_CONFIG_PATH := $(shell brew --prefix libxml2)/lib/pkgconfig:$(PKG_CONFIG_PATH) + endif + endif endif all: lint-fix lint gen web test ## Lint, build, and test everything @@ -60,10 +67,10 @@ lint: ## Lint the python and golang sources golangci-lint run -v core-install: -ifeq ($(UNAME), Darwin) - # Clear cache to ensure fresh compilation +ifdef LIBXML2_EXISTS +# Clear cache to ensure fresh compilation uv cache clean - # Force compilation from source for lxml and xmlsec with correct environment +# Force compilation from source for lxml and xmlsec with correct environment LDFLAGS="$(BREW_LDFLAGS)" CPPFLAGS="$(BREW_CPPFLAGS)" PKG_CONFIG_PATH="$(BREW_PKG_CONFIG_PATH)" uv sync --frozen --reinstall-package lxml --reinstall-package xmlsec --no-binary-package lxml --no-binary-package xmlsec else uv sync --frozen