freesurfer: fix support for linux (#39864)
* Load the script file during enviroment setup so that all the enviroment variables are set properly * Patch csh/tcsh so that it uses spacks via env * Update SHA for latest version * Extend shebang to perl and fix up the regex
This commit is contained in:
parent
1ebf1c8d1c
commit
9ed9a541c9
1 changed files with 23 additions and 2 deletions
|
@ -3,7 +3,11 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
from spack.util.environment import EnvironmentModifications
|
||||||
|
|
||||||
|
|
||||||
class Freesurfer(Package):
|
class Freesurfer(Package):
|
||||||
|
@ -14,11 +18,11 @@ class Freesurfer(Package):
|
||||||
|
|
||||||
# A license is required, but is free to obtain.
|
# A license is required, but is free to obtain.
|
||||||
license_required = True
|
license_required = True
|
||||||
license_files = ["./license.txt"]
|
license_files = [".license"]
|
||||||
|
|
||||||
maintainers("robgics")
|
maintainers("robgics")
|
||||||
|
|
||||||
version("7.4.1", sha256="eb6545d1ffdee17a90abd2e7dc444aa1091a6138e257f6f956a7ff214635b092")
|
version("7.4.1", sha256="313a96caeb246c5985f483633b5cf43f86ed8f7ccc6d6acfac8eedb638443010")
|
||||||
version("7.4.0", sha256="6b65c2edf3b88973ced0324269a88966c541f221b799337c6570c38c2f884431")
|
version("7.4.0", sha256="6b65c2edf3b88973ced0324269a88966c541f221b799337c6570c38c2f884431")
|
||||||
version("7.3.2", sha256="58518d3ee5abd2e05109208aed2eef145c4e3b994164df8c4e0033c1343b9e56")
|
version("7.3.2", sha256="58518d3ee5abd2e05109208aed2eef145c4e3b994164df8c4e0033c1343b9e56")
|
||||||
version("7.2.0", sha256="4cca78602f898bf633428b9d82cbb9b07e3ab97a86c620122050803779c86d62")
|
version("7.2.0", sha256="4cca78602f898bf633428b9d82cbb9b07e3ab97a86c620122050803779c86d62")
|
||||||
|
@ -27,6 +31,9 @@ class Freesurfer(Package):
|
||||||
|
|
||||||
depends_on("mesa-glu")
|
depends_on("mesa-glu")
|
||||||
depends_on("qt")
|
depends_on("qt")
|
||||||
|
depends_on("tcsh")
|
||||||
|
depends_on("bc")
|
||||||
|
depends_on("perl")
|
||||||
|
|
||||||
def url_for_version(self, version):
|
def url_for_version(self, version):
|
||||||
return "https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/{0}/freesurfer-linux-centos7_x86_64-{1}.tar.gz".format(
|
return "https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/{0}/freesurfer-linux-centos7_x86_64-{1}.tar.gz".format(
|
||||||
|
@ -34,10 +41,24 @@ def url_for_version(self, version):
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup_run_environment(self, env):
|
def setup_run_environment(self, env):
|
||||||
|
source_file = join_path(self.prefix, "SetUpFreeSurfer.sh")
|
||||||
env.prepend_path("PATH", self.prefix.bin)
|
env.prepend_path("PATH", self.prefix.bin)
|
||||||
env.set("FREESURFER_HOME", self.prefix)
|
env.set("FREESURFER_HOME", self.prefix)
|
||||||
env.set("SUBJECTS_DIR", join_path(self.prefix, "subjects"))
|
env.set("SUBJECTS_DIR", join_path(self.prefix, "subjects"))
|
||||||
env.set("FUNCTIONALS_DIR", join_path(self.prefix, "sessions"))
|
env.set("FUNCTIONALS_DIR", join_path(self.prefix, "sessions"))
|
||||||
|
env.append_path("PERL5LIB", join_path(self.prefix, "mni/share/perl5"))
|
||||||
|
env.append_path("PATH", join_path(self.prefix, "mni/bin"))
|
||||||
|
env.extend(EnvironmentModifications.from_sourcing_file(source_file))
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
|
scripts = ["sources.csh", "SetUpFreeSurfer.csh"]
|
||||||
|
scripts.extend(glob.glob("bin/*"))
|
||||||
|
scripts.extend(glob.glob("subjects/**/*", recursive=True))
|
||||||
|
scripts.extend(glob.glob("fsfast/bin/*", recursive=True))
|
||||||
|
scripts.extend(glob.glob("mni/bin/*", recursive=True))
|
||||||
|
for s in scripts:
|
||||||
|
if os.path.isfile(s):
|
||||||
|
filter_file(r"(\/usr)?(\/local?)\/bin\/tcsh", "/usr/bin/env -S tcsh", s)
|
||||||
|
filter_file(r"(\/usr)?(\/local?)\/bin\/csh", "/usr/bin/env -S csh", s)
|
||||||
|
filter_file(r"(\/usr)?(\/local)?\/bin\/perl", "/usr/bin/env -S perl", s)
|
||||||
install_tree(".", prefix)
|
install_tree(".", prefix)
|
||||||
|
|
Loading…
Reference in a new issue