Repository: skypilot-org/skypilot
Pull request: Sky Installation for Mac <1.15 Warnings + Doc
## Features

- [x] Added warnings for Mac installation if user runs `pip install -v .` in Sky repo. 
<img width="1032" alt="Screen Shot 2022-03-14 at 5 21 28 PM" src="https://user-images.githubusercontent.com/20640975/158284108-35690c86-b68d-459a-b6b2-91b5ad45ebc6.png">

- [x] Added Mac warning in the installation documentation

## Caveat

- There is no way for Pip install to show log/stdout outputs without the verbose flag (after much search on StackOverflow)

Problem statement:
Cannot install on Apple Silicon due to grpcio issue
Our package as is won't install on Apple Silicon due to grpcio (imported by Ray) compatibility issues. The current workaround I've been using is: `pip uninstall grpcio; conda install grpcio`, but I'm hoping either grpcio/ray finds a way to fix this soon.

Until then should we add a section to our documentation about this for Apple Silicon users?

ray does not support Mac OS X 10.x
We can only install `ray==1.5` on Mac OS X 10.x, which is OS version of Kevin's laptop.

Hints from issue discussion:
I had that problem back in Jan.  Had to clear up space and upgrade to Catalina.

Don't think we can do much here...
Discussed offline - we should 
- require ray >= 1.9.2 in setup.py
- try to detect <= MacOS 10.14 and print a useful message saying MacOS >= 1.15 is needed to satisfy the ray requirement

Commit message: Fix

Patch to review:
diff --git a/docs/source/getting-started/installation.rst b/docs/source/getting-started/installation.rst
index 70ca4015b97..2fdc70af9f7 100644
--- a/docs/source/getting-started/installation.rst
+++ b/docs/source/getting-started/installation.rst
@@ -17,6 +17,10 @@ only have access to certain clouds, use any combination of
 :code:`".[aws,azure,gcp]"` (e.g., :code:`".[aws,gcp]"`) to reduce the
 dependencies installed.
 
+.. note::
+
+    On Mac, support for Sky below macOS version < 1.15 (Mojave) is currently limited. Sky requires Ray ≥ 1.9, which works for macOS ≥ 1.15.
+
 Cloud account setup
 -------------------
 
diff --git a/sky/setup_files/setup.py b/sky/setup_files/setup.py
index 6af80f826fc..15b43e7302d 100644
--- a/sky/setup_files/setup.py
+++ b/sky/setup_files/setup.py
@@ -5,10 +5,42 @@
 Google Cloud Platform or Microsoft Azure."""
 
 import os
+import platform
 import setuptools
+import warnings
 
 ROOT_DIR = os.path.dirname(__file__)
 
+
+def version_comparator(v1, v2):
+    v1_num = [int(i) for i in v1.split(".")]
+    v2_num = [int(i) for i in v2.split(".")]
+    v1_size = len(v1_num)
+    v2_size = len(v2_num)
+
+    size_diff = abs(v1_size - v2_size)
+    for _ in range(size_diff):
+        if v1_size > v2_size:
+            v2_num.append(0)
+        elif v2_size > v1_size:
+            v1_num.append(0)
+
+    for i in range(v1_size):
+        if v1_num[i] > v2_num[i]:
+            return 1
+        elif v2_num[i] > v1_num[i]:
+            return -1
+    return 0
+
+
+system = platform.system()
+if system == 'Darwin':
+    mac_version = platform.mac_ver()[0]
+    if version_comparator(mac_version, '10.15') == -1:
+        warnings.warn(
+            f"Detected MacOS version {mac_version}. MacOS version >=1.15 "
+            "is needed to satisfy Ray>=1.9")
+
 install_requires = [
     'wheel',
     'Click',


Code review comments:
diff_hunk: @@ -5,10 +5,42 @@
 Google Cloud Platform or Microsoft Azure."""
 
 import os
+import platform
 import setuptools
+import warnings
 
 ROOT_DIR = os.path.dirname(__file__)
 
