Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
conda
installer
Commits
d98d4230
Commit
d98d4230
authored
Aug 12, 2021
by
Paul McCarthy
🚵
Browse files
Merge branch 'bf/condainstall' into 'master'
Bf/condainstall See merge request fsl/conda/installer!17
parents
479a677f
4b7546fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
fslinstaller.py
View file @
d98d4230
...
@@ -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.3.
0
'
__version__
=
'1.3.
1
'
"""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.
"""
"""
...
@@ -1276,7 +1276,7 @@ def install_fsl(ctx):
...
@@ -1276,7 +1276,7 @@ def install_fsl(ctx):
commands
=
[]
commands
=
[]
if
ctx
.
fsl_base_version
is
not
None
:
if
ctx
.
fsl_base_version
is
not
None
:
commands
.
append
(
commands
.
append
(
conda
+
'install -y -n base fsl-base='
+
ctx
.
fsl_base_version
)
conda
+
'
install -y -n base fsl-base='
+
ctx
.
fsl_base_version
)
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
))
...
...
test/test_installer.py
View file @
d98d4230
#!/usr/bin/env python
#!/usr/bin/env python
import
os
import
os
import
os.path
as
op
import
os.path
as
op
import
contextlib
import
contextlib
import
shutil
import
shutil
...
@@ -35,14 +35,18 @@ mkdir -p $prefix/etc/
...
@@ -35,14 +35,18 @@ mkdir -p $prefix/etc/
prefix=$(cd $prefix && pwd)
prefix=$(cd $prefix && pwd)
# called like conda env update -n base -f <envfile>
# called like
# and like conda clean -y --all
# - conda install -y -n base fslbase=1234.0
# - conda env update -n base -f <envfile>
# - conda clean -y --all
echo "#!/usr/bin/env bash" >> $3/bin/conda
echo "#!/usr/bin/env bash" >> $3/bin/conda
echo 'if [ "$1" = "clean" ]; then ' >> $3/bin/conda
echo 'if [ "$1" = "clean" ]; then ' >> $3/bin/conda
echo " touch $prefix/cleaned" >> $3/bin/conda
echo " touch $prefix/cleaned" >> $3/bin/conda
echo "else" >> $3/bin/conda
echo 'elif [ "$1" = "install" ]; then ' >> $3/bin/conda
echo " cp "'$6'" $prefix/" >> $3/bin/conda
echo ' echo "$5"' "> $prefix/installed" >> $3/bin/conda
echo "fi" >> $3/bin/conda
echo "else" >> $3/bin/conda
echo " cp "'$6'" $prefix/" >> $3/bin/conda
echo "fi" >> $3/bin/conda
chmod a+x $prefix/bin/conda
chmod a+x $prefix/bin/conda
"""
.
strip
()
"""
.
strip
()
...
@@ -82,6 +86,14 @@ mock_manifest = """
...
@@ -82,6 +86,14 @@ mock_manifest = """
# Format vars: version platform url conda_sha256 env610_sha256 env620_sha256
# Format vars: version platform url conda_sha256 env610_sha256 env620_sha256
mock_env_yml_template
=
"""
{version}
packages:
- fsl-base 1234.0
"""
.
strip
()
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
def
installer_server
(
cwd
=
None
):
def
installer_server
(
cwd
=
None
):
if
cwd
is
None
:
if
cwd
is
None
:
...
@@ -89,9 +101,12 @@ def installer_server(cwd=None):
...
@@ -89,9 +101,12 @@ def installer_server(cwd=None):
cwd
=
op
.
abspath
(
cwd
)
cwd
=
op
.
abspath
(
cwd
)
with
indir
(
cwd
),
server
(
cwd
)
as
srv
:
with
indir
(
cwd
),
server
(
cwd
)
as
srv
:
with
open
(
'miniconda.sh'
,
'wt'
)
as
f
:
f
.
write
(
mock_miniconda_sh
)
with
open
(
'miniconda.sh'
,
'wt'
)
as
f
:
with
open
(
'env-6.1.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
'6.1.0'
)
f
.
write
(
mock_miniconda_sh
)
with
open
(
'env-6.2.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
'6.2.0'
)
with
open
(
'env-6.1.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
mock_env_yml_template
.
format
(
version
=
'6.1.0'
))
with
open
(
'env-6.2.0.yml'
,
'wt'
)
as
f
:
f
.
write
(
mock_env_yml_template
.
format
(
version
=
'6.2.0'
))
conda_sha256
=
inst
.
sha256
(
'miniconda.sh'
)
conda_sha256
=
inst
.
sha256
(
'miniconda.sh'
)
env610_sha256
=
inst
.
sha256
(
'env-6.1.0.yml'
)
env610_sha256
=
inst
.
sha256
(
'env-6.1.0.yml'
)
...
@@ -119,15 +134,23 @@ def check_install(homedir, destdir, version):
...
@@ -119,15 +134,23 @@ def check_install(homedir, destdir, version):
profile
=
inst
.
configure_shell
.
shell_profiles
.
get
(
shell
,
None
)
profile
=
inst
.
configure_shell
.
shell_profiles
.
get
(
shell
,
None
)
with
indir
(
destdir
):
with
indir
(
destdir
):
with
open
(
op
.
join
(
etc
,
'fslversion'
),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
version
# added by our mock conda env creeate call
# added by our mock conda env creeate call
with
open
(
op
.
join
(
destdir
,
'env-{}.yml'
.
format
(
version
)),
'rt'
)
as
f
:
with
open
(
op
.
join
(
destdir
,
'env-{}.yml'
.
format
(
version
)),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
version
exp
=
mock_env_yml_template
.
format
(
version
=
version
)
assert
f
.
read
().
strip
()
==
exp
# added by our mock conda install call
with
open
(
op
.
join
(
destdir
,
'installed'
),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
'fsl-base=1234.0'
assert
op
.
exists
(
op
.
join
(
etc
,
'fslinstaller.py'
))
# added by our mock conda clean call
assert
op
.
exists
(
op
.
join
(
etc
,
'env-{}.yml'
.
format
(
version
)))
assert
op
.
exists
(
op
.
join
(
destdir
,
'cleaned'
))
# added by the fslinstaller
with
open
(
op
.
join
(
etc
,
'fslversion'
),
'rt'
)
as
f
:
assert
f
.
read
().
strip
()
==
version
assert
op
.
exists
(
op
.
join
(
etc
,
'fslinstaller.py'
))
assert
op
.
exists
(
op
.
join
(
etc
,
'env-{}.yml'
.
format
(
version
)))
assert
op
.
exists
(
op
.
join
(
homedir
,
'Documents'
,
'MATLAB'
))
assert
op
.
exists
(
op
.
join
(
homedir
,
'Documents'
,
'MATLAB'
))
if
profile
is
not
None
:
if
profile
is
not
None
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment