Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify which environment gets activated first #4942

Merged
merged 3 commits into from
Sep 18, 2023

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Jul 25, 2023

Description

Docs were wrong / out of date for this one. Comes from conda-forge/conda-forge.github.io#1841 (comment)

cc @jakirkham

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

Proof:

def _write_sh_activation_text(file_handle, m):
cygpath_prefix = "$(cygpath -u " if utils.on_win else ""
cygpath_suffix = " )" if utils.on_win else ""
py_flags = "-I -m" if os.environ.get("_CONDA_BUILD_ISOLATED_ACTIVATION") else "-m"
file_handle.write(
f"""eval "$('{sys.executable}' {py_flags} conda shell.bash hook)"\n"""
)
if m.is_cross:
# HACK: we need both build and host envs "active" - i.e. on PATH,
# and with their activate.d scripts sourced. Conda only
# lets us activate one, though. This is a
# vile hack to trick conda into "stacking"
# two environments.
#
# Net effect: binaries come from host first, then build
#
# Conda 4.4 may break this by reworking the activate scripts.
# ^^ shouldn't be true
# In conda 4.4, export CONDA_MAX_SHLVL=2 to stack envs to two
# levels deep.
# conda 4.4 does require that a conda-meta/history file
# exists to identify a valid conda environment
# conda 4.6 changes this one final time, by adding a '--stack' flag to the 'activate'
# command, and 'activate' does not stack environments by default without that flag
history_file = join(m.config.host_prefix, "conda-meta", "history")
if not isfile(history_file):
if not isdir(dirname(history_file)):
os.makedirs(dirname(history_file))
open(history_file, "a").close()
host_prefix_path = "".join(
(cygpath_prefix, m.config.host_prefix.replace("\\", "\\\\"), cygpath_suffix)
)
file_handle.write(f'conda activate "{host_prefix_path}"\n')
# Write build prefix activation AFTER host prefix, so that its executables come first
build_prefix_path = "".join(
(cygpath_prefix, m.config.build_prefix.replace("\\", "\\\\"), cygpath_suffix)
)
# Do not stack against base env when not cross.
stack = "--stack" if m.is_cross else ""
file_handle.write(f'conda activate {stack} "{build_prefix_path}"\n')

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jul 25, 2023
@jaimergp jaimergp marked this pull request as ready for review July 25, 2023 19:04
@jezdez jezdez changed the title docs: clarify which environment gets activated first Clarify which environment gets activated first Sep 18, 2023
@jezdez jezdez merged commit 47909da into conda:main Sep 18, 2023
9 checks passed
@kenodegard kenodegard mentioned this pull request Sep 26, 2023
36 tasks
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 18, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants