Skip to content

Commit

Permalink
Applied suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: jaimergp <[email protected]>
  • Loading branch information
jlstevens and jaimergp authored Sep 25, 2023
1 parent b95078f commit c7a2965
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions constructor/osxpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ def move_script(src, dst, info, ensure_shebang=False, user_script_type=None):
'CONSTRUCTOR_VERSION': info['CONSTRUCTOR_VERSION'],
}
data = preprocess(data, ppd)
custom_variables = info.get('extra_env_variables', [])
custom_variables = info.get('extra_env_variables', {})
data = fill_template(data, replace)

data = data.replace("_EXTRA_ENV_VARIABLES_=''", '\n'.join([f'export {var}' for var in custom_variables]))
data = data.replace("_EXTRA_ENV_VARIABLES_=''", '\n'.join([f'export {key}={value}' for key, value in custom_variables.items()]))


with open(dst, 'w') as fo:
Expand Down
4 changes: 2 additions & 2 deletions constructor/shar.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def get_header(conda_exec, tarball, info):

data = read_header_template()
data = preprocess(data, ppd)
custom_variables = info.get('extra_env_variables', [])
custom_variables = info.get('extra_env_variables', {})
data = fill_template(data, replace)

data = data.replace("_EXTRA_ENV_VARIABLES_=''", '\n'.join(
[f'export {var}' for var in custom_variables]))
[f'export {key}={value}' for key, value in custom_variables.items()]))
return data


Expand Down
7 changes: 2 additions & 5 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ def setup_extra_env_variables(info) -> List[str]:
List[str]: Commands to be inserted into nsi template
"""
lines = []
for variable in info.get('extra_env_variables',[]):
split = variable.split('=')
if len(split)==2:
(name, val) = split
lines.append(f"""System::Call 'kernel32::SetEnvironmentVariable(t,t)i("{name}", "{val}").r0'""")
for name, value in info.get('extra_env_variables', {}).items():
lines.append(f"""System::Call 'kernel32::SetEnvironmentVariable(t,t)i("{name}", {str_esc(value)}).r0'""")

return lines

Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ specs:
- python

extra_env_variables:
- CUSTOM_VARIABLE_1=CUSTOM1
- CUSTOM_VARIABLE_2=CUSTOM2
CUSTOM_VARIABLE_1: CUSTOM1
CUSTOM_VARIABLE_2: CUSTOM2

pre_install: pre_install.sh # [unix]
pre_install: pre_install.bat # [win]
Expand Down

0 comments on commit c7a2965

Please sign in to comment.