Skip to content

Windows skips host/build env activation when packaging a recipe named conda #6069

Description

@danyeaw

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

When building a recipe whose package name is conda on Windows, conda-build does not write activation into build_env_setup.bat. Host etc/conda/activate.d scripts therefore never run during the build.

Unix has no equivalent skip: activate_build_script still writes shell activation (including _CONDA_BUILD_ISOLATED_ACTIVATION via python -I -m conda shell.bash hook).

Observed impact: conda canary builds on Windows ship mismatched versions — conda list shows the recipe/PKG_VERSION string, while conda --version / conda.__version__ come from hatch-vcs/git because defaults setuptools-scm never gets to set SETUPTOOLS_SCM_PRETEND_VERSION=%PKG_VERSION%. Linux canaries match. Tracked downstream as conda/conda#16460.

Root cause: in conda_build/windows.py:

if m.config.activate and m.name() != "conda":
    write_bat_activation_text(fo, m)

Historical reason was #2381 (avoid creating symlinks/.bat files when building conda). Unix later gained isolated activation for packaging conda; Windows build activation still hard-skips and never consults _CONDA_BUILD_ISOLATED_ACTIVATION.

Expected: With activation enabled (and especially with _CONDA_BUILD_ISOLATED_ACTIVATION=1), Windows should activate host/build envs when packaging conda the same way Unix does, so activate.d scripts run.

Conda Info

N/A (packaging bug in conda-build; reproduced in conda canary CI)

Conda Config

N/A

Conda list

N/A

Additional Context

  • Repro CI: https://github.com/conda/conda/actions/runs/30258767626 (win-64 vs linux-64)
    • Linux log: conda package setuptools_scm activate script: setting SETUPTOOLS_SCM_PRETEND_VERSION=26.7.0.129+g397bbb548 when CONDA_BUILD=1
    • Windows log: CONDA_BUILD=1 and PKG_VERSION=… are set, but that activate echo never appears; pip installs conda-26.5.4.dev129 while the conda package is 26.7.0.129+g397bbb548
  • Related code:
    • Skip: conda_build/windows.py (name() != "conda")
    • Unix activation (no name skip): conda_build/build.py write_build_scripts / _write_sh_activation_text
    • Windows activation writer (no isolated-activation wiring): conda_build/utils.py write_bat_activation_text
  • Suggested direction: allow activation when packaging conda under isolated activation; wire _CONDA_BUILD_ISOLATED_ACTIVATION into write_bat_activation_text; add a Windows test for a recipe named conda that asserts a host activate.d env var is visible in the build.

Metadata

Metadata

Assignees

Labels

os::windowsrelevant to Windowstype::bugdescribes erroneous operation, use severity::* to classify the type

Type

No type

Projects

Status
In review 🔍

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions