diff --git a/solvers/lightning.py b/solvers/lightning.py index b18d209..da392e5 100644 --- a/solvers/lightning.py +++ b/solvers/lightning.py @@ -14,7 +14,7 @@ class Solver(BaseSolver): install_cmd = 'conda' requirements = [ 'cython', - 'pip:git+https://github.com/scikit-learn-contrib/lightning.git' + 'pip::git+https://github.com/scikit-learn-contrib/lightning.git' ] references = [ diff --git a/solvers/snapml.py b/solvers/snapml.py index 3048629..545d234 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -11,7 +11,14 @@ class Solver(BaseSolver): name = "snapml" install_cmd = "conda" - requirements = ["pip:snapml"] + + # Snap ML wheels are built with numpy 1.*, they are not compatible with + # numpy>=2. TODO : upgrade numpy when compatible wheels are released. + + # libomp x86_64 and Homebrew are needed for snapML to work correctly on + # MacOS. Please check this tutorial to install SnapML correctly: + # https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst + requirements = ["numpy'<2'", "pip::snapml"] parameters = {"gpu": [False, True]} references = [ diff --git a/test_config.py b/test_config.py index 0594d43..fb42bca 100644 --- a/test_config.py +++ b/test_config.py @@ -13,3 +13,9 @@ def check_test_solver_install(solver_class): if "glmnet" in solver_class.name.lower(): pytest.xfail("glmnet produces discrepancies (see issue #2).") + + # libomp x86_64 and Homebrew are needed for snapML to work correctly on + # MacOS. Please check this tutorial to install SnapML correctly: + # https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst + if 'snapml' in solver_class.name.lower() and sys.platform == 'darwin': + pytest.xfail('snapML is not easy to install on MacOS.') diff --git a/tutorials/snapml_macos.rst b/tutorials/snapml_macos.rst new file mode 100644 index 0000000..dd56ef8 --- /dev/null +++ b/tutorials/snapml_macos.rst @@ -0,0 +1,58 @@ +============================ +Installing SnapML on macOS +============================ + +This tutorial provides step-by-step instructions to install SnapML on a macOS machine. The process includes setting up Homebrew and installing the necessary dependencies. + +Steps to Install SnapML +======================== + +1. **Install and Setup Homebrew** + + Homebrew is a package manager for macOS that simplifies the installation of software. + + Open your terminal and run the following command to install Homebrew: + + .. code-block:: bash + + arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + After installing Homebrew, you need to add it to your shell environment: + + .. code-block:: bash + + echo 'eval "$(/usr/local/bin/brew shellenv)"' >> $HOME/.profile + eval "$(/usr/local/bin/brew shellenv)" + +2. **Install libomp** + + `libomp` is an OpenMP library required by SnapML. Install it using Homebrew: + + .. code-block:: bash + + arch -x86_64 /usr/local/bin/brew install libomp + + Once installed, set up the environment variables needed for `libomp`: + + .. code-block:: bash + + echo 'export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"' >> $HOME/.profile + echo 'export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"' >> $HOME/.profile + echo 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/homebrew/opt/libomp/lib' >> $HOME/.profile + + Apply the changes by running: + + .. code-block:: bash + + source $HOME/.profile + +3. **Install SnapML** + + With the dependencies installed, you can now proceed to install SnapML using pip: + + .. code-block:: bash + + pip install snapml + + +By following these steps, you should have SnapML installed and running correctly on your macOS machine.