From 0ed95849c96a05cae3d2903ee34c0578f4d91c35 Mon Sep 17 00:00:00 2001
From: Trung-Hoang Le <lthoang@users.noreply.github.com>
Date: Sat, 14 Sep 2024 13:03:32 +0800
Subject: [PATCH] Update suggestion command for building cornac from source
 (#645)

* Update suggestion command for building cornac from source

* Fix install command using escape dependency with specified version
---
 setup.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 48dd12aa..496abcce 100644
--- a/setup.py
+++ b/setup.py
@@ -30,14 +30,18 @@ import glob
 import shutil
 from setuptools import Extension, Command, setup, find_packages
 
+
+INSTALL_REQUIRES = ["numpy<2.0.0", "scipy<=1.13.1", "tqdm", "powerlaw"]
+
 try:
     from Cython.Distutils import build_ext
     import numpy as np
     import scipy
 except ImportError:
+    escape_dependency_version = lambda x: '"{}"'.format(x) if "<" in x or "=" in x or ">" in x else x
     exit(
         "We need some dependencies to build Cornac.\n"
-        + "Run: pip3 install Cython numpy scipy"
+        + "Run: pip3 install Cython {}".format(" ".join([escape_dependency_version(x) for x in INSTALL_REQUIRES]))
     )
 
 
@@ -351,7 +355,7 @@ setup(
         "recommendation",
     ],
     ext_modules=extensions,
-    install_requires=["numpy<2.0.0", "scipy<=1.13.1", "tqdm", "powerlaw"],
+    install_requires=INSTALL_REQUIRES,
     extras_require={"tests": ["pytest", "pytest-pep8", "pytest-xdist", "pytest-cov", "Flask"]},
     cmdclass=cmdclass,
     packages=find_packages(),
-- 
GitLab