Skip to content

Commit

Permalink
Merge pull request #504 from mlcommons/anandhu-eng-patch-6
Browse files Browse the repository at this point in the history
pip install cm4mlops - handle systems where sudo is absent
  • Loading branch information
arjunsuresh authored Nov 8, 2024
2 parents a189c15 + 11d77de commit 2f9e99c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import importlib.util
import platform
import os
import shutil

# Try to use importlib.metadata for Python 3.8+
try:
Expand Down Expand Up @@ -76,8 +77,17 @@ def install_system_packages(self):
manager, details = self.get_package_manager_details()
if manager:
if manager == "apt-get":
subprocess.check_call(['sudo', 'apt-get', 'update'])
subprocess.check_call(['sudo', 'apt-get', 'install', '-y'] + packages)
# Check if 'sudo' is available
if shutil.which('sudo'):
subprocess.check_call(['sudo', 'apt-get', 'update'])
subprocess.check_call(['sudo', 'apt-get', 'install', '-y'] + packages)
else:
print("sudo not found, trying without sudo.")
try:
subprocess.check_call(['apt-get', 'update'])
subprocess.check_call(['apt-get', 'install', '-y'] + packages)
except subprocess.CalledProcessError:
print(f"Installation of {packages} without sudo failed. Please install these packages manually to continue!")
elif self.system == 'Windows':
print(f"Please install the following packages manually: {packages}")

Expand Down

0 comments on commit 2f9e99c

Please sign in to comment.