Skip to content

Commit

Permalink
Cleanup of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Oct 7, 2022
1 parent a94896e commit 079b392
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 47 deletions.
11 changes: 6 additions & 5 deletions cm-mlops/script/get-bazel/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ def preprocess(i):

file_name = 'bazel.exe' if os_info['platform'] == 'windows' else 'bazel'
env['FILE_NAME'] = file_name
if 'CM_BAZEL_INSTALLED_PATH' in env:
found_path = env['CM_BAZEL_INSTALLED_PATH']
else:
if 'CM_BAZEL_BIN_WITH_PATH' not in env:
r = i['automation'].find_artifact({'file_name': file_name,
'env': env,
'os_info':os_info,
Expand All @@ -29,8 +27,6 @@ def preprocess(i):
else:
return r

env['CM_LLVM_INSTALLED_PATH'] = r['found_path']

return {'return':0}

def detect_version(i):
Expand All @@ -53,6 +49,11 @@ def postprocess(i):
if r['return'] >0: return r

version = r['version']
found_file_path = env['CM_BAZEL_BIN_WITH_PATH']

found_path = os.path.dirname(found_file_path)
env['CM_BAZEL_INSTALLED_PATH'] = found_path


env['CM_BAZEL_CACHE_TAGS'] = 'version-'+version

Expand Down
3 changes: 1 addition & 2 deletions cm-mlops/script/get-bazel/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
bazel_bin=${CM_BAZEL_INSTALLED_PATH}/${FILE_NAME}
bazel_bin=${CM_BAZEL_BIN_WITH_PATH:-$bazel_bin}
bazel_bin=${CM_BAZEL_BIN_WITH_PATH}
if [[ ${CM_VERSION} == "0.26.1" ]]; then
${bazel_bin} version |grep "Build label" |sed 's/Build label:/bazel/' > tmp-ver.out
else
Expand Down
10 changes: 6 additions & 4 deletions cm-mlops/script/get-cmake/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def preprocess(i):
recursion_spaces = i['recursion_spaces']

file_name = 'cmake.exe' if os_info['platform'] == 'windows' else 'cmake'
env['FILE_NAME'] = file_name
if 'CM_CMAKE_INSTALLED_PATH' not in env:
if 'CM_CMAKE_BIN_WITH_PATH' not in env:
r = i['automation'].find_artifact({'file_name': file_name,
'env':env,
'os_info':os_info,
Expand All @@ -27,8 +26,6 @@ def preprocess(i):
else:
return r

env['CM_CMAKE_INSTALLED_PATH'] = r['found_path']

return {'return':0}

def detect_version(i):
Expand All @@ -52,6 +49,11 @@ def postprocess(i):
if r['return'] >0: return r

version = r['version']
found_file_path = env['CM_CMAKE_BIN_WITH_PATH']

found_path = os.path.dirname(found_file_path)

env['CMAKE_INSTALLED_PATH'] = found_path

env['CM_CMAKE_CACHE_TAGS'] = 'version-'+version
if 'CM_HOST_CPU_TOTAL_CORES' in env:
Expand Down
3 changes: 1 addition & 2 deletions cm-mlops/script/get-cmake/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
cmake_bin=${CM_CMAKE_INSTALLED_PATH}/${FILE_NAME}
cmake_bin=${CM_CMAKE_BIN_WITH_PATH:-${cmake_bin}}
cmake_bin=${CM_CMAKE_BIN_WITH_PATH}

${cmake_bin} --version > tmp-ver.out
test $? -eq 0 || exit 1
8 changes: 5 additions & 3 deletions cm-mlops/script/get-cuda/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def preprocess(i):
recursion_spaces = i['recursion_spaces']

file_name = 'nvcc.exe' if os_info['platform'] == 'windows' else 'nvcc'
env['FILE_NAME'] = file_name

if 'CM_CUDA_INSTALLED_PATH' not in env:
r = i['automation'].find_artifact({'file_name': file_name,
Expand All @@ -31,8 +30,6 @@ def preprocess(i):
else:
return r

env['CM_CUDA_INSTALLED_PATH'] = r['found_path']

return {'return':0}

def detect_version(i):
Expand All @@ -53,6 +50,11 @@ def postprocess(i):
env = i['env']
r = detect_version(i)
if r['return'] >0: return r
found_file_path = env['CM_NVCC_BIN_WITH_PATH']

found_path = os.path.dirname(found_file_path)
env['CM_CUDA_INSTALLED_PATH'] = found_path


version = r['version']

Expand Down
3 changes: 1 addition & 2 deletions cm-mlops/script/get-cuda/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
nvcc_bin=${CM_CUDA_INSTALLED_PATH}/${FILE_NAME}
nvcc_bin=${CM_NVCC_BIN_WITH_PATH:-${nvcc_bin}}
nvcc_bin=${CM_NVCC_BIN_WITH_PATH}

${nvcc_bin} -V > tmp-ver.out
test $? -eq 0 || exit 1
12 changes: 12 additions & 0 deletions cm-mlops/script/get-openssl/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@
"openssl",
"lib-openssl"
],
"env": {
"CM_TMP_REQUIRE_INSTALL": "no"
},
"prehook_deps": [
{
"tags": "install,openssl",
"reuse_version": true,
"enable_if_env": {
"CM_TMP_REQUIRE_INSTALL": [ "yes" ]
}
}
],
"uid": "febdae70e9e64e30"
}
37 changes: 17 additions & 20 deletions cm-mlops/script/get-openssl/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,25 @@ def preprocess(i):

recursion_spaces = i['recursion_spaces']

file_name = 'openssl.exe' if os_info['platform'] == 'windows' else 'openssl'
file_name = 'openssl'

r = i['automation'].find_artifact({'file_name': file_name,
'env': env,
'os_info':os_info,
'default_path_env_key': 'PATH',
'detect_version':True,
'env_path_key':'CM_PYTHON_BIN_WITH_PATH',
'env_path_key':'CM_OPENSSL_BIN_WITH_PATH',
'run_script_input':i['run_script_input'],
'recursion_spaces':i['recursion_spaces']})
if r['return']>0:
if r['return'] == 16 and os_info['platform'] != 'windows':
if env.get('CM_TMP_FAIL_IF_NOT_FOUND','').lower() == 'yes':
return r

print (recursion_spaces+' # {}'.format(r['error']))

# Attempt to run installer
r = {'return':0, 'skip':True, 'script':{'tags':'install,openssl'}}

return r

found_path = r['found_path']
if r['return'] == 16 and os_info['platform'] != 'windows':
env['CM_TMP_REQUIRE_INSTALL'] = "yes"
return {'return': 0}
return r

return {'return':0}


def postprocess(i):

env = i['env']

def detect_version(i):
r = i['automation'].parse_version({'match_text': r'OpenSSL\s*([\d.]+)',
'group_number': 1,
'env_key':'CM_OPENSSL_VERSION',
Expand All @@ -49,8 +37,17 @@ def postprocess(i):
version = r['version']

print (i['recursion_spaces'] + ' Detected version: {}'.format(version))
return {'return':0, 'version':version}


def postprocess(i):

env = i['env']
r = detect_version(i)
if r['return'] >0: return r
version = r['version']

# Save tags that can be used to specialize further dependencies (such as python packages)
tags = 'version-'+version

return {'return':0, 'version':version}
return {'return':0}
4 changes: 2 additions & 2 deletions cm-mlops/script/get-openssl/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

openssl version > tmp-ver.out
openssl_bin=${CM_OPENSSL_BIN_WITH_PATH}
${openssl_bin} version > tmp-ver.out 2>/dev/null
test $? -eq 0 || exit 1
3 changes: 2 additions & 1 deletion cm-mlops/script/install-bazel/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def preprocess(i):

if 'CM_GIT_CHECKOUT' not in env:
env['CM_GIT_CHECKOUT'] = 'releases/gcc-' + need_version

bazel_bin = "bazel"
env['CM_BAZEL_INSTALLED_PATH'] = os.path.join(os.getcwd(), 'install', 'bin')
env['CM_BAZEL_BIN_WITH_PATH'] = os.path.join(os.getcwd(), 'install', 'bin', bazel_bin)
env['CM_TMP_GET_DEPENDENT_CACHED_PATH'] = os.getcwd()

return {'return':0}
3 changes: 3 additions & 0 deletions cm-mlops/script/install-cmake-prebuilt/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,8 @@ def preprocess(i):

env['CM_CMAKE_INSTALLED_PATH'] = path_bin
env['CM_TMP_GET_DEPENDENT_CACHED_PATH'] = os.getcwd()
bin_name = 'cmake.exe' if os_info['platform'] == 'windows' else 'cmake'
env['CM_CMAKE_BIN_WITH_PATH'] = os.path.join(path_bin, bin_name)


return {'return':0}
3 changes: 2 additions & 1 deletion cm-mlops/script/install-cuda-prebuilt/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def preprocess(i):
automation = i['automation']

recursion_spaces = i['recursion_spaces']

nvcc_bin = "nvcc"
env['CM_CUDA_INSTALLED_PATH'] = os.path.join(os.getcwd(), 'install')
env['CM_NVCC_BIN_WITH_PATH'] = os.path.join(os.getcwd(), 'install', nvcc_bin)
env['CM_TMP_GET_DEPENDENT_CACHED_PATH'] = os.getcwd()

return {'return':0}
9 changes: 4 additions & 5 deletions cm-mlops/script/install-openssl/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ def preprocess(i):

print (recursion_spaces + ' # Requested version: {}'.format(need_version))

path_bin = os.path.join(os.getcwd(), 'install', 'bin')

env['CM_TMP_PATH'] = path_bin
env['CM_TMP_FAIL_IF_NOT_FOUND'] = 'yes'

return {'return':0}

def postprocess(i):
Expand All @@ -37,4 +32,8 @@ def postprocess(i):
if '+LD_LIBRARY_PATH' not in env:
env['+LD_LIBRARY_PATH'] = []
env['+LD_LIBRARY_PATH'].append(path_lib)
bin_name = "openssl"
path_bin = os.path.join(os.getcwd(), 'install', 'bin')
env['CM_OPENSSL_INSTALLED_PATH'] = path_bin
env['CM_OPENSSL_BIN_WITH_PATH'] = os.path.join(path_bin, bin_name)
return {'return':0}

0 comments on commit 079b392

Please sign in to comment.