lmod-toolkit 0.0.3__tar.gz → 0.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lmod_toolkit-0.0.3/src/lmod_toolkit.egg-info → lmod_toolkit-0.0.5}/PKG-INFO +1 -1
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/setup.sh +23 -3
- lmod_toolkit-0.0.5/src/lmod_toolkit/__init__.py +1 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit/_version.py +3 -3
- lmod_toolkit-0.0.5/src/lmod_toolkit/bin/lmtk-test.sh +10 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit/lmod_config.py +1 -0
- lmod_toolkit-0.0.5/src/lmod_toolkit/lmod_ext_attrs.py +79 -0
- lmod_toolkit-0.0.5/src/lmod_toolkit/lmod_spider.py +54 -0
- lmod_toolkit-0.0.5/src/lmod_toolkit/test.py +14 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5/src/lmod_toolkit.egg-info}/PKG-INFO +1 -1
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit.egg-info/SOURCES.txt +4 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit.egg-info/scm_file_list.json +4 -0
- lmod_toolkit-0.0.5/src/lmod_toolkit.egg-info/scm_version.json +8 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/utils/quickstart.sh +6 -2
- lmod_toolkit-0.0.3/src/lmod_toolkit/__init__.py +0 -1
- lmod_toolkit-0.0.3/src/lmod_toolkit.egg-info/scm_version.json +0 -8
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/.github/workflows/publish-to-test-pypi.yml +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/.gitignore +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/README.md +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/README.pypi +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/pyproject.toml +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/setup.cfg +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit/build_helper.py +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit.egg-info/dependency_links.txt +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/src/lmod_toolkit.egg-info/top_level.txt +0 -0
- {lmod_toolkit-0.0.3 → lmod_toolkit-0.0.5}/utils/uv_installer.sh +0 -0
|
@@ -118,18 +118,38 @@ is_pre_release_allowed() {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
|
|
121
|
+
is_upgrade_allowed() {
|
|
122
|
+
# to enable upgrade of lmod-toolkit: export $LMTK_ALLOW_UPGRADE=yes
|
|
123
|
+
[[ $DEBUG -eq $YES ]] && set -x
|
|
124
|
+
local _retval=$NO
|
|
125
|
+
if [[ "$LMTK_ALLOW_UPGRADE" == "yes" \
|
|
126
|
+
|| "$LMTK_ALLOW_UPGRADE" == "YES" \
|
|
127
|
+
|| "$LMTK_ALLOW_UPGRADE" == "Y" \
|
|
128
|
+
|| "$LMTK_ALLOW_UPGRADE" == "y" \
|
|
129
|
+
|| "$LMTK_ALLOW_UPGRADE" -eq 1
|
|
130
|
+
]] ; then
|
|
131
|
+
_retval=$YES
|
|
132
|
+
fi
|
|
133
|
+
return $_retval
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
121
137
|
install_lmod_toolkit() {
|
|
122
138
|
[[ $DEBUG -eq $YES ]] && set -x
|
|
123
|
-
|
|
139
|
+
local -a _cli_opts
|
|
140
|
+
is_upgrade_allowed && {
|
|
141
|
+
_cli_opts+=( '--upgrade' )
|
|
142
|
+
}
|
|
124
143
|
is_pre_release_allowed && {
|
|
125
144
|
export UV_INDEX=https://test.pypi.org/simple
|
|
126
|
-
|
|
145
|
+
_cli_opts+=( '--prerelease-package' 'lmod-toolkit=allow' )
|
|
127
146
|
}
|
|
147
|
+
export UV_DEFAULT_INDEX=https://pypi.org/simple
|
|
128
148
|
pushd "${INSTALL_DIR}"
|
|
129
149
|
"${UV}" pip install \
|
|
150
|
+
"${_cli_opts[@]}" \
|
|
130
151
|
lmod-toolkit"${LMTK_INSTALL_VERSION:+==$LMTK_INSTALL_VERSION}"
|
|
131
152
|
popd
|
|
132
|
-
|
|
133
153
|
}
|
|
134
154
|
|
|
135
155
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import lmod_config, lmod_spider, lmod_ext_attrs
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.0.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 0,
|
|
21
|
+
__version__ = version = '0.0.5'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 0, 5)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g772328371'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/bash
|
|
2
|
+
|
|
3
|
+
INSTALL_DIR=___INSTALL_DIR___
|
|
4
|
+
V_PYTHON="${INSTALLL_DIR}"/.venv/bin/python
|
|
5
|
+
SITE_PACKAGES=$(
|
|
6
|
+
"${V_PYTHON}" -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
|
|
7
|
+
)
|
|
8
|
+
LMTK_PATH="${SITE_PACKAGES}"/lmod_toolkit
|
|
9
|
+
|
|
10
|
+
"${V_PYTHON}" "${LMTK_PATH}"/test.py
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import json
|
|
3
|
+
import pprint
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from lmod_toolkit import lmod_spider
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'as_json',
|
|
12
|
+
'get_ext_attrs',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
EXTATTR_KEYS = [
|
|
16
|
+
'Name',
|
|
17
|
+
'Version',
|
|
18
|
+
'.*escription',
|
|
19
|
+
'URL',
|
|
20
|
+
'Category',
|
|
21
|
+
'Keywords',
|
|
22
|
+
'SupportStatus',
|
|
23
|
+
'SupportContact',
|
|
24
|
+
'Default',
|
|
25
|
+
'IPF_FLAGS',
|
|
26
|
+
]
|
|
27
|
+
LONGEST_FIRST = sorted(EXTATTR_KEYS, key=len, reverse=True)
|
|
28
|
+
WHATIS_RE = re.compile(r'whatis\(\[\[((?:{}))\s*:\s*(.*)\]\]\)'.format('|'.join(LONGEST_FIRST)))
|
|
29
|
+
COMMENT_RE = re.compile(r'\"((?:{})):([^\"]+)\"'.format('|'.join(LONGEST_FIRST)))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@functools.cache
|
|
33
|
+
def get_ext_attrs():
|
|
34
|
+
''' Search through all modules' lua files for any extended attributes.
|
|
35
|
+
Extended attributes are non-lmod supported data added to a lua file.
|
|
36
|
+
'''
|
|
37
|
+
ext_attrs = {}
|
|
38
|
+
for module in lmod_spider.get_module_data():
|
|
39
|
+
for version in module[ 'versions' ]:
|
|
40
|
+
path = version[ 'path' ]
|
|
41
|
+
# skip non-lua files
|
|
42
|
+
if not path.endswith(".lua"):
|
|
43
|
+
#logr.debug( f"skipping non-lua file {path}" )
|
|
44
|
+
print( f"skipping non-lua file {path}" )
|
|
45
|
+
continue
|
|
46
|
+
filepath = Path( path )
|
|
47
|
+
try:
|
|
48
|
+
file_contents = filepath.read_text()
|
|
49
|
+
except ( FileNotFoundError, PermissionError, IOError ) as e:
|
|
50
|
+
#logr.debug( f"error opening file '{filepath}' {e}" )
|
|
51
|
+
print( f"error opening file '{filepath}' {e}" )
|
|
52
|
+
continue
|
|
53
|
+
ext_data = get_ext_attrs_from_lua_file( file_contents )
|
|
54
|
+
if ext_data:
|
|
55
|
+
full_name = version[ 'full' ]
|
|
56
|
+
ext_attrs[ full_name ] = ext_data
|
|
57
|
+
return ext_attrs
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def get_ext_attrs_from_lua_file( text: str ) -> dict:
|
|
61
|
+
''' text parsing taken from
|
|
62
|
+
https://github.com/access-ci-org/ipf/blob/3e419ebb/ipf/glue2/modules.py#L444
|
|
63
|
+
'''
|
|
64
|
+
whatis_res = WHATIS_RE.findall(text)
|
|
65
|
+
comment_res = COMMENT_RE.findall(text)
|
|
66
|
+
# Return all tuples found, allow "comment" to override "whatis"
|
|
67
|
+
ext_attrs = {
|
|
68
|
+
k: v
|
|
69
|
+
for k, v in whatis_res+comment_res
|
|
70
|
+
}
|
|
71
|
+
return ext_attrs
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def as_json():
|
|
75
|
+
return json.dumps( get_ext_attrs() )
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == '__main__':
|
|
79
|
+
pprint.pprint( get_ext_attrs() )
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import pprint
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from lmod_toolkit import lmod_config
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
'as_json',
|
|
14
|
+
'get_module_data',
|
|
15
|
+
'get_module_files',
|
|
16
|
+
'get_module_names',
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@functools.cache
|
|
21
|
+
def get_module_data():
|
|
22
|
+
prefix = lmod_config.prefix
|
|
23
|
+
libexec = Path( prefix , 'lmod' , 'lmod' , 'libexec' )
|
|
24
|
+
spider = libexec / 'spider'
|
|
25
|
+
try:
|
|
26
|
+
MODULEPATH = os.environ[ 'MODULEPATH' ] #will fail with KeyError if not found
|
|
27
|
+
except KeyError as e:
|
|
28
|
+
raise SystemExit( f"Missing environment variable 'MODULEPATH'\n{e}" )
|
|
29
|
+
cmds = [ 'bash', '-l', '-c', f"{spider} -o jsonSoftwarePage \"{MODULEPATH}\"" ]
|
|
30
|
+
result = subprocess.run(
|
|
31
|
+
cmds,
|
|
32
|
+
capture_output=True, # Captures both stdout and stderr
|
|
33
|
+
text=True # Returns strings instead of bytes
|
|
34
|
+
)
|
|
35
|
+
return json.loads( result.stdout )
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_module_names():
|
|
39
|
+
return get_module_data().keys()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_module_files():
|
|
43
|
+
return [
|
|
44
|
+
v.keys()
|
|
45
|
+
for v in get_module_data().values()
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def as_json():
|
|
50
|
+
return json.dumps( get_module_data() )
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if __name__ == '__main__':
|
|
54
|
+
pprint.pprint( get_module_data() )
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import lmod_toolkit as lmtk
|
|
3
|
+
|
|
4
|
+
print( '\nLMOD CONFIG' )
|
|
5
|
+
print( '===========' )
|
|
6
|
+
print( lmtk.lmod_config.as_json() )
|
|
7
|
+
|
|
8
|
+
print( '\nLMOD SPIDER' )
|
|
9
|
+
print( '===========' )
|
|
10
|
+
print( lmtk.lmod_spider.as_json() )
|
|
11
|
+
|
|
12
|
+
print( '\nLMOD EXT ATTRS' )
|
|
13
|
+
print( '==============' )
|
|
14
|
+
print( lmtk.lmod_ext_attrs.as_json() )
|
|
@@ -8,11 +8,15 @@ src/lmod_toolkit/__init__.py
|
|
|
8
8
|
src/lmod_toolkit/_version.py
|
|
9
9
|
src/lmod_toolkit/build_helper.py
|
|
10
10
|
src/lmod_toolkit/lmod_config.py
|
|
11
|
+
src/lmod_toolkit/lmod_ext_attrs.py
|
|
12
|
+
src/lmod_toolkit/lmod_spider.py
|
|
13
|
+
src/lmod_toolkit/test.py
|
|
11
14
|
src/lmod_toolkit.egg-info/PKG-INFO
|
|
12
15
|
src/lmod_toolkit.egg-info/SOURCES.txt
|
|
13
16
|
src/lmod_toolkit.egg-info/dependency_links.txt
|
|
14
17
|
src/lmod_toolkit.egg-info/scm_file_list.json
|
|
15
18
|
src/lmod_toolkit.egg-info/scm_version.json
|
|
16
19
|
src/lmod_toolkit.egg-info/top_level.txt
|
|
20
|
+
src/lmod_toolkit/bin/lmtk-test.sh
|
|
17
21
|
utils/quickstart.sh
|
|
18
22
|
utils/uv_installer.sh
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
"pyproject.toml",
|
|
8
8
|
"setup.sh",
|
|
9
9
|
"src/lmod_toolkit/__init__.py",
|
|
10
|
+
"src/lmod_toolkit/bin/lmtk-test.sh",
|
|
10
11
|
"src/lmod_toolkit/build_helper.py",
|
|
11
12
|
"src/lmod_toolkit/lmod_config.py",
|
|
13
|
+
"src/lmod_toolkit/lmod_ext_attrs.py",
|
|
14
|
+
"src/lmod_toolkit/lmod_spider.py",
|
|
15
|
+
"src/lmod_toolkit/test.py",
|
|
12
16
|
"utils/quickstart.sh",
|
|
13
17
|
"utils/uv_installer.sh"
|
|
14
18
|
]
|
|
@@ -19,6 +19,9 @@ LMTK_INSTALL_DIR="${HOME}"/lmod-toolkit
|
|
|
19
19
|
# set to "yes" or leave unset (defaults to latest)
|
|
20
20
|
# LMTK_ALLOW_PRE_RELEASE=yes
|
|
21
21
|
|
|
22
|
+
# set to "yes" to enable upgrading lmod-toolkit
|
|
23
|
+
# LMTK_ALLOW_UPGRADE=yes
|
|
24
|
+
|
|
22
25
|
# specify an exact version of LMTK
|
|
23
26
|
# get version string from
|
|
24
27
|
# https://pypi.org/project/lmod-toolkit/#history (production releases)
|
|
@@ -52,6 +55,7 @@ VENV="${LMTK_INSTALL_DIR}"/.venv
|
|
|
52
55
|
export LMTK_UV_URL
|
|
53
56
|
export LMTK_INSTALL_DIR
|
|
54
57
|
[[ -n "${LMTK_ALLOW_PRE_RELEASE}" ]] && export LMTK_ALLOW_PRE_RELEASE
|
|
58
|
+
[[ -n "${LMTK_ALLOW_UPGRADE}" ]] && export LMTK_ALLOW_UPGRADE
|
|
55
59
|
[[ -n "${LMTK_UV_PYTHON}" ]] && export LMTK_UV_PYTHON
|
|
56
60
|
[[ -n "${LMTK_INSTALL_VERSION}" ]] && export LMTK_INSTALL_VERSION
|
|
57
61
|
|
|
@@ -77,5 +81,5 @@ ${ACTION} curl -o "${LMTK_SETUP}" "${LMTK_SETUP_URL}"
|
|
|
77
81
|
${ACTION} bash "${LMTK_SETUP}"
|
|
78
82
|
|
|
79
83
|
# validate install
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
${ACTION} "${VENV}"/bin/python --version
|
|
85
|
+
${ACTION} "${INSTALL_DIR}"/uv/uv --directory "${INSTALL_DIR}" pip freeze
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from . import lmod_config
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|