generated from benchopt/template_benchmark
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f95a84
commit c241413
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from libomp_install import install_libomp_on_macos | ||
|
||
# libomp x86_64 is needed for snapML on macOS. Homebrew is needed for this install as well. | ||
|
||
# Homebrew is installed and added to path to install libomp x86_64. | ||
|
||
# Also, libomp needs some directories added to PATH to function correctly. | ||
|
||
install_libomp_on_macos() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import platform | ||
import subprocess | ||
import os | ||
|
||
|
||
def install_libomp_on_macos(): | ||
# Check if the OS is macOS | ||
if platform.system() != 'Darwin': | ||
return | ||
|
||
# Install and setup Homebrew | ||
subprocess.run( | ||
[ | ||
'arch', '-x86_64', '/bin/bash', '-c', | ||
'"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' | ||
], | ||
check=True, | ||
shell=True | ||
) | ||
|
||
# Add Homebrew to the shell environment | ||
homebrew_shellenv = subprocess.run( | ||
[ | ||
'/usr/local/bin/brew', 'shellenv' | ||
], | ||
check=True, | ||
capture_output=True, | ||
text=True, | ||
shell=True | ||
).stdout | ||
with open(os.path.expanduser('~/.profile'), 'a') as profile_file: | ||
profile_file.write(f'eval "$({homebrew_shellenv})"\n') | ||
subprocess.run( | ||
['eval', f'"$({homebrew_shellenv})"'], | ||
check=True, | ||
shell=True | ||
) | ||
|
||
# Install libomp | ||
subprocess.run( | ||
['arch', '-x86_64', '/usr/local/bin/brew', 'install', 'libomp'], | ||
check=True, | ||
shell=True | ||
) | ||
|
||
# Set environment variables | ||
with open(os.path.expanduser('~/.profile'), 'a') as profile_file: | ||
profile_file.write('export LDFLAGS="-L/usr/local/opt/libomp/lib"\n') | ||
profile_file.write('export CPPFLAGS="-I/usr/local/opt/libomp/include"\n') | ||
profile_file.write( | ||
'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/opt/libomp/lib\n') | ||
|
||
# Also export environment variables in the current session | ||
os.environ['LDFLAGS'] = '-L/usr/local/opt/libomp/lib' | ||
os.environ['CPPFLAGS'] = '-I/usr/local/opt/libomp/include' | ||
os.environ['DYLD_LIBRARY_PATH'] = os.environ.get( | ||
'DYLD_LIBRARY_PATH', '') + ':/usr/local/opt/libomp/lib' |