miniforge3: wrong sbang replacement (#47178)

This commit is contained in:
Martin Lang 2024-10-24 21:26:04 +02:00 committed by GitHub
parent 4511052d26
commit b063765c2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,6 +56,21 @@ def install(self, spec, prefix):
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))