-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsetup.py
37 lines (30 loc) · 1.17 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import subprocess
from setuptools import setup
from setuptools.command.install import install
class CustomInstallCommand(install):
"""Customized install command that runs 'brew install libomp' on macOS."""
def run(self):
if sys.platform == "darwin":
homebrew_installed = False
try:
# Check if Homebrew is installed by trying to call 'brew --version'
subprocess.check_call(["brew", "--version"])
homebrew_installed = True
except Exception as e:
print(
"Homebrew not found. Please install Homebrew to automatically install libomp."
)
if homebrew_installed:
try:
subprocess.check_call(["brew", "install", "libomp"])
except Exception as e:
print(
"Warning: Failed to install libomp using Homebrew. Please ensure libomp is installed.",
e,
)
# Continue with the normal installation process
install.run(self)
setup(
cmdclass={"install": CustomInstallCommand},
)