+
+def version_comparator(v1, v2):
+    v1_num = [int(i) for i in v1.split(".")]
+    v2_num = [int(i) for i in v2.split(".")]
+    v1_size = len(v1_num)
+    v2_size = len(v2_num)
+
+    size_diff = abs(v1_size - v2_size)
+    for _ in range(size_diff):
+        if v1_size > v2_size:
+            v2_num.append(0)
+        elif v2_size > v1_size:
+            v1_num.append(0)
+
+    for i in range(v1_size):
+        if v1_num[i] > v2_num[i]:
+            return 1
+        elif v2_num[i] > v1_num[i]:
+            return -1
+    return 0
+
+
+system = platform.system()
+if system == 'Darwin':
+    mac_version = platform.mac_ver()[0]
+    if version_comparator(mac_version, '10.15') == -1:
path: sky/setup_files/setup.py
text: @user1:
Hmm, version_comparator() is too complex to have for this simple use case. How about
```
mac_major, mac_minor = mac_version.split('.')[:2]
if not (int(mac_major) >= 10 and int(mac_minor) >= 15): 
  ...
```

diff_hunk: @@ -5,10 +5,42 @@
 Google Cloud Platform or Microsoft Azure."""
 
 import os
+import platform
 import setuptools
+import warnings
 
 ROOT_DIR = os.path.dirname(__file__)
 
+
+def version_comparator(v1, v2):
+    v1_num = [int(i) for i in v1.split(".")]
+    v2_num = [int(i) for i in v2.split(".")]
+    v1_size = len(v1_num)
+    v2_size = len(v2_num)
+
+    size_diff = abs(v1_size - v2_size)
+    for _ in range(size_diff):
+        if v1_size > v2_size:
+            v2_num.append(0)
+        elif v2_size > v1_size:
+            v1_num.append(0)
+
+    for i in range(v1_size):
+        if v1_num[i] > v2_num[i]:
+            return 1
+        elif v2_num[i] > v1_num[i]:
+            return -1
+    return 0
+
+
+system = platform.system()
+if system == 'Darwin':
+    mac_version = platform.mac_ver()[0]
+    if version_comparator(mac_version, '10.15') == -1:
+        warnings.warn(
+            f"Detected MacOS version {mac_version}. MacOS version >=1.15 "
+            "is needed to satisfy Ray>=1.9")
path: sky/setup_files/setup.py
text: @user1:
"to install ray>=1.9"

quotes?

diff_hunk: @@ -5,10 +5,42 @@
 Google Cloud Platform or Microsoft Azure."""
 
 import os
+import platform
 import setuptools
+import warnings
 
 ROOT_DIR = os.path.dirname(__file__)
 
+
+def version_comparator(v1, v2):
+    v1_num = [int(i) for i in v1.split(".")]
+    v2_num = [int(i) for i in v2.split(".")]
+    v1_size = len(v1_num)
+    v2_size = len(v2_num)
+
+    size_diff = abs(v1_size - v2_size)
+    for _ in range(size_diff):
+        if v1_size > v2_size:
+            v2_num.append(0)
+        elif v2_size > v1_size:
+            v1_num.append(0)
+
+    for i in range(v1_size):
+        if v1_num[i] > v2_num[i]:
+            return 1
+        elif v2_num[i] > v1_num[i]:
+            return -1
+    return 0
+
+
+system = platform.system()
+if system == 'Darwin':
+    mac_version = platform.mac_ver()[0]
+    if version_comparator(mac_version, '10.15') == -1:
+        warnings.warn(
+            f"Detected MacOS version {mac_version}. MacOS version >=1.15 "
path: sky/setup_files/setup.py
text: @user1:
not 1.15, but 10.15

diff_hunk: @@ -17,6 +17,10 @@ only have access to certain clouds, use any combination of
 :code:`".[aws,azure,gcp]"` (e.g., :code:`".[aws,gcp]"`) to reduce the
 dependencies installed.
 
+.. note::
+
+    On Mac, support for Sky below macOS version < 1.15 (Mojave) is currently limited. Sky requires Ray ≥ 1.9, which works for macOS ≥ 1.15.
path: docs/source/getting-started/installation.rst
text: @user1:
We need to make 
- "is currently limited"
- "which works for"
precise.  How about

```
For Macs, macOS >= 1.15 is required to install Sky.
```

@author:
Emulated Ray syntax for Windows here: https://docs.ray.io/en/latest/ray-overview/installation.html

Otherwise, SGTM