Commit 0c540eb0 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rf/user-condarc' into 'master'

RF: Make installer more resilient to existing conda installations

See merge request fsl/conda/installer!15
parents 0853f539 17d3a93f
...@@ -52,7 +52,7 @@ log = logging.getLogger(__name__) ...@@ -52,7 +52,7 @@ log = logging.getLogger(__name__)
__absfile__ = op.abspath(__file__).rstrip('c') __absfile__ = op.abspath(__file__).rstrip('c')
__version__ = '1.1.1' __version__ = '1.2.0'
"""Installer script version number. This is automatically updated """Installer script version number. This is automatically updated
whenever a new version of the installer script is released. whenever a new version of the installer script is released.
""" """
...@@ -1172,14 +1172,6 @@ def install_miniconda(ctx): ...@@ -1172,14 +1172,6 @@ def install_miniconda(ctx):
# Create .condarc config file # Create .condarc config file
condarc = tw.dedent(""" condarc = tw.dedent("""
# Putting a .condarc file into the root environment
# directory will override ~/.condarc if it exists,
# but will not override a system condarc (e.g. at
# /etc/condarc/condarc). There is currently no
# workaround for this - see:
# - https://github.com/conda/conda/issues/8599
# - https://github.com/conda/conda/issues/8804
# Try and make package downloads more robust # Try and make package downloads more robust
remote_read_timeout_secs: 240 remote_read_timeout_secs: 240
remote_connect_timeout_secs: 20 remote_connect_timeout_secs: 20
...@@ -1193,12 +1185,21 @@ def install_miniconda(ctx): ...@@ -1193,12 +1185,21 @@ def install_miniconda(ctx):
# ensure that conda-forge versions of e.g. VTK were # ensure that conda-forge versions of e.g. VTK were
# preferred over legacy FSL conda versions). # preferred over legacy FSL conda versions).
# #
# Use final/top/bottom marks to prevent the channel
# priority order being modified by user ~/.condarc
# configuration files.
#
# https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html
# https://www.anaconda.com/blog/conda-configuration-engine-power-users
# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-channels.html
channel_priority: strict #!final
channel_priority: strict
""") """)
condarc +='\nchannels:\n' channels = list(ctx.environment_channels)
for channel in ctx.environment_channels: if len(channels) > 0:
channels[0] += ' #!top'
channels[-1] += ' #!bottom'
condarc += '\nchannels: #!final\n'
for channel in channels:
condarc += ' - {}\n'.format(channel) condarc += ' - {}\n'.format(channel)
with open('.condarc', 'wt') as f: with open('.condarc', 'wt') as f:
...@@ -1232,11 +1233,11 @@ def install_fsl(ctx): ...@@ -1232,11 +1233,11 @@ def install_fsl(ctx):
printmsg('Installing FSL into {}...'.format(ctx.destdir)) printmsg('Installing FSL into {}...'.format(ctx.destdir))
# Clear any environment variables that # Clear any environment variables that refer
# refer to an existing FSL installation # to existing FSL or conda installations.
env = os.environ.copy() env = os.environ.copy()
for v in list(env.keys()): for v in list(env.keys()):
if 'FSL' in v: if any(('FSL' in v, 'CONDA' in v)):
env.pop(v) env.pop(v)
# post-link scripts call $FSLDIR/share/fsl/sbin/createFSLWrapper # post-link scripts call $FSLDIR/share/fsl/sbin/createFSLWrapper
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment