Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build_wheel_off.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build wheel and release into PYPI (off now)


on:
push:
branches:
Expand Down
194 changes: 105 additions & 89 deletions automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,95 +732,15 @@ def _run(self, i):
variation_tags_string = r['variation_tags_string']
explicit_variation_tags = r['explicit_variation_tags']

# USE CASE:
# HERE we may have versions in script input and env['MLC_VERSION_*']

# STEP 900: Get version, min, max, usable from env (priority if passed from another script to force version),
# then script input, then script meta

# VERSIONS SHOULD NOT BE USED INSIDE VARIATIONS (in meta)!

# First, take version from input
version = str(i.get('version', '')).strip()
version_min = str(i.get('version_min', '')).strip()
version_max = str(i.get('version_max', '')).strip()
version_max_usable = str(i.get('version_max_usable', '')).strip()

# Second, take from env
if version == '':
version = str(env.get('MLC_VERSION', ''))
if version_min == '':
version_min = str(env.get('MLC_VERSION_MIN', ''))
if version_max == '':
version_max = str(env.get('MLC_VERSION_MAX', ''))
if version_max_usable == '':
version_max_usable = str(env.get(
'MLC_VERSION_MAX_USABLE', ''))

# Third, take from meta
if version == '':
version = str(meta.get('version', ''))
if version_min == '':
version_min = str(meta.get('version_min', ''))
if version_max == '':
version_max = str(meta.get('version_max', ''))
if version_max_usable == '':
version_max_usable = str(meta.get(
'version_max_usable', ''))

# Update env with resolved versions
notes = []
for version_index in [(version, 'MLC_VERSION', ' == {}'),
(version_min, 'MLC_VERSION_MIN', ' >= {}'),
(version_max, 'MLC_VERSION_MAX', ' <= {}'),
(version_max_usable, 'MLC_VERSION_MAX_USABLE', '({})')]:
version_value = version_index[0]
key = version_index[1]
note = version_index[2]

if version_value != '':
env[key] = version_value

notes.append(note.format(version_value))
# elif key in env:
# # If version_X is "", remove related key from ENV ...
# del(env[key])

if len(notes) > 0:
logger.debug(
self.recursion_spaces +
' - Requested version: ' +
' '.join(notes))

# STEP 900 output: version* set
# env['MLC_VERSION*] set

# STEP 1000: Update version only if in "versions" (not obligatory)
# can be useful when handling complex Git revisions
versions = script_item.meta.get('versions', {})

if version != '' and version in versions:
versions_meta = versions[version]
r = self.update_state_from_meta(
versions_meta,
run_state,
i)
if r['return'] > 0:
return r
adr = get_adr(versions_meta)
if adr:
self._merge_dicts_with_tags(add_deps_recursive, adr)
# Processing them again using updated deps for
# add_deps_recursive
r = update_adr_from_meta(
deps,
post_deps,
prehook_deps,
posthook_deps,
add_deps_recursive,
env)

# STEP 1100: Update deps from input
r = self._update_state_from_version(meta, i)
version = r['version']
version_min = r['version_min']
version_max = r['version_max']
version_max_usable = r['version_max_usable']
versions = r['versions']

# STEP 1100: Update deps from input -? is this needed as we update adr
# from meta anyway
r = update_deps_from_input(
deps, post_deps, prehook_deps, posthook_deps, i)
if r['return'] > 0:
Expand Down Expand Up @@ -1985,6 +1905,102 @@ def _run(self, i):

return rr

##########################################################################
def _update_state_from_version(self, meta, i):

# USE CASE:
# HERE we may have versions in script input and env['MLC_VERSION_*']

# STEP 900: Get version, min, max, usable from env (priority if passed from another script to force version),
# then script input, then script meta

# VERSIONS SHOULD NOT BE USED INSIDE VARIATIONS (in meta)!

# First, take version from input
version = str(i.get('version', '')).strip()
version_min = str(i.get('version_min', '')).strip()
version_max = str(i.get('version_max', '')).strip()
version_max_usable = str(i.get('version_max_usable', '')).strip()

env = self.env

# Second, take from env
if version == '':
version = str(env.get('MLC_VERSION', ''))
if version_min == '':
version_min = str(env.get('MLC_VERSION_MIN', ''))
if version_max == '':
version_max = str(env.get('MLC_VERSION_MAX', ''))
if version_max_usable == '':
version_max_usable = str(env.get(
'MLC_VERSION_MAX_USABLE', ''))

# Third, take from meta
if version == '':
version = str(meta.get('version', ''))
if version_min == '':
version_min = str(meta.get('version_min', ''))
if version_max == '':
version_max = str(meta.get('version_max', ''))
if version_max_usable == '':
version_max_usable = str(meta.get(
'version_max_usable', ''))

# Update env with resolved versions
notes = []
for version_index in [(version, 'MLC_VERSION', ' == {}'),
(version_min, 'MLC_VERSION_MIN', ' >= {}'),
(version_max, 'MLC_VERSION_MAX', ' <= {}'),
(version_max_usable, 'MLC_VERSION_MAX_USABLE', '({})')]:
version_value = version_index[0]
key = version_index[1]
note = version_index[2]

if version_value != '':
env[key] = version_value

notes.append(note.format(version_value))
# elif key in env:
# # If version_X is "", remove related key from ENV ...
# del(env[key])

if len(notes) > 0:
self.logger.debug(
self.recursion_spaces +
' - Requested version: ' +
' '.join(notes))

# STEP 900 output: version* set
# env['MLC_VERSION*] set

# STEP 1000: Update version only if in "versions" (not obligatory)
# can be useful when handling complex Git revisions
versions = meta.get('versions', {})

if version != '' and version in versions:
versions_meta = versions[version]
r = self.update_state_from_meta(
versions_meta,
self.run_state,
i)
if r['return'] > 0:
return r
adr = get_adr(versions_meta)
if adr:
self._merge_dicts_with_tags(add_deps_recursive, adr)
# Processing them again using updated deps for
# add_deps_recursive
r = update_adr_from_meta(
deps,
post_deps,
prehook_deps,
posthook_deps,
add_deps_recursive,
env)

return {'return': 0, 'version': version, 'version_min': version_min,
'version_max': version_max, 'version_max_usable': version_max_usable, 'versions': versions}

##########################################################################

def _update_env_from_input(self, env, i):
Expand Down
Loading