summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Lang <67915889+lang-m@users.noreply.github.com>2024-10-24 21:26:04 +0200
committerGitHub <noreply@github.com>2024-10-24 21:26:04 +0200
commitb063765c2efecb7937d9f6bbbbb34cd41efd1286 (patch)
treefff19158c03b8b2018783f95efde570d7857f095
parent4511052d26c02510517fb3f2ef3d2181dfbe71b3 (diff)
downloadspack-b063765c2efecb7937d9f6bbbbb34cd41efd1286.tar.gz
spack-b063765c2efecb7937d9f6bbbbb34cd41efd1286.tar.bz2
spack-b063765c2efecb7937d9f6bbbbb34cd41efd1286.tar.xz
spack-b063765c2efecb7937d9f6bbbbb34cd41efd1286.zip
miniforge3: wrong sbang replacement (#47178)
-rw-r--r--var/spack/repos/builtin/packages/miniforge3/package.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/miniforge3/package.py b/var/spack/repos/builtin/packages/miniforge3/package.py
index f690742aca..8f5d3c05e2 100644
--- a/var/spack/repos/builtin/packages/miniforge3/package.py
+++ b/var/spack/repos/builtin/packages/miniforge3/package.py
@@ -56,6 +56,21 @@ class Miniforge3(Package):
bash = which("bash")
bash(script, "-b", "-f", "-p", self.prefix)
+ @run_after("install")
+ def patch_sbang(self):
+ # Conda replaces the full path to the Python executable with `/usr/bin/env python`
+ # if the full path exceeds 127 characters. This does however break `conda deactivate`
+ # because the wrong Python interpreter is used after activating an environment.
+ # The 127 character limit is not relevant in Spack as Spack will automatically
+ # use the `sbang` script to deal with the overly long sbang line.
+ filter_file(
+ r"#!/usr/bin/env python", rf"#!{self.prefix.bin.python}", self.prefix.bin.conda
+ )
+ if "+mamba" in self.spec:
+ filter_file(
+ r"#!/usr/bin/env python", rf"#!{self.prefix.bin.python}", self.prefix.bin.mamba
+ )
+
def setup_run_environment(self, env):
filename = self.prefix.etc.join("profile.d").join("conda.sh")
env.extend(EnvironmentModifications.from_sourcing_file(filename))