From e15f73790218b1426cd6b30b60bd19ebcdf3c83f Mon Sep 17 00:00:00 2001 From: Sean Pedersen Date: Wed, 12 Mar 2025 11:34:10 +0100 Subject: [PATCH] Fix pip install from source for Mac --- README.md | 6 +++++- requirements.txt | 5 +++++ setup.py | 21 +++++++++++---------- 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 requirements.txt diff --git a/README.md b/README.md index 1c646cf..17d8faa 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ $ conda install alartum::ncvis **Important**: be sure to have *OpenMP* available. +Install for Mac: `$ brew install libomp` + First of all, download the *pcg-cpp* and *hnswlib* libraries: ```bash $ make libs @@ -103,7 +105,9 @@ If *conda* environment is used, it replaces library search paths. To prevent com * Pip ```bash - $ pip install numpy cython pybind11 + $ uv venv --python 3.11 + $ source .venv/bin/activate + $ uv pip install -r requirements.txt $ make wrapper ``` diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a1bf796 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +cython==3.0.2 +numpy==1.26.1 +pybind11==2.13.6 +scipy==1.15.2 +setuptools==61.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 581f619..f8c02b8 100644 --- a/setup.py +++ b/setup.py @@ -77,14 +77,9 @@ def finalize_options(self): deps = runtime_deps -try: - from Cython.Build import cythonize - import numpy - import pybind11 # noqa: F401 -except ImportError: - print("numpy/cython/pybind11 are not installed:") - print(">> pip install numpy cython pybind11") - exit(1) +from Cython.Build import cythonize +import numpy +import pybind11 # noqa: F401 with open("recipe/meta.yaml", "r") as f: config = f.read() @@ -118,14 +113,19 @@ def finalize_options(self): "-std=c++14", "-fpic", "-ffast-math", - "-fopenmp=libiomp5", + "-fopenmp", + "-Wl,-rpath,/opt/homebrew/opt/libomp/lib" ] - libraries = ["m", "iomp5"] + extra_link_args = ["-L/opt/homebrew/opt/libomp/lib", "-lomp"] + libraries = ["m"] + include_dirs = [numpy.get_include(), "/opt/homebrew/opt/libomp/include"] elif sys.platform.startswith("linux"): extra_compile_args = ["-O3", "-std=c++14", "-ffast-math", "-fopenmp"] + extra_link_args = [] libraries = ["m", "gomp"] elif sys.platform.startswith("win32"): extra_compile_args = ["/O2", "/fp:fast", "/openmp"] + extra_link_args = [] libraries = ["/openmp"] extensions = [ @@ -133,6 +133,7 @@ def finalize_options(self): "ncvis", ["wrapper/*.pyx", *src], extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, libraries=libraries, include_dirs=[numpy.get_include()], language="c++",