Commit 2252568b authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rf/base_packages' into 'master'

Rf/base packages

See merge request fsl/conda/installer!24
parents 78349215 edc70b0b
...@@ -29,7 +29,6 @@ import shutil ...@@ -29,7 +29,6 @@ import shutil
import sys import sys
import tempfile import tempfile
import threading import threading
import time
import traceback import traceback
# TODO check py2/3 # TODO check py2/3
...@@ -52,7 +51,7 @@ log = logging.getLogger(__name__) ...@@ -52,7 +51,7 @@ log = logging.getLogger(__name__)
__absfile__ = op.abspath(__file__).rstrip('c') __absfile__ = op.abspath(__file__).rstrip('c')
__version__ = '1.3.7' __version__ = '1.4.0'
"""Installer script version number. This must be updated """Installer script version number. This must be updated
whenever a new version of the installer script is released. whenever a new version of the installer script is released.
""" """
...@@ -161,11 +160,11 @@ class Context(object): ...@@ -161,11 +160,11 @@ class Context(object):
# The download_fsl_environment function stores # The download_fsl_environment function stores
# the path to the FSL conda environment file, # the path to the FSL conda environment file,
# list of conda channels, and fsl-base version, # list of conda channels, and versions of a
# here. # small set of "base" packages here.
self.environment_file = None self.environment_file = None
self.environment_channels = None self.environment_channels = None
self.fsl_base_version = None self.fsl_base_packages = None
# The config_logging function stores the path # The config_logging function stores the path
# to the fslinstaller log file here. # to the fslinstaller log file here.
...@@ -1078,11 +1077,13 @@ def download_fsl_environment(ctx): ...@@ -1078,11 +1077,13 @@ def download_fsl_environment(ctx):
if ctx.args.environment is None: if ctx.args.environment is None:
build = ctx.build build = ctx.build
url = build['environment'] url = build['environment']
checksum = build['sha256'] checksum = build.get('sha256', None)
basepkgnames = build.get('base_packages', [])
else: else:
build = {} build = {}
url = ctx.args.environment url = ctx.args.environment
checksum = None checksum = None
basepkgnames = []
printmsg('Downloading FSL environment specification ' printmsg('Downloading FSL environment specification '
'from {}...'.format(url)) 'from {}...'.format(url))
...@@ -1120,14 +1121,13 @@ def download_fsl_environment(ctx): ...@@ -1120,14 +1121,13 @@ def download_fsl_environment(ctx):
# The install_miniconda function will then add the # The install_miniconda function will then add the
# channels to $FSLDIR/.condarc. # channels to $FSLDIR/.condarc.
# #
# The fsl-base version is installed before any other # A collection of "base" packages are installed
# packages, as other FSL packages require it to be # before any other packages. So we also extract the
# present in order to install successfully. So we # version numbers of these base packages from the
# also extract the fsl-base version number from # environment file, and store them in the context.
# the environment file, and store it in the context.
channels = []
basever = None
copy = '.' + op.basename(ctx.environment_file) copy = '.' + op.basename(ctx.environment_file)
channels = []
basepkgs = {}
shutil.move(ctx.environment_file, copy) shutil.move(ctx.environment_file, copy)
with open(copy, 'rt') as inf, \ with open(copy, 'rt') as inf, \
open(ctx.environment_file, 'wt') as outf: open(ctx.environment_file, 'wt') as outf:
...@@ -1149,15 +1149,17 @@ def download_fsl_environment(ctx): ...@@ -1149,15 +1149,17 @@ def download_fsl_environment(ctx):
channels.append(line.split()[-1]) channels.append(line.split()[-1])
continue continue
# save fsl-base version, as # save base package versions, as
# we install it separately # we install them separately
if line.strip().startswith('- fsl-base'): for pkg in basepkgnames:
basever = line.split()[2] if line.strip().startswith('- {}'.format(pkg)):
pkgver = line.strip().split(' ', 2)[2]
basepkgs[pkg] = pkgver.replace(' ', '=')
outf.write(line) outf.write(line)
ctx.environment_channels = channels ctx.environment_channels = channels
ctx.fsl_base_version = basever ctx.fsl_base_packages = basepkgs
def download_miniconda(ctx): def download_miniconda(ctx):
...@@ -1270,18 +1272,23 @@ def install_fsl(ctx): ...@@ -1270,18 +1272,23 @@ def install_fsl(ctx):
# We install FSL in two steps: # We install FSL in two steps:
# #
# 1. Install fsl-base. This is installed first, as other # 1. Install base packages. This is installed first, as
# FSL packages require it to be present during installation, # FSL packages require fsl-base to be present during
# (in their post-link.sh scripts), and this is not # installation (in their post-link.sh scripts), and
# guaranteed if everything is installed simultaneously # this is not guaranteed if everything is installed
# simultaneously. Also done for efficiency, so e.g.
# libopenblas variants don't get swapped back and
# forth.
# 2. Install everything else. # 2. Install everything else.
# #
# The download_fsl_environment function extracts the appropriate # The download_fsl_environment function extracts the
# fsl-base version to install. # appropriate base package versions to install.
commands = [] commands = []
if ctx.fsl_base_version is not None: if ctx.fsl_base_packages is not None and len(ctx.fsl_base_packages) > 0:
commands.append( basepkgs = ctx.fsl_base_packages
conda + ' install -y -n base fsl-base=' + ctx.fsl_base_version) basepkgs = ['{}={}'.format(pkg, ver) for pkg, ver in basepkgs.items()]
basepkgs = ' '.join(basepkgs)
commands.append(conda + ' install -y -n base ' + basepkgs)
commands.append(conda + ' env update -n base -f ' + ctx.environment_file) commands.append(conda + ' env update -n base -f ' + ctx.environment_file)
printmsg('Installing FSL into {}...'.format(ctx.destdir)) printmsg('Installing FSL into {}...'.format(ctx.destdir))
......
...@@ -70,14 +70,16 @@ mock_manifest = """ ...@@ -70,14 +70,16 @@ mock_manifest = """
{{ {{
"platform" : "{platform}", "platform" : "{platform}",
"environment" : "{url}/env-6.2.0.yml", "environment" : "{url}/env-6.2.0.yml",
"sha256" : "{env620_sha256}" "sha256" : "{env620_sha256}",
"base_packages" : ["fsl-base", "libopenblas"]
}} }}
], ],
"6.1.0" : [ "6.1.0" : [
{{ {{
"platform" : "{platform}", "platform" : "{platform}",
"environment" : "{url}/env-6.1.0.yml", "environment" : "{url}/env-6.1.0.yml",
"sha256" : "{env610_sha256}" "sha256" : "{env610_sha256}",
"base_packages" : ["fsl-base", "libopenblas"]
}} }}
] ]
}} }}
......
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