From ff50896a655fc76fe97532e3a88e4781dc76a3d7 Mon Sep 17 00:00:00 2001 From: Alex Windels Date: Tue, 11 Aug 2026 09:52:48 +0200 Subject: [PATCH] Skip the veryfasttree dependency entirely on macOS arm64 The previous fix (#10) only changed which tree tool CANDy *selects at runtime* by default -- it never touched the actual package dependency declaration, which still unconditionally required veryfasttree for every platform. pip/uv resolves and builds dependencies before a single line of CANDy's own code runs, so the runtime default never got a chance to matter: `pip install`/`uv tool install` itself was still failing trying to build veryfasttree from source on arm64 Macs, confirmed by a real install attempt after upgrading to 3.0.3. Add a PEP 508 environment marker so the dependency is skipped entirely on macOS arm64 (no wheel exists there anyway, and CANDy already defaults away from it there) while still installing normally everywhere else, including Intel Mac and Rosetta-translated x86_64 Python (both have a real wheel, no source build involved). Also guard VeryFastTreeBuilder's import so forcing --tree-tool veryfasttree where it's now legitimately absent raises a clear, actionable error instead of a raw ModuleNotFoundError. Co-Authored-By: Claude Sonnet 5 --- pyproject.toml | 9 ++++++++- src/candy/phylogenetics/veryfasttree_builder.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 089651e..622aabc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,14 @@ dependencies = [ "typer>=0.12", "lxml>=5.0", "pyfamsa>=0.5", - "veryfasttree>=4.0", + # No macOS arm64 wheel exists for this (as of 4.0.4.1) -- installing it + # there falls back to a from-source build that's known to fail (an + # upstream OpenMP-detection bug). CANDy already defaults to fasttree + # instead on exactly this platform (see config.default_tree_tool), so + # skip the dependency there entirely rather than failing every install. + # Still installed on Intel Mac (a real x86_64 wheel exists) and under + # Rosetta translation (ditto) -- neither of those needs a source build. + "veryfasttree>=4.0; sys_platform != 'darwin' or platform_machine != 'arm64'", "platformdirs>=4.0", ] diff --git a/src/candy/phylogenetics/veryfasttree_builder.py b/src/candy/phylogenetics/veryfasttree_builder.py index b87a9c8..15bedcc 100644 --- a/src/candy/phylogenetics/veryfasttree_builder.py +++ b/src/candy/phylogenetics/veryfasttree_builder.py @@ -3,7 +3,16 @@ import logging from pathlib import Path -import veryfasttree +try: + import veryfasttree +except ImportError as exc: # pragma: no cover -- exercised only where the wheel is genuinely absent + raise ImportError( + "The 'veryfasttree' package is not installed. On macOS arm64 (Apple Silicon), this is " + "deliberate -- veryfasttree has no native wheel there and CANDy defaults to --tree-tool " + "fasttree instead (see the README's Apple Silicon setup section). To force veryfasttree " + "anyway, `pip install veryfasttree` yourself -- it will attempt a from-source build, which " + "is known to fail on stock macOS due to an upstream OpenMP-detection bug." + ) from exc logger = logging.getLogger(__name__)