Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
800206f
Crude schema migration to Pydantic model and JSON Schema
jaimergp Feb 28, 2025
500f97c
add $schema path in examples
jaimergp Feb 28, 2025
e3aa238
Add pydantic to dependencies, small fixes
jaimergp Feb 28, 2025
1ecaa7b
Refine types
jaimergp Feb 28, 2025
4d870ec
Generate documentation from Pydantic model
jaimergp Mar 5, 2025
0014436
Adjust documentation generation pipeline
jaimergp Mar 5, 2025
4316140
Implement JSON Schema validation
jaimergp Mar 5, 2025
8e995d5
Split Pydantic model to _schema.py and check up-to-date
jaimergp Mar 5, 2025
9dce9ed
Merge branch 'main' of github.com:conda/constructor into pydantic-schema
jaimergp Mar 5, 2025
4285932
Adjust `hash` description again
jaimergp Mar 5, 2025
e479ccf
pre-commit
jaimergp Mar 5, 2025
3f59e6e
cleanup
jaimergp Mar 5, 2025
1178425
Check docs and schema with Python 3.12 to use StrEnum
jaimergp Mar 5, 2025
44ca08b
Fix schema for extra_files
jaimergp Mar 5, 2025
0e15add
fix extra_envs schema
jaimergp Mar 5, 2025
5ff3828
Restore help message
jaimergp Mar 5, 2025
e4aadbf
add news
jaimergp Mar 5, 2025
3ea4e2e
Fix make_docs
jaimergp Mar 5, 2025
dc40fca
Restore description for exclude
jaimergp Mar 5, 2025
da0dac7
fix deprecations
jaimergp Mar 5, 2025
d50560e
pre-commit
jaimergp Mar 5, 2025
2c64a9d
fully restore --help-construct
jaimergp Mar 5, 2025
4beb978
pre-commit
jaimergp Mar 5, 2025
f1ddc96
Update scripts/make_docs.py
jaimergp Mar 6, 2025
ed88121
Use an enum for installer_type
jaimergp Mar 6, 2025
035ac75
Merge branch 'pydantic-schema' of github.com:jaimergp/constructor int…
jaimergp Mar 6, 2025
e894627
docs sync
jaimergp Mar 6, 2025
97df99b
Add pattern for virtual_specs str
jaimergp Mar 6, 2025
ac29a2e
Define schema for pkg_domains
jaimergp Mar 6, 2025
7693368
Allow several extra_files_* mappings per entry
jaimergp Mar 6, 2025
276d6e8
Merge branch 'main' of github.com:conda/constructor into pydantic-schema
jaimergp Mar 13, 2025
162e1b1
format
jaimergp Mar 13, 2025
8fe3384
Merge branch 'main' of github.com:conda/constructor into pydantic-schema
jaimergp Mar 13, 2025
c899906
address ruff lint suggestions
jaimergp Mar 13, 2025
a444c92
Fix missing Literal import in _schema
jaimergp Mar 13, 2025
c67b4cf
Adjust name and version regex
jaimergp Mar 14, 2025
f257927
Remove unneded runtime check
jaimergp Mar 14, 2025
3a4b4d7
Apply suggestions from code review
jaimergp Mar 24, 2025
9ea066c
Apply suggestions from code review
jaimergp Mar 24, 2025
1726343
Apply suggestions from code review
jaimergp Mar 24, 2025
2e846f5
add more files to 'extra_files' example
jaimergp Mar 24, 2025
fd95a1c
regenerate schema and docs
jaimergp Mar 24, 2025
b141bc6
always sort_keys
jaimergp Mar 24, 2025
179eca2
Fix whitespace in descriptions
jaimergp Mar 24, 2025
9dde3d2
sort here too
jaimergp Mar 24, 2025
5c649f2
add pydantic to run_constrained
jaimergp Mar 24, 2025
1f99e0f
Rename constructor.schema.json to construct.schema.json and add $sche…
jaimergp Mar 24, 2025
0099f2e
update news
jaimergp Mar 24, 2025
5ac7e7b
Define BuildOutputs enum
jaimergp Mar 24, 2025
63c6bbf
Add schema for build_outputs too
jaimergp Mar 24, 2025
dcc7b9e
regenerate
jaimergp Mar 24, 2025
a78e3b2
sort algorithms
jaimergp Mar 24, 2025
198753c
Merge branch 'main' of github.com:conda/constructor into pydantic-schema
jaimergp Mar 24, 2025
c67e253
Reword docstring for `initialize_conda`
jaimergp Mar 24, 2025
56e35a6
Draft implementation for condabin/ in PATH
jaimergp Mar 24, 2025
7f30991
add titles?
jaimergp Mar 24, 2025
505027f
classes?
jaimergp Mar 24, 2025
da0a074
Generate description dynamically
jaimergp Mar 24, 2025
1b86ba4
Format
jaimergp Mar 25, 2025
66c90f1
Fix codeblock line wrapping
jaimergp Mar 25, 2025
e922618
Small adjustments
jaimergp Mar 25, 2025
5660591
Merge branch 'pydantic-schema' of github.com:jaimergp/constructor int…
jaimergp Mar 25, 2025
0342e87
fix test_header::test_template_shellcheck
jaimergp Mar 25, 2025
e012982
like for real
jaimergp Mar 25, 2025
42172ff
fix header tests
jaimergp Mar 25, 2025
49fbbed
add one more answer to the interactive tests
jaimergp Mar 25, 2025
0d2c298
it's show_add_condabin_to_path here
jaimergp Mar 25, 2025
e3423e8
define AddCondabinToPath_OnClick
jaimergp Mar 25, 2025
c89ac76
fix var name
jaimergp Mar 25, 2025
5ef0b7d
these too
jaimergp Mar 25, 2025
57f9230
Merge branch 'condabin' of github.com:jaimergp/constructor; branch 'm…
jaimergp Mar 26, 2025
b623213
Reword NSIS GUI text
jaimergp Mar 26, 2025
96e0917
Merge branch 'main' into condabin
jaimergp Apr 7, 2025
639ae2c
Merge branch 'main' of github.com:conda/constructor into condabin
jaimergp Jun 2, 2025
6fa3bc9
use 'conda init --condabin'
jaimergp Jun 2, 2025
7425a68
Merge branch 'main' into condabin
jaimergp Jun 14, 2025
434a067
add news
jaimergp Jun 16, 2025
d44a889
Merge branch 'condabin' of github.com:jaimergp/constructor into condabin
jaimergp Jun 16, 2025
be62304
add test
jaimergp Jun 16, 2025
b2e80b4
fix example
jaimergp Jun 16, 2025
0aadf4b
check conda version
jaimergp Jun 16, 2025
69db7a9
false by default
jaimergp Jun 16, 2025
6eba227
Add choice box to PKG
jaimergp Jun 16, 2025
43e7352
update schema
jaimergp Jun 16, 2025
7bdc7b4
Adjust options UI in Windows installers
jaimergp Jun 16, 2025
3cbd090
add docs
jaimergp Jun 16, 2025
87bb9db
prevent PATH manipulation in All Users mode here too
jaimergp Jun 17, 2025
0c1e065
Only show CLI options if enabled
jaimergp Jun 17, 2025
89f186b
update test
jaimergp Jun 17, 2025
53028b1
add -c/-z condabin option, enable it in batch mode
jaimergp Jun 17, 2025
4059d10
pre-commit
jaimergp Jun 17, 2025
3d494be
posix
jaimergp Jun 17, 2025
3b4c789
fix if block
jaimergp Jun 17, 2025
e58d0b5
delayed expansion for windows
jaimergp Jun 17, 2025
1d6fd1c
fix if block again
jaimergp Jun 17, 2025
ee781f4
Apply suggestions from code review
jaimergp Jun 18, 2025
7900ba5
use default in help message
jaimergp Jun 18, 2025
2802e32
implement as enum in `initialize_conda` option
jaimergp Jun 24, 2025
c8b78aa
implement for windows
jaimergp Jun 24, 2025
bc5862d
implement for PKG
jaimergp Jun 24, 2025
5c15f73
implement for SH
jaimergp Jun 24, 2025
51330cb
adjust messaging
jaimergp Jun 24, 2025
ff904d0
Merge branch 'main' of github.com:conda/constructor into condabin
jaimergp Jun 24, 2025
fa2e30a
fix shell tests
jaimergp Jun 24, 2025
a248aa4
amend news
jaimergp Jun 24, 2025
912b7f5
parametrize osx script for conda init
jaimergp Jun 24, 2025
9a2df44
cleanup main.py checks
jaimergp Jun 24, 2025
d38c5ed
update old comment
jaimergp Jun 24, 2025
f7b71b6
amend news
jaimergp Jun 24, 2025
2a6da83
messaging cleanup
jaimergp Jun 24, 2025
3026211
fix nsis syntax
jaimergp Jun 24, 2025
59a00c6
Merge branch 'main' of github.com:conda/constructor into condabin
jaimergp Jun 24, 2025
825cdb8
pass options to test to force add-to-path
jaimergp Jun 24, 2025
acbb9a2
try paexec method to run windows tests as regular user
jaimergp Jun 25, 2025
1a9faad
install wget
jaimergp Jun 25, 2025
cc4f274
wrap in cmd?
jaimergp Jun 25, 2025
140aea0
split in two steps
jaimergp Jun 25, 2025
438eb84
this block is Windows-only too
jaimergp Jun 25, 2025
0082950
use Invoke-WebRequest directly
jaimergp Jun 25, 2025
b048549
use a safer password to satisfy system policy
jaimergp Jun 25, 2025
1edb7cd
trim password under 14 characters so net user doesn't prompt
jaimergp Jun 25, 2025
d5208e5
in system32?
jaimergp Jun 25, 2025
51d345d
hardcode absolute path to python?
jaimergp Jun 25, 2025
6daa1c9
debug
jaimergp Jun 25, 2025
24287bb
wrap again
jaimergp Jun 25, 2025
dc02656
debug 127
jaimergp Jun 25, 2025
2cf5f89
drop the .exe bit?
jaimergp Jun 25, 2025
4ec3655
chmod just in case?
jaimergp Jun 25, 2025
d681966
use powershell
jaimergp Jun 25, 2025
ea55a3c
no || token
jaimergp Jun 25, 2025
a6df42e
use select-string and $pwd
jaimergp Jun 25, 2025
a1704ab
query registry directly
jaimergp Jun 25, 2025
69fa11f
Remove leftover step
jaimergp Jun 25, 2025
3abfa81
Apply suggestions
jaimergp Jun 25, 2025
f08fe8c
test condabin example only for debugging
jaimergp Jun 25, 2025
e826197
debug linux
jaimergp Jun 25, 2025
6ba498f
skip windows too
jaimergp Jun 25, 2025
d995ad2
enable on failure
jaimergp Jun 25, 2025
74e277b
pre-commit
jaimergp Jun 25, 2025
f5657e1
only one python version
jaimergp Jul 7, 2025
2aab287
parametrize initialization methods, xfail some windows cases
jaimergp Jul 7, 2025
d0ce422
rename test
jaimergp Jul 7, 2025
2ecfda0
unquote
jaimergp Jul 7, 2025
0a0a48d
shell=False?
jaimergp Jul 7, 2025
d5159e7
add a cleanup finalizer
jaimergp Jul 7, 2025
7e02300
GHA seems to have a different login flag?
jaimergp Jul 7, 2025
7777f46
interactive shell instead of login
jaimergp Jul 7, 2025
0f90cb9
fix flags
jaimergp Jul 7, 2025
e4f6d63
restore workflow
jaimergp Jul 7, 2025
56c406a
remove xfail
jaimergp Jul 7, 2025
af9c7d5
pre-commit
jaimergp Jul 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
conda activate constructor-dev
echo "CONSTRUCTOR_CONDA_EXE=$CONDA_PREFIX/standalone_conda/conda.exe" >> $GITHUB_ENV
fi
echo "CONDA_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
- name: conda info
run: conda info
- name: conda list
Expand Down
13 changes: 11 additions & 2 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,16 @@ If `header_image` is not provided, use this text when generating the image

Add an option to the installer so the user can choose whether to run `conda init`
after the installation (Unix), or to add certain subdirectories of the installation
to PATH (Windows). See also `initialize_by_default`.
to PATH (Windows). Requires `conda` to be part of the `base` environment. Valid options:

- `classic` or `True`: runs `conda init` on Unix, which injects a shell function in the
shell profiles. On Windows, it adds `$INSTDIR`, `$INSTDIR/Scripts`, `$INSTDIR/Library/bin`
to `PATH`. This is the default.
- `condabin`: only adds `$INSTDIR/condabin` to `PATH`. On Unix, `conda>=25.5.0` is required
in `base`.
- `False`: the installer doesn't perform initialization.

See also `initialize_by_default`.

### `initialize_by_default`

Expand All @@ -500,7 +509,7 @@ is true for GUI installers (EXE, PKG) and false for shell installers. The user
is able to change the default during interactive installation. NOTE: For Windows,
`AddToPath` is disabled when `InstallationType=AllUsers`.

Only applies if `initialize_conda` is true.
Only applies if `initialize_conda` is not false.

### `register_python`

Expand Down
20 changes: 17 additions & 3 deletions constructor/_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class PkgDomains(StrEnum):
LOCAL_SYSTEM = "enable_localSystem"


class CondaInitialization(StrEnum):
CLASSIC = "classic"
CONDABIN = "condabin"


class ChannelRemap(BaseModel):
model_config: ConfigDict = _base_config_dict

Expand Down Expand Up @@ -649,11 +654,20 @@ class ConstructorConfiguration(BaseModel):
If `header_image` is not provided, use this text when generating the image
(Windows only). Defaults to `name`.
"""
initialize_conda: bool = True
initialize_conda: CondaInitialization | bool = True
"""
Add an option to the installer so the user can choose whether to run `conda init`
after the installation (Unix), or to add certain subdirectories of the installation
to PATH (Windows). See also `initialize_by_default`.
to PATH (Windows). Requires `conda` to be part of the `base` environment. Valid options:

- `classic` or `True`: runs `conda init` on Unix, which injects a shell function in the
shell profiles. On Windows, it adds `$INSTDIR`, `$INSTDIR/Scripts`, `$INSTDIR/Library/bin`
to `PATH`. This is the default.
- `condabin`: only adds `$INSTDIR/condabin` to `PATH`. On Unix, `conda>=25.5.0` is required
in `base`.
- `False`: the installer doesn't perform initialization.

See also `initialize_by_default`.
"""
initialize_by_default: bool | None = None
"""
Expand All @@ -662,7 +676,7 @@ class ConstructorConfiguration(BaseModel):
is able to change the default during interactive installation. NOTE: For Windows,
`AddToPath` is disabled when `InstallationType=AllUsers`.

Only applies if `initialize_conda` is true.
Only applies if `initialize_conda` is not false.
"""
register_python: bool = True
"""
Expand Down
23 changes: 19 additions & 4 deletions constructor/data/construct.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
"title": "ChannelRemap",
"type": "object"
},
"CondaInitialization": {
"enum": [
"classic",
"condabin"
],
"title": "CondaInitialization",
"type": "string"
},
"ExtraEnv": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -749,14 +757,21 @@
}
],
"default": null,
"description": "Default value for the option added by `initialize_conda`. The default is true for GUI installers (EXE, PKG) and false for shell installers. The user is able to change the default during interactive installation. NOTE: For Windows, `AddToPath` is disabled when `InstallationType=AllUsers`.\nOnly applies if `initialize_conda` is true.",
"description": "Default value for the option added by `initialize_conda`. The default is true for GUI installers (EXE, PKG) and false for shell installers. The user is able to change the default during interactive installation. NOTE: For Windows, `AddToPath` is disabled when `InstallationType=AllUsers`.\nOnly applies if `initialize_conda` is not false.",
"title": "Initialize By Default"
},
"initialize_conda": {
"anyOf": [
{
"$ref": "#/$defs/CondaInitialization"
},
{
"type": "boolean"
}
],
"default": true,
"description": "Add an option to the installer so the user can choose whether to run `conda init` after the installation (Unix), or to add certain subdirectories of the installation to PATH (Windows). See also `initialize_by_default`.",
"title": "Initialize Conda",
"type": "boolean"
"description": "Add an option to the installer so the user can choose whether to run `conda init` after the installation (Unix), or to add certain subdirectories of the installation to PATH (Windows). Requires `conda` to be part of the `base` environment. Valid options:\n- `classic` or `True`: runs `conda init` on Unix, which injects a shell function in the shell profiles. On Windows, it adds `$INSTDIR`, `$INSTDIR/Scripts`, `$INSTDIR/Library/bin` to `PATH`. This is the default.\n- `condabin`: only adds `$INSTDIR/condabin` to `PATH`. On Unix, `conda>=25.5.0` is required in `base`.\n- `False`: the installer doesn't perform initialization.\nSee also `initialize_by_default`.",
"title": "Initialize Conda"
},
"install_in_dependency_order": {
"anyOf": [
Expand Down
128 changes: 98 additions & 30 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ SKIP_SCRIPTS=0
{%- if enable_shortcuts == "true" %}
SKIP_SHORTCUTS=0
{%- endif %}
INIT_CONDA=0
TEST=0
REINSTALL=0
USAGE="
Expand Down Expand Up @@ -123,18 +124,30 @@ Installs ${INSTALLER_NAME} ${INSTALLER_VER}
-u update an existing installation
{%- if has_conda %}
-t run package tests after installation (may install conda-build)
{%- if initialize_conda %}
-c run 'conda init{{ ' --condabin' if initialize_conda == 'condabin' else ''}}' after installation (only applies to batch mode)
{%- endif %}
{%- endif %}
"

{#-
# We used to have a getopt version here, falling back to getopts if needed
# However getopt is not standardized and the version on Mac has different
# behaviour. getopts is good enough for what we need :)
# More info: https://unix.stackexchange.com/questions/62950/
#}
{%- set getopts_str = "bifhkp:s" %}
{%- if enable_shortcuts == "true" %}
while getopts "bifhkp:smut" x; do
{%- else %}
while getopts "bifhkp:sut" x; do
{%- set getopts_str = getopts_str ~ "m" %}
{%- endif %}
{%- set getopts_str = getopts_str ~ "u" %}
{%- if has_conda %}
{%- set getopts_str = getopts_str ~ "t" %}
{%- if initialize_conda %}
{%- set getopts_str = getopts_str ~ "c" %}
{%- endif %}
{%- endif %}
while getopts "{{ getopts_str }}" x; do
case "$x" in
h)
printf "%s\\n" "$USAGE"
Expand Down Expand Up @@ -170,6 +183,11 @@ while getopts "bifhkp:sut" x; do
t)
TEST=1
;;
{%- if initialize_conda %}
c)
INIT_CONDA=1
;;
{%- endif %}
{%- endif %}
?)
printf "ERROR: did not recognize option '%s', please try -h\\n" "$x"
Expand Down Expand Up @@ -514,7 +532,7 @@ if [ "$(id -u)" -ne 0 ]; then
fi

# the third binary payload: the tarball of packages
printf "Unpacking payload ...\n"
printf "Unpacking payload...\n"
extract_range "${boundary2}" "${boundary3}" | \
CONDA_QUIET="$BATCH" "$CONDA_EXEC" constructor --extract-tarball --prefix "$PREFIX"

Expand Down Expand Up @@ -547,12 +565,14 @@ MSGS="$PREFIX/.messages.txt"
touch "$MSGS"
export FORCE

{#-
# original issue report:
# https://github.com/ContinuumIO/anaconda-issues/issues/11148
# First try to fix it (this apparently didn't work; QA reported the issue again)
# https://github.com/conda/conda/pull/9073
# Avoid silent errors when $HOME is not writable
# https://github.com/conda/constructor/pull/669
#}
test -d ~/.conda || mkdir -p ~/.conda >/dev/null 2>/dev/null || test -d ~/.conda || mkdir ~/.conda

printf "\nInstalling base environment...\n\n"
Expand Down Expand Up @@ -635,7 +655,6 @@ rm -rf "$PREFIX/install_tmp"
export TMP="$TMP_BACKUP"


#The templating doesn't support nested if statements
{%- if has_post_install %}
if [ "$SKIP_SCRIPTS" = "1" ]; then
printf "WARNING: skipping post_install.sh by user request\\n" >&2
Expand Down Expand Up @@ -675,9 +694,66 @@ if [ "${PYTHONPATH:-}" != "" ]; then
printf " directories of packages that are compatible with the Python interpreter\\n"
printf " in %s: %s\\n" "${INSTALLER_NAME}" "$PREFIX"
fi
{% if has_conda %}
{%- if initialize_conda == 'condabin' %}
_maybe_run_conda_init_condabin() {
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m conda init --condabin zsh ;;
*) "$PREFIX/bin/python" -m conda init --condabin ;;
esac
}
{%- elif initialize_conda %}
_maybe_run_conda_init() {
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m conda init zsh ;;
*) "$PREFIX/bin/python" -m conda init ;;
esac
if [ -f "$PREFIX/bin/mamba" ]; then
# If the version of mamba is <2.0.0, we preferably use the `mamba` python module
# to perform the initialization.
#
# Otherwise (i.e. as of 2.0.0), we use the `mamba shell init` command
if [ "$("$PREFIX/bin/mamba" --version | head -n 1 | cut -d' ' -f2 | cut -d'.' -f1)" -lt 2 ]; then
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m mamba.mamba init zsh ;;
*) "$PREFIX/bin/python" -m mamba.mamba init ;;
esac
else
case $SHELL in
*zsh) "$PREFIX/bin/mamba" shell init --shell zsh ;;
*) "$PREFIX/bin/mamba" shell init ;;
esac
fi
fi
}
{%- endif %}
{%- endif %}

if [ "$BATCH" = "0" ]; then
{%- if has_conda and initialize_conda %}
{%- if has_conda %}
{%- if initialize_conda == 'condabin' %}
DEFAULT={{ 'yes' if initialize_by_default else 'no' }}

printf "Do you wish to update your shell profile to add '%s/condabin' to PATH?\\n" "$PREFIX"
printf "This will enable you to run 'conda' anywhere, without injecting a shell function.\\n"
printf "You can undo this by running \`conda init --condabin --reverse? [yes|no]\\n"
printf "[%s] >>> " "$DEFAULT"
read -r ans
if [ "$ans" = "" ]; then
ans=$DEFAULT
fi
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
if [ "$ans" != "YES" ] && [ "$ans" != "Y" ]
then
printf "\\n"
printf "'%s/condabin' will not be added to PATH.\\n" "$PREFIX"
else
_maybe_run_conda_init_condabin
fi
{%- elif initialize_conda %}
DEFAULT={{ 'yes' if initialize_by_default else 'no' }}
# Interactive mode.

Expand Down Expand Up @@ -708,34 +784,26 @@ if [ "$BATCH" = "0" ]; then
printf "conda init\\n"
printf "\\n"
else
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m conda init zsh ;;
*) "$PREFIX/bin/python" -m conda init ;;
esac
if [ -f "$PREFIX/bin/mamba" ]; then
# If the version of mamba is <2.0.0, we preferably use the `mamba` python module
# to perform the initialization.
#
# Otherwise (i.e. as of 2.0.0), we use the `mamba shell init` command
if [ "$("$PREFIX/bin/mamba" --version | head -n 1 | cut -d' ' -f2 | cut -d'.' -f1)" -lt 2 ]; then
case $SHELL in
# We call the module directly to avoid issues with spaces in shebang
*zsh) "$PREFIX/bin/python" -m mamba.mamba init zsh ;;
*) "$PREFIX/bin/python" -m mamba.mamba init ;;
esac
else
case $SHELL in
*zsh) "$PREFIX/bin/mamba" shell init --shell zsh ;;
*) "$PREFIX/bin/mamba" shell init ;;
esac
fi
fi
_maybe_run_conda_init
fi
{%- endif %}
{%- endif %}

printf "Thank you for installing %s!\\n" "${INSTALLER_NAME}"
fi # !BATCH
{#- End of Interactive mode #}
{#- Batch mode #}
{%- if has_conda and initialize_conda %}
elif [ "$INIT_CONDA" = "1" ]; then
{%- if initialize_conda == 'condabin' %}
printf "Adding '%s/condabin' to PATH...\\n" "$PREFIX"
_maybe_run_conda_init_condabin
{%- else %}
printf "Initializing '%s' with 'conda init'...\\n" "$PREFIX"
_maybe_run_conda_init
{%- endif %}
{%- endif %}
{#- End of Batch mode #}
fi


{%- if has_conda %}
Expand Down
10 changes: 10 additions & 0 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ def main_build(
# '_dists': list[Dist]
# '_urls': list[Tuple[url, md5]]

if initialize_conda := info.get("initialize_conda"):
if not info.get("_has_conda"):
sys.exit("Error: 'initialize_conda' requires 'conda' in the base environment.")
if initialize_conda == "condabin" and platform.startswith(("linux-", "osx-")):
conda = next(record for record in info.get("_records", ()) if record.name == "conda")
if Version(conda.version) < Version("25.5.0"):
sys.exit(
"Error: 'initialize_conda == condabin' requires 'conda >=25.5.0' in base env."
)

os.makedirs(output_dir, exist_ok=True)
info_dicts = []
for itype in itypes:
Expand Down
Loading
Loading