Skip to content

Conversation

@ww2283
Copy link

@ww2283 ww2283 commented Oct 27, 2025

Summary

Fixes ZMQ linking issues that cause ImportError: symbol not found '_zmq_close' during editable installs.

Problem

  • Editable installs failed with ImportError for ZMQ symbols
  • PyPI wheel installations worked fine
  • macOS Python::Module adds -undefined dynamic_lookup which defers symbol resolution
  • ARM64 Mac was finding Intel Homebrew ZMQ instead of ARM64 version

Root Cause

  1. Missing IMPORTED_TARGET in pkg_check_modules
  2. macOS -undefined dynamic_lookup flag deferred symbol resolution
  3. Incorrect architecture-specific ZMQ library detection

Solution

  • Used pkg_check_modules IMPORTED_TARGET to create proper CMake targets
  • Set PKG_CONFIG_PATH to prioritize ARM64 Homebrew on Apple Silicon
  • Overrode macOS -undefined dynamic_lookup to force symbol resolution at build time
  • Used PUBLIC linkage for ZMQ in faiss library for transitive dependencies

Testing

  • ✅ Editable install now works
  • ✅ Python extension imports successfully
  • ✅ All ZMQ symbols resolved at build time

Related

This fix is required for LEANN PR facebookresearch#150 (metadata output feature) and PR #152 (Ollama batching optimization).

@yichuan-w
Copy link
Owner

LGTM

@yichuan-w yichuan-w merged commit 4006a19 into yichuan-w:main Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants