Skip to content

Commit

Permalink
Add ability to provide defaults for custom options
Browse files Browse the repository at this point in the history
  • Loading branch information
mbargull committed Mar 2, 2017
1 parent a7c9de2 commit 6c6cf57
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,17 @@ The color of the default images (when not providing explicit image files)
used on Windows. Possible values are `red`, `green`, `blue`, `yellow`.
The default is `blue`.


`add_to_path_default`:
----------------
Default choice for whether to add the installation to the PATH environment
variable. The user is still able to change this during interactive
installation.


`register_python_default`:
----------------
Default choice for whether to register the installed Python instance as the
system's default Python. The user is still able to change this during
interactive installation. (Windows only)

12 changes: 12 additions & 0 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@
The color of the default images (when not providing explicit image files)
used on Windows. Possible values are `red`, `green`, `blue`, `yellow`.
The default is `blue`.
'''),

('add_to_path_default', False, bool, '''
Default choice for whether to add the installation to the PATH environment
variable. The user is still able to change this during interactive
installation.
'''),

('register_python_default', False, bool, '''
Default choice for whether to register the installed Python instance as the
system's default Python. The user is still able to change this during
interactive installation. (Windows only)
'''),
]

Expand Down
6 changes: 6 additions & 0 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ then
BASH_RC=$HOME/.bashrc
DEFAULT=no
#endif
#if add_to_path_default is True
DEFAULT=yes
#endif
#if add_to_path_default is False
DEFAULT=no
#endif

echo -n "Do you wish the installer to prepend the __NAME__ install location
to PATH in your $BASH_RC ? [yes|no]
Expand Down
14 changes: 14 additions & 0 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,20 @@ Function .onInit

# Initialize the default settings for the anaconda custom options
Call mui_AnaCustomOptions_InitDefaults
# Override custom options with explicitly given values from contruct.yaml.
# If add_to_path_default (register_python_default) is None, do nothing.
#if add_to_path_default is True
StrCpy $Ana_AddToPath_State ${BST_CHECKED}
#endif
#if add_to_path_default is False
StrCpy $Ana_AddToPath_State ${BST_UNCHECKED}
#endif
#if register_python_default is True
StrCpy $Ana_RegisterSystemPython_State ${BST_CHECKED}
#endif
#if register_python_default is False
StrCpy $Ana_RegisterSystemPython_State ${BST_UNCHECKED}
#endif

Pop $R2
Pop $R1
Expand Down
1 change: 1 addition & 0 deletions constructor/shar.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_header(tarball, info):
ppd['has_license'] = has_license
for key in 'pre_install', 'post_install':
ppd['has_%s' % key] = bool(key in info)
ppd['add_to_path_default'] = info.get('add_to_path_default', None)

install_lines = ['install_dist %s' % d for d in dists]
install_lines.extend(add_condarc(info))
Expand Down
5 changes: 4 additions & 1 deletion constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def make_nsi(info, dir_path):
replace[key] = str_esc(replace[key])

data = read_nsi_tmpl()
data = preprocess(data, ns_platform(info['_platform']))
ppd = ns_platform(info['_platform'])
ppd['add_to_path_default'] = info.get('add_to_path_default', None)
ppd['register_python_default'] = info.get('register_python_default', None)
data = preprocess(data, ppd)
data = fill_template(data, replace)

cmds = pkg_commands(download_dir, dists, py_version,
Expand Down

0 comments on commit 6c6cf57

Please sign in to comment.